Error Parsing JSON Response in ‘gpt-4o-2024-08-06’ Model: Seld\JsonLint\ParsingException

Hello everyone! After changing the model to a new one, ‘gpt-4o-2024-08-06’, my application started to give a lot of errors during the analysis of pictures by prompt and giving an answer about what is depicted there

Please tell me how to fix it?

In particular, the error looks like this:

Log context “root”:{2 items “message”:NULL “error”:{4 items “type”:string"Seld\JsonLint\ParsingException" “code”:int0 “message”:string"Parse error on line 1: ^ Expected one of: ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{’, ‘[’" “details “:{4 items “caller”:string"parseResponse” “file”:string”/home/dai3e3voeroc/attributor/vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php" “line”:string"407" “context”:{5 items “object”:string"StockItem" “object_id”:int37624 “user_id”:int50 “event”:string"openai.client.response.parse" “data”:{1 item “message”:NULL } } } } }

1 Like

Welcome to the dev forum!

I’ve moved your post to a new thread.

Is the error consistent? Easy to reproduce?

The models are trained different, so it’s usually good to test before the default branch switches to a new model.

1 Like

Same symptom, same application of receiving JSON, same source model.

I’m inclined to say OpenAI broke something in the brains.

2 Likes

Thanks, @_j . Your help around here is very much appreciated.

I agree that sometimes things break when these new models are rolled out. People reporting the problems helps get eyes on them…

Thanks again for your valuable contributions to our community garden!

2 Likes

Facing same issue. It was alright till 26/11/2024 till 12pm. The application has gone to UAT testing and now giving the error. Tried increasing the max_tokens, although it was generating only 952 tokens, still the same error. Tried in OpenAI studio with same parameters, and it is generating incomplete JSON even there.

1 Like

I thought this was resolved, have you updated your openai library in your UAT setup?

Also, can you give an example of the incomplete output from the playground, please.

1 Like

I have upgraded openai package to v1.55.1. I am still facing the same issue.
This is a rag chatbot that we have implemented, wherein we are making calls to gpt-4o (East US). It has to return a JSON output. I have mentioned multiple times in the prompt asking it to provide JSON output strictly. I have also mentioned the below JSON schema in the prompt

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "strict": true,
  "properties": {
    "query_type": {
      "type": "string"
    },
    "response": {
      "type": "string"
    },
    "reference_1": {
      "type": "object",
      "properties": {
        "document_name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "page": {
          "type": "string"
        }
      },
      "required": ["document_name", "url", "page"]
    },
    "reference_2": {
      "type": "object",
      "properties": {
        "document_name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "page": {
          "type": "string"
        }
      },
      "required": ["document_name", "url", "page"]
    }
  },
  "required": ["query_type", "response", "reference_1", "reference_2"]
}

I have mentioned the response format in the config file

response_format": { “type”: “json_object” }

As I said, it was working well all these days.

This is the content generated by playground. Although I cannot provide the full content since it is client confidential. But this is the structure

{
“query_type”: “NON_LIST”,
“response”: “The content is in Vietnamese”,
“reference_1”: {
“document_name”: “13.%___.pdf”,
“url”: “https…pdf”,
“page”: “6”
},
“reference_2”: {
“document_name”: "… (The JSON is breaking here without the ending curly braces)

EDIT 1:

Hi,

Latest update. Found that the issue is happening because of Gpt-4o throwing random content filters.

{
“query_type”: “NON_LIST”,
“response”: "**Quy định … đủ phép tháng đó (

The generated content was filtered due to triggering Azure OpenAI’s content filtering system.

Reason: This response contains content flagged as Sexual (medium)

Please modify your prompt and retry. [Learn more]

This is happening for all questions. There is no sexual content in the response. It is filtering content at random, because the above question I asked is about ‘Annual Leave Regulations’. It is working as of now if I modify the threshold for content filtering as high. But there is no violence, hate, sexual or any content deemed inappropriate.