gemini: Fix "invalid argument" error when request contains no tools (#28747)
When we do not have any tools, we want to set the `tools` field to `None` Release Notes: - Fixed an issue where Gemini requests would sometimes return a Bad Request ("Invalid argument...")
This commit is contained in:
parent
cfc848d24b
commit
e1c42315dc
1 changed files with 13 additions and 11 deletions
|
@ -417,17 +417,19 @@ pub fn into_google(
|
||||||
top_k: None,
|
top_k: None,
|
||||||
}),
|
}),
|
||||||
safety_settings: None,
|
safety_settings: None,
|
||||||
tools: Some(vec![google_ai::Tool {
|
tools: (request.tools.len() > 0).then(|| {
|
||||||
function_declarations: request
|
vec![google_ai::Tool {
|
||||||
.tools
|
function_declarations: request
|
||||||
.into_iter()
|
.tools
|
||||||
.map(|tool| FunctionDeclaration {
|
.into_iter()
|
||||||
name: tool.name,
|
.map(|tool| FunctionDeclaration {
|
||||||
description: tool.description,
|
name: tool.name,
|
||||||
parameters: tool.input_schema,
|
description: tool.description,
|
||||||
})
|
parameters: tool.input_schema,
|
||||||
.collect(),
|
})
|
||||||
}]),
|
.collect(),
|
||||||
|
}]
|
||||||
|
}),
|
||||||
tool_config: None,
|
tool_config: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue