fix(deepseek): more aggressive R1 fix and detailed error logging
- Ensure assistant tool calls always have content: "" instead of null. - Add debug-level logging of the full request body when DeepSeek returns 400. - Improved R1 placeholder injection to include content sanitation.
This commit is contained in:
@@ -65,10 +65,10 @@ pub async fn messages_to_openai_json(messages: &[UnifiedMessage]) -> Result<Vec<
|
||||
msg["reasoning_content"] = serde_json::json!(reasoning);
|
||||
}
|
||||
|
||||
// For assistant messages with tool_calls, content can be null
|
||||
// For assistant messages with tool_calls, content can be empty string
|
||||
if let Some(tool_calls) = &m.tool_calls {
|
||||
if parts.is_empty() {
|
||||
msg["content"] = serde_json::Value::Null;
|
||||
msg["content"] = serde_json::json!("");
|
||||
} else {
|
||||
msg["content"] = serde_json::json!(parts);
|
||||
}
|
||||
@@ -143,10 +143,10 @@ pub async fn messages_to_openai_json_text_only(
|
||||
msg["reasoning_content"] = serde_json::json!(reasoning);
|
||||
}
|
||||
|
||||
// For assistant messages with tool_calls, content can be null
|
||||
// For assistant messages with tool_calls, content can be empty string
|
||||
if let Some(tool_calls) = &m.tool_calls {
|
||||
if parts.is_empty() {
|
||||
msg["content"] = serde_json::Value::Null;
|
||||
msg["content"] = serde_json::json!("");
|
||||
} else {
|
||||
msg["content"] = serde_json::json!(parts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user