Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion astrbot/core/provider/sources/openai_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,11 @@
"""Finally convert the payload. Such as think part conversion, tool inject."""
model = payloads.get("model", "").lower()
is_gemini = "gemini" in model
deepseek_reasoning_models = {"deepseek-v4-pro", "deepseek-v4-flash"}
is_deepseek_v4_reasoning = (
model in deepseek_reasoning_models
or "api.deepseek.com" in self.client.base_url.host
)

for message in payloads.get("messages", []):
if message.get("role") == "assistant" and isinstance(
Expand All @@ -978,7 +983,14 @@
# Some providers (Grok, etc.) reject empty content lists.
# When all parts were think blocks, fall back to None.
message["content"] = new_content or None
if reasoning_content:
if is_deepseek_v4_reasoning and not reasoning_content:
logger.info(
"Deepseek v4 model requires non-empty reasoning content, but got empty. Setting to 'none' to satisfy the requirement."

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
api.deepseek.com
may be at an arbitrary position in the sanitized URL.
)
# Deepseek models require the field on assistant
# history messages, even when the reasoning content is empty.
message["reasoning_content"] = "none"
elif reasoning_content:
message["reasoning_content"] = reasoning_content

# Gemini 的 function_response 要求 google.protobuf.Struct(即 JSON 对象),
Expand Down
Loading