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

handle multiple function calls in openai #346

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeevan057
Copy link

openai can give multiple tool calls
ex : "message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_cuC7cq3IoIqCN2IvwfGuNl8J",
"type": "function",
"function": {
"name": "add_numbers",
"arguments": "{"a": 1, "b": 2}"
}
},
{
"id": "call_SfbHakQINYSeK9a7VzQq50OW",
"type": "function",
"function": {
"name": "add_numbers",
"arguments": "{"a": 3, "b": 4}"
}
}
],
"refusal": null
},

The current implementation assumes only single function call. In this case we get function name as add_numbersadd_numbers (here we have function name twice ). This would fail when the openai is giving multiple tool calls.

The fix I used is create a list of function names and call them.

…nly one function call at a time. Fixed this to handle multiple function calls.
@jeevan057 jeevan057 changed the title handle multiple function calls handle multiple function calls in openai Aug 7, 2024
@aconchillo
Copy link
Contributor

This is awesome. Thank you! @chadbailey59 what do you think?

@cartesis07
Copy link

Great thanks!

@szeka94
Copy link

szeka94 commented Sep 7, 2024

any concerns merging this? I'm running into the same error.

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.

4 participants