-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool Call Improvements #71
Conversation
- add detailed docstrings to chat_openai and chat_anthropic
- set default tool_choice as auto if tools are listed
- replace haiku with sonnet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Thank you for documenting this so thoroughly, and for the added tests. Returning results from tool use is super helpful!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very neat, thanks for adding the rigorous battery of tests!
Changes
1. tool_choice schema
Removed pydantic schema for
tool_choice
. OpenAI and Anthropic have very different inputs for this parameter.auto
{"type": "auto"}
required
{"type": "any"}
{"type": "function", "function": {"name": function_name}}
{"type": "tool", "name": function_name}
We hence simplify things by allowing the input to the chat functions to be simple strings like "auto", "required", "function_name".
convert_tool_choice
function will then map these to the right formats above for the different models. Also iftools
are listed buttool_choice
is not set, we default to "auto".2. Avoid looping with
required
tool_choicePreviously if
tool_choice
was set torequired
, tool chaining would force the model to use a tool in each round. This will continue indefinitely and would not end with a message. We fix this by settingtool_choice
to beauto
after the first tool call.3. tool_outputs in LLMResponse
We output the intermediate tool outputs during tool chaining so that we can inspect the steps the model has taken.
4. New tests
We port the tests for tool calls from defog_utils. However, we retain
get_weather
tests and do away with theweb_search
tests so that we do not require a defog API key. Other tests have also been added to cases where tool_choice isrequired
or a forced function. Anthropic tests now also use sonnet instead of haiku as it's more reliable.