handle multiple function calls in openai #346
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.