Skip to content

Commit 72a0305

Browse files
committed
fix: consolidate changes and remove old tool type
1 parent a071ccd commit 72a0305

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

docs/openapi.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,12 +2114,18 @@
21142114
"ToolType": {
21152115
"oneOf": [
21162116
{
2117-
"type": "object",
2118-
"default": null,
2119-
"nullable": true
2117+
"type": "string",
2118+
"description": "Means the model can pick between generating a message or calling one or more tools.",
2119+
"enum": [
2120+
"auto"
2121+
]
21202122
},
21212123
{
2122-
"type": "string"
2124+
"type": "string",
2125+
"description": "Means the model will not call any tool and instead generates a message.",
2126+
"enum": [
2127+
"none"
2128+
]
21232129
},
21242130
{
21252131
"type": "object",
@@ -2131,13 +2137,10 @@
21312137
"$ref": "#/components/schemas/FunctionName"
21322138
}
21332139
}
2134-
},
2135-
{
2136-
"type": "object",
2137-
"default": null,
2138-
"nullable": true
21392140
}
2140-
]
2141+
],
2142+
"description": "Controls which (if any) tool is called by the model.",
2143+
"example": "auto"
21412144
},
21422145
"Url": {
21432146
"type": "object",

router/src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,7 @@ pub struct ToolChoice(pub Option<ToolType>);
993993
enum ToolTypeDeserializer {
994994
Null,
995995
String(String),
996-
ToolType(ToolType),
997-
TypedChoice(TypedChoice), //this is the OpenAI schema
996+
ToolType(TypedChoice),
998997
}
999998

1000999
impl From<ToolTypeDeserializer> for ToolChoice {
@@ -1006,10 +1005,9 @@ impl From<ToolTypeDeserializer> for ToolChoice {
10061005
"auto" => ToolChoice(Some(ToolType::OneOf)),
10071006
_ => ToolChoice(Some(ToolType::Function(FunctionName { name: s }))),
10081007
},
1009-
ToolTypeDeserializer::TypedChoice(TypedChoice::Function { function }) => {
1008+
ToolTypeDeserializer::ToolType(TypedChoice::Function { function }) => {
10101009
ToolChoice(Some(ToolType::Function(function)))
10111010
}
1012-
ToolTypeDeserializer::ToolType(tool_type) => ToolChoice(Some(tool_type)),
10131011
}
10141012
}
10151013
}
@@ -1640,10 +1638,6 @@ mod tests {
16401638
let de_named: TestRequest = serde_json::from_str(named).unwrap();
16411639
assert_eq!(de_named.tool_choice, ref_choice);
16421640

1643-
let old_named = r#"{"tool_choice":{"function":{"name":"myfn"}}}"#;
1644-
let de_old_named: TestRequest = serde_json::from_str(old_named).unwrap();
1645-
assert_eq!(de_old_named.tool_choice, ref_choice);
1646-
16471641
let openai_named = r#"{"tool_choice":{"type":"function","function":{"name":"myfn"}}}"#;
16481642
let de_openai_named: TestRequest = serde_json::from_str(openai_named).unwrap();
16491643

0 commit comments

Comments
 (0)