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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user