Commit ca204ddd authored by shaw's avatar shaw
Browse files

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.
parent ff08f9d7
...@@ -4167,14 +4167,14 @@ func reconstructResponseOutputFromSSE(bodyText string) ([]byte, bool) { ...@@ -4167,14 +4167,14 @@ func reconstructResponseOutputFromSSE(bodyText string) ([]byte, bool) {
var output []json.RawMessage var output []json.RawMessage
if acc.HasContent() { if acc.HasContent() {
outputJSON, err := json.Marshal(acc.BuildOutput()) outputJSON, err := json.Marshal(acc.BuildOutput())
if err != nil { if err == nil {
return nil, false _ = json.Unmarshal(outputJSON, &output)
}
if err := json.Unmarshal(outputJSON, &output); err != nil {
return nil, false
} }
} }
output = append(output, imageOutputs...) output = append(output, imageOutputs...)
if len(output) == 0 {
return nil, false
}
outputJSON, err := json.Marshal(output) outputJSON, err := json.Marshal(output)
if err != nil { if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment