Skip to content

fix: omit response_format from API request when it is None#546

Open
wudimenghuan wants to merge 1 commit intoHuanshere:mainfrom
wudimenghuan:fix/response-format-null-error
Open

fix: omit response_format from API request when it is None#546
wudimenghuan wants to merge 1 commit intoHuanshere:mainfrom
wudimenghuan:fix/response-format-null-error

Conversation

@wudimenghuan
Copy link
Copy Markdown

Summary

  • When api.llm_support_json is False, response_format was set to None but still included in the API request body as "response_format": null
  • Some OpenAI-compatible API providers try to parse this field and access null.type, causing a 400 error: "Cannot read properties of null (reading 'type')"

Test plan

  • Set api.llm_support_json to false and verify API requests no longer include response_format: null
  • Set api.llm_support_json to true and verify response_format: {"type": "json_object"} is still sent correctly

When api.llm_support_json is False, response_format was set to None
but still included in the request body as "response_format": null.
Some OpenAI-compatible API providers try to parse this field and
access null.type, causing a 400 error:
"Cannot read properties of null (reading 'type')"

Now response_format is only included in params when it is not None.
@wudimenghuan
Copy link
Copy Markdown
Author

#545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant