Files
new-api/relay/chat_completions_via_responses_test.go
T
Calcium-Ion 2d5a041639 feat: support Responses to Chat (#5787)
* fix(openai): harden Chat-to-Responses compatibility

Add a shared Responses-to-Chat stream state machine and use it from the OpenAI relay path. Preserve assistant text alongside tool calls, bind tool argument deltas by output_index, map incomplete finish reasons, support reasoning/custom tool events, and buffer upstream SSE for non-stream Chat clients.

Add deterministic service tests and relay SSE tests for the conversion path.

Related to #5745.

* refactor: rename openaicompat to relayconvert for improved clarity

* feat(gemini): support responses request conversion

* feat: add responses to chat conversion support

* fix: harden responses chat conversion edge cases
2026-06-28 14:25:47 +08:00

27 lines
657 B
Go

package relay
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsResponsesEventStreamContentType(t *testing.T) {
tests := []struct {
name string
contentType string
want bool
}{
{name: "plain", contentType: "text/event-stream", want: true},
{name: "mixed case with charset", contentType: "Text/Event-Stream; charset=utf-8", want: true},
{name: "json", contentType: "application/json", want: false},
{name: "empty", contentType: "", want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, isResponsesEventStreamContentType(tt.contentType))
})
}
}