mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 20:34:54 +00:00
fix: run linter and bump api docs
This commit is contained in:
parent
151f950eea
commit
2c172a2da7
@ -2245,18 +2245,12 @@
|
|||||||
"ToolType": {
|
"ToolType": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "object",
|
||||||
"description": "Means the model can pick between generating a message or calling one or more tools.",
|
"default": null,
|
||||||
"enum": [
|
"nullable": true
|
||||||
"auto"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"description": "Means the model will not call any tool and instead generates a message.",
|
|
||||||
"enum": [
|
|
||||||
"none"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -2271,25 +2265,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"default": null,
|
||||||
"type",
|
"nullable": true
|
||||||
"function"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"function"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"function": {
|
|
||||||
"$ref": "#/components/schemas/FunctionName"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"description": "Controls which (if any) tool is called by the model.",
|
|
||||||
"example": "auto"
|
|
||||||
},
|
},
|
||||||
"Url": {
|
"Url": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -1015,12 +1015,11 @@ pub enum ToolType {
|
|||||||
Function(FunctionName),
|
Function(FunctionName),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum TypedChoice {
|
pub enum TypedChoice {
|
||||||
#[serde(rename = "function")]
|
#[serde(rename = "function")]
|
||||||
Function{function: FunctionName},
|
Function { function: FunctionName },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ToSchema)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ToSchema)]
|
||||||
@ -1038,10 +1037,9 @@ enum ToolTypeDeserializer {
|
|||||||
Null,
|
Null,
|
||||||
String(String),
|
String(String),
|
||||||
ToolType(ToolType),
|
ToolType(ToolType),
|
||||||
TypedChoice(TypedChoice) //this is the OpenAI schema
|
TypedChoice(TypedChoice), //this is the OpenAI schema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl From<ToolTypeDeserializer> for ToolChoice {
|
impl From<ToolTypeDeserializer> for ToolChoice {
|
||||||
fn from(value: ToolTypeDeserializer) -> Self {
|
fn from(value: ToolTypeDeserializer) -> Self {
|
||||||
match value {
|
match value {
|
||||||
@ -1051,7 +1049,9 @@ impl From<ToolTypeDeserializer> for ToolChoice {
|
|||||||
"auto" => ToolChoice(Some(ToolType::OneOf)),
|
"auto" => ToolChoice(Some(ToolType::OneOf)),
|
||||||
_ => ToolChoice(Some(ToolType::Function(FunctionName { name: s }))),
|
_ => 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)),
|
ToolTypeDeserializer::ToolType(tool_type) => ToolChoice(Some(tool_type)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1661,7 +1661,6 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tool_choice_formats() {
|
fn tool_choice_formats() {
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct TestRequest {
|
struct TestRequest {
|
||||||
tool_choice: ToolChoice,
|
tool_choice: ToolChoice,
|
||||||
@ -1675,7 +1674,9 @@ mod tests {
|
|||||||
let de_auto: TestRequest = serde_json::from_str(auto).unwrap();
|
let de_auto: TestRequest = serde_json::from_str(auto).unwrap();
|
||||||
assert_eq!(de_auto.tool_choice, ToolChoice(Some(ToolType::OneOf)));
|
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 named = r#"{"tool_choice":"myfn"}"#;
|
||||||
let de_named: TestRequest = serde_json::from_str(named).unwrap();
|
let de_named: TestRequest = serde_json::from_str(named).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user