Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

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

Kevin Hubcc92e04c9c7
diff --git a/agent/component/generate.py b/agent/component/generate.py
index 3b05747e1f..ea12f9040d 100644
--- a/agent/component/generate.py
+++ b/agent/component/generate.py
@@ -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)