Skip to content
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 calling support. Part I #102

Merged
merged 12 commits into from
Jan 24, 2025
Merged

Tool calling support. Part I #102

merged 12 commits into from
Jan 24, 2025

Conversation

rohitprasad15
Copy link
Collaborator

Add tool calling support for below providers -
OpenAI, Groq, Anthropic, AWS, & Mistral.
OpenAI compatible SDKs need to changes for
tool calling support.

Adding utility ToolManager for users to easily
supply tools, and parse model's request for
tool usage.

Copy link
Collaborator

@ksolo ksolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @rohitprasad15

Nothing blocking, just a few suggestions in the review.

Comment on lines +43 to +47
if isinstance(msg, dict):
return self._convert_dict_message(msg)
return self._convert_message_object(msg)
Copy link
Collaborator

@ksolo ksolo Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like both _convert_dict_message and _convert_message_object logically do the same things. Would it be better to convert to one format and keep one of the convert message methods.

if isinstance(msg, dict):
    msg = Message(msg)
return self._convert_message_object(msg)

or the other way

if isinstance(msg, Message):
    msg = dict(msg)
return self._convert_dict_message(msg)

Comment on lines +85 to +105
tool_input = (
tool_call["function"]["arguments"]
if isinstance(tool_call, dict)
else tool_call.function.arguments
)
message_content.append(
{
"type": "tool_use",
"id": (
tool_call["id"] if isinstance(tool_call, dict) else tool_call.id
),
"name": (
tool_call["function"]["name"]
if isinstance(tool_call, dict)
else tool_call.function.name
),
"input": json.loads(tool_input),
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar thought, converting to either an object or dict at the beginning of this would create a consistency that would not require the if/else statements throughout the function call.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests for this?

Copy link

@mmtmn mmtmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outside of unit tests, lgtm

@amaarora
Copy link

@rohitprasad15 When can we expect tool calling in aisuite? Is there a timeline?

@rohitprasad15
Copy link
Collaborator Author

@ksolo - PTAL again. Added support for a bunch of other providers, and added test cases.
I will take care of the Lint and other failures before merging. Thanks!

Add tool calling support for below providers -
OpenAI, Groq, Anthropic, AWS, & Mistral.
OpenAI compatible SDKs need to changes for
tool calling support.

Adding utility ToolManager for users to easily
supply tools, and parse model's request for
tool usage.
@rohitprasad15 rohitprasad15 merged commit bd6b23f into main Jan 24, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants