Skip to content

Commit

Permalink
feat: return the generated text when parsing fails (#2353)
Browse files Browse the repository at this point in the history
  • Loading branch information
drbh authored Aug 6, 2024
1 parent f8a5b38 commit 1768c00
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions router/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))?;
Expand Down

0 comments on commit 1768c00

Please sign in to comment.