chrysb
January 31, 2024, 7:44am
1
As far as I understand, in order to send a follow-up message from GPT after running a function call, you need to pass an object like this:
messages.push({
tool_call_id: toolCall.id,
role: "tool",
name: functionName,
content: functionResponse,
});
The issue is, when streaming, I don’t see an id call_...
in the streaming response:
{
id: 'chatcmpl-8mzIGYpyMzCMxE1KDv3Kt9IcfaSzX',
object: 'chat.completion.chunk',
created: 1706686048,
model: 'gpt-3.5-turbo-1106',
system_fingerprint: 'fp_b57c83dd65',
choices: [
{
index: 0,
delta: { tool_calls: [ { index: 0, function: { arguments: ' my' } } ] },
logprobs: null,
finish_reason: null
}]
}
Is this a known issue? Or am I missing something about how to get the tool_call_id
?
alanc
February 14, 2024, 10:25pm
2
It’s been a little while, but if you haven’t figured it out, I found that in the first chunk that comes back, the structure includes a tool call ID.
{
"id": "chatcmpl-8ruxmT0SbZYoS6jQmDzyJzyp0K4n0",
"object": "chat.completion.chunk",
"created": 1707861042,
"model": "gpt-3.5-turbo-0613",
"system_fingerprint": null,
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"index": 0,
"id": "call_KxcsHbt88vrVefLY6j01Ezci",
"type": "function",
"function": {
"name": "some_function",
"arguments": ""
}
}
]
},
"logprobs": null,
"finish_reason": null
}
]
}
2 Likes
_j
February 14, 2024, 11:46pm
3
It also is strategic, in that you can use the initial delta to stop playing the stream and instead throw up a progress report to indicate what is happening, to enhance user experience.
1 Like
chrysb
February 24, 2024, 4:29am
4
Glad I checked back in, this works! Thank you