From 05997e82156c17d7ce6d35102ae991f536be63b0 Mon Sep 17 00:00:00 2001 From: Graf2242 Date: Tue, 25 Mar 2025 05:22:41 +0300 Subject: [PATCH] Remove thinking block from keyword node's result (#6474) ### What problem does this PR solve? For now, if you use thinking model (deepseek-r1:32b with ollama server in my case) in "Keyword" node, result contains all block and so node return not only keywords ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): --- agent/component/keyword.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agent/component/keyword.py b/agent/component/keyword.py index 3b71441c0..1e7cbacde 100644 --- a/agent/component/keyword.py +++ b/agent/component/keyword.py @@ -57,9 +57,10 @@ class KeywordExtract(Generate, ABC): ans = chat_mdl.chat(self._param.get_prompt(), [{"role": "user", "content": query}], self._param.gen_conf()) + ans = re.sub(r".*", "", ans, flags=re.DOTALL) ans = re.sub(r".*keyword:", "", ans).strip() logging.debug(f"ans: {ans}") return KeywordExtract.be_output(ans) def debug(self, **kwargs): - return self._run([], **kwargs) \ No newline at end of file + return self._run([], **kwargs)