Просмотр исходного кода

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 месяцев назад
Родитель
Сommit
05997e8215
Аккаунт пользователя с таким Email не найден
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)

Загрузка…
Отмена
Сохранить