<think> tag is missing. (#7256)

### What problem does this PR solve?

Some models force thinking, resulting in the absence of the think tag in
the returned content

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
WhiteBear
2025-04-24 11:44:10 +08:00
committed by GitHub
parent 4e8fd73a20
commit 2c62652ea8
8 changed files with 13 additions and 13 deletions

View File

@ -54,7 +54,7 @@ class Extractor:
return response
_, system_msg = message_fit_in([{"role": "system", "content": system}], int(self._llm.max_length * 0.92))
response = self._llm.chat(system_msg[0]["content"], hist, conf)
response = re.sub(r"<think>.*</think>", "", response, flags=re.DOTALL)
response = re.sub(r"^.*</think>", "", response, flags=re.DOTALL)
if response.find("**ERROR**") >= 0:
logging.warning(f"Extractor._chat got error. response: {response}")
return ""