fix: run linter and bump api docs

This commit is contained in:
David Holtz 2024-10-14 14:26:45 +00:00 committed by drbh
parent 151f950eea
commit 2c172a2da7
2 changed files with 15 additions and 35 deletions

View File

@ -2245,18 +2245,12 @@
"ToolType": {
"oneOf": [
{
"type": "string",
"description": "Means the model can pick between generating a message or calling one or more tools.",
"enum": [
"auto"
]
"type": "object",
"default": null,
"nullable": true
},
{
"type": "string",
"description": "Means the model will not call any tool and instead generates a message.",
"enum": [
"none"
]
"type": "string"
},
{
"type": "object",
@ -2271,26 +2265,11 @@
},
{
"type": "object",
"required": [
"type",
"function"
],
"properties": {
"type": {
"type": "string",
"enum": [
"function"
"default": null,
"nullable": true
}
]
},
"function": {
"$ref": "#/components/schemas/FunctionName"
}
}
}
],
"description": "Controls which (if any) tool is called by the model.",
"example": "auto"
},
"Url": {
"type": "object",
"required": [

View File

@ -1015,7 +1015,6 @@ pub enum ToolType {
Function(FunctionName),
}
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(tag = "type")]
pub enum TypedChoice {
@ -1038,10 +1037,9 @@ enum ToolTypeDeserializer {
Null,
String(String),
ToolType(ToolType),
TypedChoice(TypedChoice) //this is the OpenAI schema
TypedChoice(TypedChoice), //this is the OpenAI schema
}
impl From<ToolTypeDeserializer> for ToolChoice {
fn from(value: ToolTypeDeserializer) -> Self {
match value {
@ -1051,7 +1049,9 @@ impl From<ToolTypeDeserializer> for ToolChoice {
"auto" => ToolChoice(Some(ToolType::OneOf)),
_ => ToolChoice(Some(ToolType::Function(FunctionName { name: s }))),
},
ToolTypeDeserializer::TypedChoice(TypedChoice::Function{function}) => ToolChoice(Some(ToolType::Function(function))),
ToolTypeDeserializer::TypedChoice(TypedChoice::Function { function }) => {
ToolChoice(Some(ToolType::Function(function)))
}
ToolTypeDeserializer::ToolType(tool_type) => ToolChoice(Some(tool_type)),
}
}
@ -1661,7 +1661,6 @@ mod tests {
#[test]
fn tool_choice_formats() {
#[derive(Deserialize)]
struct TestRequest {
tool_choice: ToolChoice,
@ -1675,7 +1674,9 @@ mod tests {
let de_auto: TestRequest = serde_json::from_str(auto).unwrap();
assert_eq!(de_auto.tool_choice, ToolChoice(Some(ToolType::OneOf)));
let ref_choice = ToolChoice(Some(ToolType::Function(FunctionName { name: "myfn".to_string() })));
let ref_choice = ToolChoice(Some(ToolType::Function(FunctionName {
name: "myfn".to_string(),
})));
let named = r#"{"tool_choice":"myfn"}"#;
let de_named: TestRequest = serde_json::from_str(named).unwrap();