dify icon indicating copy to clipboard operation
dify copied to clipboard

When using moonshot, setting the value of response_format to json_object results in a call error.

Open wadezyj opened this issue 1 year ago • 1 comments

Self Checks

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

Dify version

0.10.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using moonshot, setting the value of response_format to json_object results in a call error. The error message is: "[moonshot] Error: API request failed with status code 400: {"error":{"message":"Invalid request: the response_format field in the request (expected type object) is illegal, and string is not acceptable","type":"invalid_request_error"}}"

✔️ Expected Behavior

No error

❌ Actual Behavior

"[moonshot] Error: API request failed with status code 400: {"error":{"message":"Invalid request: the response_format field in the request (expected type object) is illegal, and string is not acceptable","type":"invalid_request_error"}}"

wadezyj avatar Oct 24 '24 09:10 wadezyj

@wadezyj Hello there! I'm here to help you with bugs, questions, and becoming a contributor. Let's solve this together while we wait for a human maintainer.

The error you're encountering is due to the response_format field being set to a value that is not accepted by the Dify system. According to the Dify codebase, the accepted values for the response_format field are:

  • "json_schema": This requires an accompanying json_schema to be defined and correctly formatted.
  • Any other string value, which will be set as the type in the response_format dictionary [1].

The error message indicates that the system expected an object type for response_format, but received a string instead. To resolve this, ensure that the response_format is set to a valid value, such as "json_schema" with a proper JSON schema, or another accepted string value. If "json_object" is not a recognized value, you may need to adjust it to one of the accepted formats.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Oct 24 '24 09:10 dosubot[bot]