From 312e762aff340e1c62471aa5506874e55e5aabe6 Mon Sep 17 00:00:00 2001 From: cfy666 <3087823110@qq.com> Date: Sun, 14 Jun 2026 13:02:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=97=B6=20LLM=20API=20=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 contentPart.Text 的 omitempty 标签 - 确保 text 字段始终存在于 JSON 请求中 --- backend/internal/ai/llm/openai.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/internal/ai/llm/openai.go b/backend/internal/ai/llm/openai.go index 754176c..e421d7e 100644 --- a/backend/internal/ai/llm/openai.go +++ b/backend/internal/ai/llm/openai.go @@ -61,7 +61,7 @@ type chatMessage struct { type contentPart struct { Type string `json:"type"` - Text string `json:"text,omitempty"` + Text string `json:"text"` ImageURL *imageURL `json:"image_url,omitempty"` } @@ -100,6 +100,9 @@ func (o *OpenAIService) ChatStream(ctx context.Context, req Request) (<-chan Chu if err != nil { return nil, fmt.Errorf("llm: marshal request: %w", err) } + if err != nil { + return nil, fmt.Errorf("llm: marshal request: %w", err) + } // 创建带超时的 context ctx, cancel := context.WithTimeout(ctx, o.timeout)