language_models: Fix tool_choice null issue for other providers (#34554)

Follow up: #34532

Closes #35434 

Mostly fixes a issue were when the tool_choice is none it was getting
serialised as null. This was fixed for openrouter just wanted to follow
up and cleanup for other providers which might have this issue as this
is against the spec.

Release Notes:

- N/A
This commit is contained in:
Umesh Yadav
2025-09-03 01:22:57 +02:00
committed by GitHub
parent 946efb03df
commit 9f749881b3
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -86,11 +86,12 @@ impl Model {
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
#[serde(rename_all = "lowercase")]
pub enum ToolChoice {
Auto,
Required,
None,
#[serde(untagged)]
Other(ToolDefinition),
}
+2 -1
View File
@@ -286,12 +286,13 @@ pub enum Prediction {
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "lowercase")]
pub enum ToolChoice {
Auto,
Required,
None,
Any,
#[serde(untagged)]
Function(ToolDefinition),
}
+2 -1
View File
@@ -269,11 +269,12 @@ pub struct Request {
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
#[serde(rename_all = "lowercase")]
pub enum ToolChoice {
Auto,
Required,
None,
#[serde(untagged)]
Other(ToolDefinition),
}