fix: when reasoningEffort = "", no "reasoning" field

This commit is contained in:
xkm
2026-03-21 16:16:05 +08:00
parent aa06c480e8
commit eb8f4a273c
2 changed files with 10 additions and 7 deletions

View File

@@ -14,16 +14,16 @@ type OpenaiChatCompletionReq struct {
}
type OpenaiResponseReasoning struct {
Effort string `json:"effort"`
Effort string `json:"effort,omitempty"`
Summary string `json:"summary,omitempty"` // auto, concise, detailed
}
type OpenaiChatResponseReq struct {
Model string `json:"model"`
Input []OpenaiChatMessage `json:"input"`
Temperature *float64 `json:"temperature,omitempty"`
Reasoning OpenaiResponseReasoning `json:"reasoning,omitempty"`
Stream bool `json:"stream"`
Model string `json:"model"`
Input []OpenaiChatMessage `json:"input"`
Temperature *float64 `json:"temperature,omitempty"`
Reasoning *OpenaiResponseReasoning `json:"reasoning,omitempty"`
Stream bool `json:"stream"`
}
type OpenaiResponseStreamEvent struct {

View File

@@ -32,10 +32,13 @@ func OpenaiStreamChatResponses(
Model: model,
Input: msgs,
Temperature: temperature,
Reasoning: OpenaiResponseReasoning{Effort: reasoningEffort},
Stream: true,
}
if reasoningEffort != "" {
body.Reasoning = &OpenaiResponseReasoning{Effort: reasoningEffort}
}
payload, err := json.Marshal(body)
if err != nil {
return nil, err