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,7 +1246,21 @@ async fn chat_completions(
|
||||
if let Value::Object(ref mut props) = arguments {
|
||||
props.remove("_name");
|
||||
}
|
||||
|
||||
match name.as_str() {
|
||||
"notify_error" => {
|
||||
// parse the error message
|
||||
let error_message = arguments
|
||||
.get("error")
|
||||
.and_then(Value::as_str)
|
||||
.ok_or_else(|| {
|
||||
InferError::ToolError(
|
||||
"No error message found in generated text".to_string(),
|
||||
)
|
||||
})?
|
||||
.to_string();
|
||||
(None, Some(error_message))
|
||||
}
|
||||
_ => {
|
||||
let tool_calls = vec![ToolCall {
|
||||
id: "0".to_string(),
|
||||
r#type: "function".to_string(),
|
||||
@ -1257,6 +1271,8 @@ async fn chat_completions(
|
||||
},
|
||||
}];
|
||||
(Some(tool_calls), None)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
(None, Some(generation.generated_text))
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user