feat: return the generated text when parsing fails (#2353)
This commit is contained in:
parent
f8a5b381fe
commit
1768c00b9f
|
@ -1246,9 +1246,13 @@ async fn chat_completions(
|
|||
.as_secs();
|
||||
|
||||
let (tool_calls, output) = if tool_grammar.is_some() {
|
||||
let gen_text_value: Value = serde_json::from_str(&generation.generated_text)
|
||||
.map_err(|e| InferError::ToolError(e.to_string()))?;
|
||||
|
||||
let gen_text_value: Value =
|
||||
serde_json::from_str(&generation.generated_text).map_err(|e| {
|
||||
InferError::ToolError(format!(
|
||||
"Failed to parse generated text: {} {:?}",
|
||||
e, generation.generated_text
|
||||
))
|
||||
})?;
|
||||
let function = gen_text_value.get("function").ok_or(InferError::ToolError(
|
||||
"No function found in generated text".to_string(),
|
||||
))?;
|
||||
|
|
Loading…
Reference in New Issue