修复空回复检测,同时修复tool_call

This commit is contained in:
Windpicker-owo
2025-08-27 17:39:28 +08:00
parent 6c885afe9d
commit bbbb9df112

View File

@@ -328,10 +328,13 @@ class LLMRequest:
if not reasoning_content and content:
content, extracted_reasoning = self._extract_reasoning(content)
reasoning_content = extracted_reasoning
# 检测是否为空回复或截断
is_empty_reply = not content or content.strip() == ""
is_empty_reply = False
is_truncated = False
# 检测是否为空回复或截断
if not tool_calls:
is_empty_reply = not content or content.strip() == ""
is_truncated = False
if use_anti_truncation:
if content.endswith("[done]"):
@@ -370,7 +373,7 @@ class LLMRequest:
)
# 处理空回复
if not content:
if not content and not tool_calls:
if raise_when_empty:
raise RuntimeError(f"经过 {empty_retry_count} 次重试后仍然生成空回复")
content = "生成的响应为空,请检查模型配置或输入内容是否正确"