mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-25 00:05:58 +08:00
- 修复:
- Qwen Agent 的 OutputParser 不再抛出异常,遇到非 COT 文本直接返回
- CallbackHandler 正确处理工具调用信息
- 重写 tool 定义方式:
- 添加 regist_tool 简化 tool 定义:
- 可以指定一个用户友好的名称
- 自动将函数的 __doc__ 作为 tool.description
- 支持用 Field 定义参数,不再需要额外定义 ModelSchema
- 添加 BaseToolOutput 封装 tool 返回结果,以便同时获取原始值、给LLM的字符串值
- 支持工具热加载(有待测试)
- 增加 openai 兼容的统一 chat 接口,通过 tools/tool_choice/extra_body 不同参数组合支持:
- Agent 对话
- 指定工具调用(如知识库RAG)
- LLM 对话
- 根据后端功能更新 webui
13 lines
412 B
Python
13 lines
412 B
Python
# LangChain 的 Shell 工具
|
|
from langchain.tools.shell import ShellTool
|
|
|
|
from chatchat.server.pydantic_v1 import Field
|
|
from .tools_registry import regist_tool, BaseToolOutput
|
|
|
|
|
|
@regist_tool(title="系统命令")
|
|
def shell(query: str = Field(description="The command to execute")):
|
|
'''Use Shell to execute system shell commands'''
|
|
tool = ShellTool()
|
|
return BaseToolOutput(tool.run(tool_input=query))
|