修复空回复检测,同时修复tool_call
This commit is contained in:
@@ -329,7 +329,10 @@ class LLMRequest:
|
|||||||
content, extracted_reasoning = self._extract_reasoning(content)
|
content, extracted_reasoning = self._extract_reasoning(content)
|
||||||
reasoning_content = extracted_reasoning
|
reasoning_content = extracted_reasoning
|
||||||
|
|
||||||
|
is_empty_reply = False
|
||||||
|
is_truncated = False
|
||||||
# 检测是否为空回复或截断
|
# 检测是否为空回复或截断
|
||||||
|
if not tool_calls:
|
||||||
is_empty_reply = not content or content.strip() == ""
|
is_empty_reply = not content or content.strip() == ""
|
||||||
is_truncated = False
|
is_truncated = False
|
||||||
|
|
||||||
@@ -370,7 +373,7 @@ class LLMRequest:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 处理空回复
|
# 处理空回复
|
||||||
if not content:
|
if not content and not tool_calls:
|
||||||
if raise_when_empty:
|
if raise_when_empty:
|
||||||
raise RuntimeError(f"经过 {empty_retry_count} 次重试后仍然生成空回复")
|
raise RuntimeError(f"经过 {empty_retry_count} 次重试后仍然生成空回复")
|
||||||
content = "生成的响应为空,请检查模型配置或输入内容是否正确"
|
content = "生成的响应为空,请检查模型配置或输入内容是否正确"
|
||||||
|
|||||||
Reference in New Issue
Block a user