mirror of
https://github.com/katanemo/plano.git
synced 2026-06-29 15:49:40 +02:00
Add tests for default selection policy behavior in routing preferences
This commit is contained in:
parent
3fde960a19
commit
eb00a48b55
2 changed files with 38 additions and 0 deletions
|
|
@ -283,6 +283,43 @@ mod tests {
|
||||||
assert_eq!(prefs[0].selection_policy.prefer, SelectionPreference::None);
|
assert_eq!(prefs[0].selection_policy.prefer, SelectionPreference::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn extract_routing_policy_selection_policy_missing_defaults_to_none() {
|
||||||
|
let policy = r#""routing_preferences": [
|
||||||
|
{
|
||||||
|
"name": "coding",
|
||||||
|
"description": "code generation, writing functions, debugging",
|
||||||
|
"models": ["openai/gpt-4o", "openai/gpt-4o-mini"]
|
||||||
|
}
|
||||||
|
]"#;
|
||||||
|
let body = make_chat_body(policy);
|
||||||
|
let (_cleaned, prefs) = extract_routing_policy(&body).unwrap();
|
||||||
|
|
||||||
|
let prefs =
|
||||||
|
prefs.expect("should parse routing_preferences when selection_policy is missing");
|
||||||
|
assert_eq!(prefs.len(), 1);
|
||||||
|
assert_eq!(prefs[0].selection_policy.prefer, SelectionPreference::None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn extract_routing_policy_prefer_empty_string_defaults_to_none() {
|
||||||
|
let policy = r#""routing_preferences": [
|
||||||
|
{
|
||||||
|
"name": "coding",
|
||||||
|
"description": "code generation, writing functions, debugging",
|
||||||
|
"models": ["openai/gpt-4o", "openai/gpt-4o-mini"],
|
||||||
|
"selection_policy": {"prefer": ""}
|
||||||
|
}
|
||||||
|
]"#;
|
||||||
|
let body = make_chat_body(policy);
|
||||||
|
let (_cleaned, prefs) = extract_routing_policy(&body).unwrap();
|
||||||
|
|
||||||
|
let prefs =
|
||||||
|
prefs.expect("should parse routing_preferences when selection_policy.prefer is empty");
|
||||||
|
assert_eq!(prefs.len(), 1);
|
||||||
|
assert_eq!(prefs[0].selection_policy.prefer, SelectionPreference::None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn routing_decision_response_serialization() {
|
fn routing_decision_response_serialization() {
|
||||||
let response = RoutingDecisionResponse {
|
let response = RoutingDecisionResponse {
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ pub enum SelectionPreference {
|
||||||
Fastest,
|
Fastest,
|
||||||
/// Return models in the same order they were defined — no reordering.
|
/// Return models in the same order they were defined — no reordering.
|
||||||
#[default]
|
#[default]
|
||||||
|
#[serde(alias = "")]
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue