浏览代码

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 <think> 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):
tags/v0.18.0
Graf2242 7 个月前
父节点
当前提交
05997e8215
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2
    1
      agent/component/keyword.py

+ 2
- 1
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"<think>.*</think>", "", 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)
return self._run([], **kwargs)

正在加载...
取消
保存