fix: revert shared helper changes that broke standard OpenAI models
- Move DeepSeek R1 reasoning_content and content:"" fixes to DeepSeekProvider only. - Restore OpenAI-standard null content for tool calls in helpers.rs. - Fixes 400 Bad Request for gpt-5-nano and other strict OpenAI models.
This commit is contained in:
@@ -60,15 +60,10 @@ pub async fn messages_to_openai_json(messages: &[UnifiedMessage]) -> Result<Vec<
|
||||
|
||||
let mut msg = serde_json::json!({ "role": m.role });
|
||||
|
||||
// Include reasoning_content if present (DeepSeek R1/reasoner requires this in history)
|
||||
if let Some(reasoning) = &m.reasoning_content {
|
||||
msg["reasoning_content"] = serde_json::json!(reasoning);
|
||||
}
|
||||
|
||||
// For assistant messages with tool_calls, content can be empty string
|
||||
// For assistant messages with tool_calls, content can be null
|
||||
if let Some(tool_calls) = &m.tool_calls {
|
||||
if parts.is_empty() {
|
||||
msg["content"] = serde_json::json!("");
|
||||
msg["content"] = serde_json::Value::Null;
|
||||
} else {
|
||||
msg["content"] = serde_json::json!(parts);
|
||||
}
|
||||
@@ -138,15 +133,10 @@ pub async fn messages_to_openai_json_text_only(
|
||||
|
||||
let mut msg = serde_json::json!({ "role": m.role });
|
||||
|
||||
// Include reasoning_content if present (DeepSeek R1/reasoner requires this in history)
|
||||
if let Some(reasoning) = &m.reasoning_content {
|
||||
msg["reasoning_content"] = serde_json::json!(reasoning);
|
||||
}
|
||||
|
||||
// For assistant messages with tool_calls, content can be empty string
|
||||
// For assistant messages with tool_calls, content can be null
|
||||
if let Some(tool_calls) = &m.tool_calls {
|
||||
if parts.is_empty() {
|
||||
msg["content"] = serde_json::json!("");
|
||||
msg["content"] = serde_json::Value::Null;
|
||||
} else {
|
||||
msg["content"] = serde_json::json!(parts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user