When response_format parameter set to ‘json_object’ leading to an infinite stream loop
POST /v1/chat/completions HTTP/1.1
Host: api.openai.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0
Accept: text/event-stream
{
"response_format": {
"type": "json_object"
},
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Tell me a joke"
},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_FZP4cgNT6LmG5TAaBfrFAwzO",
"type": "function",
"function": {
"name": "Joke",
"arguments": "{\n \"about\": \"\"\n}"
}
}
]
},
{
"tool_call_id": "call_FZP4cgNT6LmG5TAaBfrFAwzO",
"role": "tool",
"name": "Joke",
"content": "json: Why should I use this tool?"
}
],
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"model": "gpt-3.5-turbo-1106",
"stream": true
}