THUDM / ChatGLM3

ChatGLM3 series: Open Bilingual Chat LLMs | 开源双语对话语言模型
Apache License 2.0
13.31k stars 1.55k forks source link

agent-chat-openai工具调度算法更新完善 #1201

Closed lilongxian closed 4 months ago

lilongxian commented 4 months ago

你好!该pr修改的内容为:

完善agent-chat-openai项目中工具调用时候的工具参数抽象化,之前的参数误写了,抽象化目的在于底层算法的完备性。具体内容如下,谢谢查阅:

(1)openai_api_demo.api_server.py 275--287行: if tool: this_tool_define_param_name = tool_define_param_name.get(function_call.name) if this_tool_define_param_name: tool_param = json.loads(function_call.arguments).get(this_tool_define_param_name) if tool().parameter_validation(tool_param): observation = str(tool().run(tool_param)) tool_response = observation else: tool_response = "Tool parameter values error, please tell the user about this situation." else: tool_response = "Tool parameter is not defined in tools schema, please tell the user about this situation." else: tool_response = "No available tools found, please tell the user about this situation."

(2)在tools.schema.py中 增加用户工具参数适配器并在api_server.py中被import: """ Describes the tool parameter name defined in the system prompt. E.g: tool_define_param_name = { 'Calculator': "symbol", ... } """ tool_define_param_name = { }