Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structured outputs not working for 4o-mini #14475

Open
5 tasks done
sugoh opened this issue Feb 27, 2025 · 8 comments
Open
5 tasks done

structured outputs not working for 4o-mini #14475

sugoh opened this issue Feb 27, 2025 · 8 comments
Labels
🐞 bug Something isn't working cloud When the version is cloud and it is a bug report good first issue Good first issue for newcomers

Comments

@sugoh
Copy link

sugoh commented Feb 27, 2025

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.0.0

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Create an LLM block
  2. Set model to 4o-mini
  3. Set Response Format to json_object
  4. Fill out JSON Schema field
  5. Toggle on both Response Format and JSON Schema
  6. Run

Note: It doesn't matter if you select json_object or json_schema, the error will be the same.

✔️ Expected Behavior

a JSON structured output.

❌ Actual Behavior

Run failed: [openai] Error: PluginInvokeError: {"args":{"description":"[models] Error: Completions.create() got an unexpected keyword argument 'json_schema'"},"error_type":"InvokeError","message":"[models] Error: Completions.create() got an unexpected keyword argument 'json_schema'"}
Copy link

dosubot bot commented Feb 27, 2025

The issue you're encountering with the 4o-mini model is due to its lack of support for JSON Schema functionality. According to the documentation, only gpt-4o-mini-2024-07-18 and later versions, as well as gpt-4o-2024-08-06 and later versions, support JSON Schema. The 4o-mini model likely predates these versions and does not recognize the json_schema argument, resulting in the PluginInvokeError you're seeing [1].

A similar closed issue suggested setting the response_format to json_schema instead of json_object as a solution, but this may not apply to your case if the model itself does not support JSON Schema [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added the 🐞 bug Something isn't working label Feb 27, 2025
@Nothing1024
Copy link

Nothing1024 commented Feb 27, 2025

same as you.
the old version doesn't show the error, but it doesn't have the json_schema-style output, just streaming text.
I thought something maybe happen in OPENAI.
Now, half of my projects can't work, I am trying to change the claude ;;

--update--

I try to request by curl with the json_schema method, and get the response of normal format.

"choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": ""
      },
      "finish_reason": "stop"
    }
  ],

--update--

I try the python demo from Structured Outputs Offical and get the right format. I can't locate the error rigth now.

@crazywoola crazywoola added the cloud When the version is cloud and it is a bug report label Feb 27, 2025
@OrWestSide
Copy link

Same issue here.

@elliottsharp
Copy link

experiencing the same issue

@alitayin
Copy link

Same here. it works for the past months until today.

@yamaneko1212
Copy link

I got the similar issue using GPT-4o-2024-11-20.

@crazywoola crazywoola added the good first issue Good first issue for newcomers label Feb 28, 2025
@crazywoola
Copy link
Member

For anyone who is interested working on this, please submit a pull request to https://github.com/langgenius/dify-official-plugins.

@yamaneko1212
Copy link

yamaneko1212 commented Feb 28, 2025

I got an answer from dify support team via mail.
In my case, upgrading OpenAI plugin and reconfigure settings solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working cloud When the version is cloud and it is a bug report good first issue Good first issue for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants