fix: simplify responses SSE suffix handling

This commit is contained in:
trph
2026-03-29 22:19:25 +08:00
parent 0fcc02fbea
commit f73d55ddaa
@@ -32,15 +32,13 @@ func writeResponsesSSEChunk(w io.Writer, chunk []byte) {
if bytes.HasSuffix(chunk, []byte("\n\n")) { if bytes.HasSuffix(chunk, []byte("\n\n")) {
return return
} }
suffix := []byte("\n\n")
if bytes.HasSuffix(chunk, []byte("\n")) { if bytes.HasSuffix(chunk, []byte("\n")) {
if _, err := w.Write([]byte("\n")); err != nil { suffix = []byte("\n")
return
} }
} else { if _, err := w.Write(suffix); err != nil {
if _, err := w.Write([]byte("\n\n")); err != nil {
return return
} }
}
} }
// OpenAIResponsesAPIHandler contains the handlers for OpenAIResponses API endpoints. // OpenAIResponsesAPIHandler contains the handlers for OpenAIResponses API endpoints.