@@ -43,29 +43,36 @@ def __init__(
4343 json_response_format : bool = False ,
4444 custom_agent_config : Optional [AgentConfig ] = None ,
4545 ):
46- def get_tool_definition (tool ):
47- return {
48- "name" : tool .identifier ,
49- "description" : tool .description ,
50- "parameters" : tool .parameters ,
51- }
52-
53- if custom_agent_config is None :
54- tool_names = ""
55- tool_descriptions = ""
46+ def get_tool_defs ():
47+ tool_defs = []
5648 for x in builtin_toolgroups :
57- tool_names += ", " .join ([tool .identifier for tool in client .tools .list (toolgroup_id = x )])
58- tool_descriptions += "\n " .join (
59- [f"- { tool .identifier } : { get_tool_definition (tool )} " for tool in client .tools .list (toolgroup_id = x )]
49+ tool_defs .extend (
50+ [
51+ {
52+ "name" : tool .identifier ,
53+ "description" : tool .description ,
54+ "parameters" : tool .parameters ,
55+ }
56+ for tool in client .tools .list (toolgroup_id = x )
57+ ]
6058 )
61-
62- tool_names += ", "
63- tool_descriptions += "\n "
64- tool_names += ", " .join ([tool .get_name () for tool in client_tools ])
65- tool_descriptions += "\n " .join (
66- [f"- { tool .get_name ()} : { tool .get_tool_definition ()} " for tool in client_tools ]
59+ tool_defs .extend (
60+ [
61+ {
62+ "name" : tool .get_name (),
63+ "description" : tool .get_description (),
64+ "parameters" : tool .get_params_definition (),
65+ }
66+ for tool in client_tools
67+ ]
6768 )
69+ return tool_defs
6870
71+ if custom_agent_config is None :
72+ tool_names , tool_descriptions = "" , ""
73+ tool_defs = get_tool_defs ()
74+ tool_names = ", " .join ([x ["name" ] for x in tool_defs ])
75+ tool_descriptions = "\n " .join ([f"- { x ['name' ]} : { x } " for x in tool_defs ])
6976 instruction = DEFAULT_REACT_AGENT_SYSTEM_PROMPT_TEMPLATE .replace ("<<tool_names>>" , tool_names ).replace (
7077 "<<tool_descriptions>>" , tool_descriptions
7178 )
0 commit comments