Why can't the local Ollama model perceive the toolMessage result and repeats the same output after forcing a tool call? #4425
Unanswered
Lyb-shoujibuyaofangkoudai
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
project
Process
I know that some local models, if not fine-tuned, will fail to automatically invoke custom tools. After my testing, most of these models return results like this:
content='{name: 'tavily_search_results_json', arguments:{query: 'xxxx'}}' additional_kwargs={} response_metadata={} id='run-dda16116-a9b0-43c6-9d6a-ea2bbb978c6f-0',
When I used LangGraph to create a chatbox node, I wrote a method specifically to detect the above result and generate the corresponding AIMessage based on it, forcibly adding the tool_calls attribute so that it would proceed to the tool node and invoke the tool.
Result
Although the tool was successfully invoked, and the corresponding ToolMessage data result from the tool exists in the state, when passing through the chatbox node again, the chatbox node kept repeating the output:
content='{name: 'tavily_search_results_json', arguments:{query: 'xxxx'}}' additional_kwargs={} response_metadata={} id='run-dda16116-a9b0-43c6-9d6a-ea2bbb978c6f-0',
This caused a continuous loop invoking the tool node.
Question
Why is this happening? Is it wrong to write it this way? Are there any solutions? I hope someone can help answer this question or provide a solution. Thank you!
When I used LangGraph to create a chatbox node, I wrote a method specifically to detect the above result and generate the corresponding AIMessage based on it, forcibly adding the tool_calls attribute so that it would proceed to the tool node and invoke the tool.
经过
我知道有些本地模型没有经过微调会导致无法自动调用自定义工具,经过我的测试,大部分这类的模型都会返回这样的结果:
content='{name: 'tavily_search_results_json', arguments:{query: 'xxxx'}}' additional_kwargs={} response_metadata={} id='run-dda16116-a9b0-43c6-9d6a-ea2bbb978c6f-0',
在我使用langgraph创建chatbox节点时,我写了一个方法专门检测上诉结果,会根据这个结果来生成对应的的AIMessage,强制增加tool_calls属性,让其跑到工具节点以此调用工具。
结果
虽然成功的调用了工具,且在state中也存在对应工具获取到的数据结果ToolMesdsage,但是当继续经过chatbox节点时,chatbox节点会一直重复输出 content='{name: 'tavily_search_results_json', arguments:{query: 'xxxx'}}' additional_kwargs={} response_metadata={} id='run-dda16116-a9b0-43c6-9d6a-ea2bbb978c6f-0', 导致一直循环调用工具节点
问题
为什么会这样子?是不能这样子写吗?有什么解决办法吗?希望有大神为解答一下这个问题或提供解决方案,谢谢!
Beta Was this translation helpful? Give feedback.
All reactions