fix(openai): preserve image outputs when text content serialization fails

In reconstructResponseOutputFromSSE, text content Marshal/Unmarshal
failure previously caused an early return that silently discarded
already-extracted image_generation_call outputs. Now serialization
errors are tolerated so image results still reach the client.
This commit is contained in:
shaw
2026-04-24 08:58:51 +08:00
parent ff08f9d798
commit ca204ddd2f

View File

@@ -4167,14 +4167,14 @@ func reconstructResponseOutputFromSSE(bodyText string) ([]byte, bool) {
var output []json.RawMessage
if acc.HasContent() {
outputJSON, err := json.Marshal(acc.BuildOutput())
if err != nil {
return nil, false
}
if err := json.Unmarshal(outputJSON, &output); err != nil {
return nil, false
if err == nil {
_ = json.Unmarshal(outputJSON, &output)
}
}
output = append(output, imageOutputs...)
if len(output) == 0 {
return nil, false
}
outputJSON, err := json.Marshal(output)
if err != nil {