fix: 修复文本输入时 LLM API 报错的问题

- 移除 contentPart.Text 的 omitempty 标签
- 确保 text 字段始终存在于 JSON 请求中
This commit is contained in:
2026-06-14 13:02:07 +08:00
parent 41cacaa740
commit 312e762aff

View File

@@ -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)