Ver código fonte

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 meses atrás
pai
commit
810f997276
Nenhuma conta vinculada ao e-mail do autor do commit
1 arquivos alterados com 4 adições e 0 exclusões
  1. 4
    0
      api/db/services/dialog_service.py

+ 4
- 0
api/db/services/dialog_service.py Ver arquivo

@@ -570,6 +570,7 @@ Requirements:
kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.2})
if isinstance(kwd, tuple):
kwd = kwd[0]
kwd = re.sub(r"<think>.*</think>", "", kwd)
if kwd.find("**ERROR**") >= 0:
return ""
return kwd
@@ -599,6 +600,7 @@ Requirements:
kwd = chat_mdl.chat(prompt, msg[1:], {"temperature": 0.2})
if isinstance(kwd, tuple):
kwd = kwd[0]
kwd = re.sub(r"<think>.*</think>", "", kwd)
if kwd.find("**ERROR**") >= 0:
return ""
return kwd
@@ -669,6 +671,7 @@ Output: What's the weather in Rochester on {tomorrow}?
###############
"""
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"]


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


Carregando…
Cancelar
Salvar