Accept wrapped text content from LLM providers (#31048)
Some providers sometimes send `{ "type": "text", "text": ... }` instead of just the text as a string. Now we accept those instead of erroring. Release Notes: - N/A
This commit is contained in:
parent
89700c3682
commit
4bb04cef9d
9 changed files with 72 additions and 26 deletions
|
@ -426,14 +426,17 @@ pub fn into_google(
|
|||
}
|
||||
language_model::MessageContent::ToolResult(tool_result) => {
|
||||
match tool_result.content {
|
||||
language_model::LanguageModelToolResultContent::Text(txt) => {
|
||||
language_model::LanguageModelToolResultContent::Text(text)
|
||||
| language_model::LanguageModelToolResultContent::WrappedText(
|
||||
language_model::WrappedTextContent { text, .. },
|
||||
) => {
|
||||
vec![Part::FunctionResponsePart(
|
||||
google_ai::FunctionResponsePart {
|
||||
function_response: google_ai::FunctionResponse {
|
||||
name: tool_result.tool_name.to_string(),
|
||||
// The API expects a valid JSON object
|
||||
response: serde_json::json!({
|
||||
"output": txt
|
||||
"output": text
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue