Skip to content

[Bug] GPT request failed: Error code: 400 - Cannot read properties of null (reading 'type') #545

@lakitu12

Description

@lakitu12

运行环境:

OS: Debian GNU/Linux forky/sid (forky) x86_64
Kernel: Linux 6.19.10+deb14-amd64
CPU: Intel(R) Xeon(R) E5-2680 v4 (28) @ 3.30 GHz
GPU: AMD Radeon RX 590 GME [Discrete]

问题描述:

使用videoLingo调用LM-Studio-0.4.9-1-x64本地运行gemma-4-e4b-it的api服务时出现

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 5/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 6/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 1/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 1/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 2/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 3/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 4/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 5/5 

lm_studio的日志:
2026-04-04 18:37:33 [DEBUG]

Received request: POST to /v1/chat/completions with body  {

"messages": [

{

"role": "user",

"content": "This is a test, response 'message':'success' in json format."

}

],

"model": "gemma-4-e4b-it",

"response_format": null

} 

发现lm_studio不能处理response_format为null的请求。
core/utils/ask_gpt.py中第60行
response_format = {"type": "json_object"} if resp_type == "json" and load_key("api.llm_support_json") else None
不满足条件时response_format就会变成null,导致400错误。

可能的解决办法:

动态构建 params 字典,不满足条件时,不应包含response_format字段。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions