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