|
- package relay
-
- import (
- "testing"
-
- "github.com/QuantumNous/new-api/constant"
- "github.com/QuantumNous/new-api/dto"
- relaycommon "github.com/QuantumNous/new-api/relay/common"
- relayconstant "github.com/QuantumNous/new-api/relay/constant"
- "github.com/stretchr/testify/assert"
- )
-
- func TestShouldUseChatCompletionsViaResponses_CodexAlwaysEnabled(t *testing.T) {
- info := &relaycommon.RelayInfo{
- RelayMode: relayconstant.RelayModeChatCompletions,
- OriginModelName: "gpt-5-codex",
- ChannelMeta: &relaycommon.ChannelMeta{
- ChannelType: constant.ChannelTypeCodex,
- ChannelId: 1,
- ApiType: constant.APITypeCodex,
- },
- }
-
- // Codex should always convert, regardless of pass-through settings
- assert.True(t, shouldUseChatCompletionsViaResponses(info, false))
- assert.True(t, shouldUseChatCompletionsViaResponses(info, true))
- }
-
- func TestShouldUseChatCompletionsViaResponses_NonCodexDisabledByPassThrough(t *testing.T) {
- info := &relaycommon.RelayInfo{
- RelayMode: relayconstant.RelayModeChatCompletions,
- ChannelMeta: &relaycommon.ChannelMeta{
- ChannelType: constant.ChannelTypeOpenAI,
- ChannelId: 1,
- ApiType: constant.APITypeOpenAI,
- ChannelSetting: dto.ChannelSettings{
- PassThroughBodyEnabled: true,
- },
- },
- }
-
- assert.False(t, shouldUseChatCompletionsViaResponses(info, false))
- assert.False(t, shouldUseChatCompletionsViaResponses(info, true))
- }
|