mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 20:34:54 +00:00
feat: unroll notify_error if no tool is choosen
This commit is contained in:
parent
d1f257ac56
commit
dfc4559017
@ -1246,17 +1246,33 @@ async fn chat_completions(
|
|||||||
if let Value::Object(ref mut props) = arguments {
|
if let Value::Object(ref mut props) = arguments {
|
||||||
props.remove("_name");
|
props.remove("_name");
|
||||||
}
|
}
|
||||||
|
match name.as_str() {
|
||||||
let tool_calls = vec![ToolCall {
|
"notify_error" => {
|
||||||
id: "0".to_string(),
|
// parse the error message
|
||||||
r#type: "function".to_string(),
|
let error_message = arguments
|
||||||
function: FunctionDefinition {
|
.get("error")
|
||||||
description: None,
|
.and_then(Value::as_str)
|
||||||
name,
|
.ok_or_else(|| {
|
||||||
arguments,
|
InferError::ToolError(
|
||||||
},
|
"No error message found in generated text".to_string(),
|
||||||
}];
|
)
|
||||||
(Some(tool_calls), None)
|
})?
|
||||||
|
.to_string();
|
||||||
|
(None, Some(error_message))
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let tool_calls = vec![ToolCall {
|
||||||
|
id: "0".to_string(),
|
||||||
|
r#type: "function".to_string(),
|
||||||
|
function: FunctionDefinition {
|
||||||
|
description: None,
|
||||||
|
name,
|
||||||
|
arguments,
|
||||||
|
},
|
||||||
|
}];
|
||||||
|
(Some(tool_calls), None)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(None, Some(generation.generated_text))
|
(None, Some(generation.generated_text))
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user