deepseek: Add tool_choice field to DeepSeek request model (#56040)

Release Notes:

- N/A

reference: https://api-docs.deepseek.com/api/create-chat-completion/
This commit is contained in:
Xiaobo Liu 2026-05-12 16:21:38 +08:00 committed by GitHub
parent 57765207c8
commit 166c53206e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -126,6 +126,8 @@ pub struct Request {
pub reasoning_effort: Option<ReasoningEffort>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub response_format: Option<ResponseFormat>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool_choice: Option<ToolChoice>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub tools: Vec<ToolDefinition>,
}
@ -158,6 +160,14 @@ pub enum ResponseFormat {
JsonObject,
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ToolChoice {
None,
Auto,
Required,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ToolDefinition {

View file

@ -450,6 +450,11 @@ pub fn into_deepseek(
None
},
response_format: None,
tool_choice: request.tool_choice.map(|choice| match choice {
LanguageModelToolChoice::Auto => deepseek::ToolChoice::Auto,
LanguageModelToolChoice::Any => deepseek::ToolChoice::Required,
LanguageModelToolChoice::None => deepseek::ToolChoice::None,
}),
tools: request
.tools
.into_iter()