Response from Tools "call.Function.Arguments" is not consistently valid JSON

When creating a chat completion request to gpt-3.5-turbo-0613, the response in the string call.Function.Arguments isn’t always valid JSON. Specifically, sometimes there’s a training comma at the end of JSON arrays.

For example, when returning an array of strings sometimes it gives:

 "watch-out-for-items": [
    "Monitor your blood pressure regularly and report any significant changes to your doctor.",
    "Keep an eye out for signs of infection, such as increased pain, redness, warmth, or discharge at the surgical site.",
    "If you experience persistent or worsening pain, inform your healthcare team.",
    "Monitor your exercise tolerance and gradually increase the intensity or duration of your workouts as advised by your physical therapist.",

Where the training comma in therapist.", is invalid JSON and breaks the standard golang JSON parser.

The response is intermittent. Sometimes the extra comma is present, other times it is not.


Same here,

This is a JSON from response.choices[0].message.tool_calls[0].function.arguments

"sinonimos": ["Associação Brasileira das Indústrias de Alimentação"],

Note the trailing comma (JSON doesn’t support comma in the last item)

Update: As a workaround I’m using this in Python:


Yes, still an issue. I wish there would be some validation server side.