chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM, Qwen 与 Llama 等)基于 Langchain 与 ChatGLM 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
29.48k stars 5.17k forks source link

Agent添加新的tools #4309

Open XiaoTongDeng opened 1 week ago

XiaoTongDeng commented 1 week ago

请问如何为Agent添加新的tools,能出具相应的教程吗,如何更改源代码。感谢

glide-the commented 1 week ago

目前pip安装的无法拓展,如果你愿意拓展tools模块,增加AgentTIK的一些工程化能力,请参考redeme中的参与贡献

https://github.com/chatchat-space/Langchain-Chatchat/pull/2427

XiaoTongDeng commented 1 week ago

目前pip安装的无法拓展,如果你愿意拓展tools模块,增加AgentTIK的一些工程化能力,请参考redeme中的参与贡献

2427

我研究了一下源代码。似乎我在tools_factory目录下新增函数工具随后使用@regist_tool注册一下就可以了。然后工具函数的传入参数Field(description="xxxx")是作为描述工具内容的,只需要写好description就可以使用Agent识别到相应的tool了。随后在workspace_config.json添加一下TOOL_CONFIG的字典就ok。我是这么完成的。