Compare commits

...

2 Commits

Author SHA1 Message Date
c7b67d5840 fix(deepseek): add more exhaustive sanitation for deepseek-reasoner
Some checks failed
CI / Check (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Formatting (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Release Build (push) Has been cancelled
R1 model does not support presence_penalty, frequency_penalty, logit_bias,
logprobs, or top_logprobs. Added these to the list of stripped parameters.
2026-03-05 17:59:49 +00:00
7efb36029c fix(deepseek): sanitize requests for deepseek-reasoner
deepseek-reasoner (R1) does not support tools, temperature, or top_p.
These fields are now stripped to avoid 400 Bad Request errors.
2026-03-05 17:59:31 +00:00

View File

@@ -57,7 +57,22 @@ impl super::Provider for DeepSeekProvider {
async fn chat_completion(&self, request: UnifiedRequest) -> Result<ProviderResponse, AppError> {
let messages_json = helpers::messages_to_openai_json(&request.messages).await?;
let body = helpers::build_openai_body(&request, messages_json, false);
let mut body = helpers::build_openai_body(&request, messages_json, false);
// Sanitize for deepseek-reasoner
if request.model == "deepseek-reasoner" {
if let Some(obj) = body.as_object_mut() {
obj.remove("tools");
obj.remove("tool_choice");
obj.remove("temperature");
obj.remove("top_p");
obj.remove("presence_penalty");
obj.remove("frequency_penalty");
obj.remove("logit_bias");
obj.remove("logprobs");
obj.remove("top_logprobs");
}
}
let response = self
.client
@@ -114,7 +129,28 @@ impl super::Provider for DeepSeekProvider {
// DeepSeek doesn't support images in streaming, use text-only
let messages_json = helpers::messages_to_openai_json_text_only(&request.messages).await?;
let mut body = helpers::build_openai_body(&request, messages_json, true);
body.as_object_mut().expect("body is object").remove("stream_options");
// DeepSeek reasoning model doesn't support stream_options
if request.model == "deepseek-reasoner" {
if let Some(obj) = body.as_object_mut() {
obj.remove("stream_options");
// Also does not support these parameters
obj.remove("tools");
obj.remove("tool_choice");
obj.remove("temperature");
obj.remove("top_p");
obj.remove("presence_penalty");
obj.remove("frequency_penalty");
obj.remove("logit_bias");
obj.remove("logprobs");
obj.remove("top_logprobs");
}
} else {
// For standard deepseek-chat, keep it clean
if let Some(obj) = body.as_object_mut() {
obj.remove("stream_options");
}
}
let es = reqwest_eventsource::EventSource::new(
self.client