Compare commits
2 Commits
6440e8cc13
...
c7b67d5840
| Author | SHA1 | Date | |
|---|---|---|---|
| c7b67d5840 | |||
| 7efb36029c |
@@ -57,7 +57,22 @@ impl super::Provider for DeepSeekProvider {
|
|||||||
|
|
||||||
async fn chat_completion(&self, request: UnifiedRequest) -> Result<ProviderResponse, AppError> {
|
async fn chat_completion(&self, request: UnifiedRequest) -> Result<ProviderResponse, AppError> {
|
||||||
let messages_json = helpers::messages_to_openai_json(&request.messages).await?;
|
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
|
let response = self
|
||||||
.client
|
.client
|
||||||
@@ -114,7 +129,28 @@ impl super::Provider for DeepSeekProvider {
|
|||||||
// DeepSeek doesn't support images in streaming, use text-only
|
// DeepSeek doesn't support images in streaming, use text-only
|
||||||
let messages_json = helpers::messages_to_openai_json_text_only(&request.messages).await?;
|
let messages_json = helpers::messages_to_openai_json_text_only(&request.messages).await?;
|
||||||
let mut body = helpers::build_openai_body(&request, messages_json, true);
|
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(
|
let es = reqwest_eventsource::EventSource::new(
|
||||||
self.client
|
self.client
|
||||||
|
|||||||
Reference in New Issue
Block a user