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) {
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 {
......
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