浏览代码

Fix <think> in keywords or question auto-generations. (#5021)

### What problem does this PR solve?

**#4983**

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.17.0
Kevin Hu 8 个月前
父节点
当前提交
810f997276
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4
    0
      api/db/services/dialog_service.py

+ 4
- 0
api/db/services/dialog_service.py 查看文件

kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.2}) kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.2})
if isinstance(kwd, tuple): if isinstance(kwd, tuple):
kwd = kwd[0] kwd = kwd[0]
kwd = re.sub(r"<think>.*</think>", "", kwd)
if kwd.find("**ERROR**") >= 0: if kwd.find("**ERROR**") >= 0:
return "" return ""
return kwd return kwd
kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.2}) kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.2})
if isinstance(kwd, tuple): if isinstance(kwd, tuple):
kwd = kwd[0] kwd = kwd[0]
kwd = re.sub(r"<think>.*</think>", "", kwd)
if kwd.find("**ERROR**") >= 0: if kwd.find("**ERROR**") >= 0:
return "" return ""
return kwd return kwd
############### ###############
""" """
ans = chat_mdl.chat(prompt, [{"role": "user", "content": "Output: "}], {"temperature": 0.2}) ans = chat_mdl.chat(prompt, [{"role": "user", "content": "Output: "}], {"temperature": 0.2})
ans = re.sub(r"<think>.*</think>", "", ans)
return ans if ans.find("**ERROR**") < 0 else messages[-1]["content"] return ans if ans.find("**ERROR**") < 0 else messages[-1]["content"]




kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.5}) kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.5})
if isinstance(kwd, tuple): if isinstance(kwd, tuple):
kwd = kwd[0] kwd = kwd[0]
kwd = re.sub(r"<think>.*</think>", "", kwd)
if kwd.find("**ERROR**") >= 0: if kwd.find("**ERROR**") >= 0:
raise Exception(kwd) raise Exception(kwd)



正在加载...
取消
保存