Remove <think> content for Generate if it's not stream output. (#5281)

### What problem does this PR solve?

### Type of change

- [x] Refactoring
This commit is contained in:
Kevin Hu 2025-02-24 13:44:11 +08:00 committed by GitHub
parent 9aa222f738
commit bcc92e04c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -198,6 +198,7 @@ class Generate(ComponentBase):
if len(msg) < 2:
msg.append({"role": "user", "content": "Output: "})
ans = chat_mdl.chat(msg[0]["content"], msg[1:], self._param.gen_conf())
ans = re.sub(r"<think>.*</think>", "", ans, flags=re.DOTALL)
if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
res = self.set_cite(retrieval_res, ans)