(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 = {
}
你好!该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 = { }