Skip to content

Commit 5708979

Browse files
committed
fix: 兼容,vllm qwq 推理内容(没有<think>,只有</think>)
1 parent 4fa6736 commit 5708979

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/llm/client/ollama_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ def _extract_content(self, content: str) -> str:
2727
Returns:
2828
str: 提取后的内容。
2929
"""
30-
if re.search(r'<think>.*?</think>', content, re.DOTALL):
31-
return re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
32-
elif "<think>" in content and "</think>" not in content:
30+
if "<think>" in content and "</think>" not in content:
3331
# 大模型回复的时候,思考链有可能截断,那么果断忽略回复,返回空
3432
return "COT ABORT!"
33+
elif "<think>" not in content and "</think>" in content:
34+
return content.split("</think>", 1)[1].strip()
35+
elif re.search(r'<think>.*?</think>', content, re.DOTALL):
36+
return re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
3537
return content
3638

3739
def completions(self,

0 commit comments

Comments
 (0)