-
Notifications
You must be signed in to change notification settings - Fork 245
Open
Description
如题,前端给出:
"通信失败
抱歉,与AI连接时遇到问题: Failed to fetch"
后端日志有:
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': "'response_format.type' must be 'json_schema' or 'text'"}
gemini的分析:
"这是一个 400 Bad Request 错误,这意味着你的 FastAPI 应用成功连接到了 LM Studio,但是发送的请求内容(payload)中包含了 LM Studio 不支持或格式不正确的参数。
具体来说,LM Studio 告诉你,你在 chat.completions.create 请求中提供的 response_format.type 参数的值是无效的。它只接受 'json_schema' 或 'text'。
问题分析:
你的代码在调用 _client.chat.completions.create 时,payload 字典中包含了一个 response_format 参数,并且其 type 字段的值 LM Studio 不识别。
标准的 OpenAI API 中,如果要强制模型输出 JSON 格式,response_format 应该是 {"type": "json_object"}。LM Studio 的这个错误信息表明它可能还没有完全实现 json_object 类型,或者它期望的是更复杂的 json_schema 定义。"
小白摊手┑( ̄Д  ̄)┍
请开发者修补.
Metadata
Metadata
Assignees
Labels
No labels