Inconsistency on how to do function calling, I want to get the basics right, and all the examples seems left the basics on purpose.
OK, here it goes:
When doing tool calls, after I get a response indicate I have to do two tool_calls, and I call the tools, got the result, then what?
Append the result messages to the conversation and try again!
But should I append the tool_call information from the response? Who knows, OPENAI didn’t say.
And if I look into the examples, it’s even worse:
in this example: [How to call functions with chat models | OpenAI Cookbook] It said:
# Append the message to messages list
response_message = response.choices[0].message
messages.append(response_message)
en,…, OK, simply copy the message from response to the request, that’s fine.
But in this cookbook:
[Structured Outputs for Multi-Agent Systems | OpenAI Cookbook]
It said:
conversation_messages.append([tool_call.function for tool_call in response.choices[0].message.tool_calls])
Holy call, tool_call.function is two levels down from the response.message, more importantly, it’s not even a valid message, there’s no “Role” on tool_call.function!
Now exactly what should I do? follow the new example? I certainly need to rework my code to be able to include tool_call.function in the messages.
Or is it a bug in the example? Can the code in the examples actually run? Or you guys think it’s just a explanation, not actual code?