seems fine. Tbh looking at the code though, I'm not sure why predicting an index was chosen, predicting a name should be good enough?
You can do this yourself as well, which maybe is better?
tools_by_name = {tool.metadata.name: tool for tool in tools}
# can pass in a user msg or chat history
resp = llm.chat_with_tools(
tools,
user_msg=f"Given this latest message, pick at least one tool to use: {user_msg}",
error_on_no_tool_call=False
)
tool_calls = llm.get_tool_calls_from_response(resp)
for tool_call in tool_calls:
print(tool_call.tool_name)
print(tool_call.tool_kwargs)
tool_result = tools_by_name[tool_call.tool_name](**tool_call.tool_kwargs)
print(tool_result)