Skip to content

Commit 10434e2

Browse files
committed
fix: 修正,大模型应答异常情况下,思考回复会当做评论发布
1 parent 3273b16 commit 10434e2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/llm/client/ollama_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def _extract_content(self, content: str) -> str:
2929
"""
3030
if re.search(r'<think>.*?</think>', content, re.DOTALL):
3131
return re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
32+
elif "<think>" in content and "</think>" not in content:
33+
# 大模型回复的时候,思考链有可能截断,那么果断忽略回复,返回空
34+
return "COT ABORT!"
3235
return content
3336

3437
def completions(self,

0 commit comments

Comments
 (0)