You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
1.4 KiB

  1. package relay
  2. import (
  3. "testing"
  4. "github.com/QuantumNous/new-api/constant"
  5. "github.com/QuantumNous/new-api/dto"
  6. relaycommon "github.com/QuantumNous/new-api/relay/common"
  7. relayconstant "github.com/QuantumNous/new-api/relay/constant"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestShouldUseChatCompletionsViaResponses_CodexAlwaysEnabled(t *testing.T) {
  11. info := &relaycommon.RelayInfo{
  12. RelayMode: relayconstant.RelayModeChatCompletions,
  13. OriginModelName: "gpt-5-codex",
  14. ChannelMeta: &relaycommon.ChannelMeta{
  15. ChannelType: constant.ChannelTypeCodex,
  16. ChannelId: 1,
  17. ApiType: constant.APITypeCodex,
  18. },
  19. }
  20. // Codex should always convert, regardless of pass-through settings
  21. assert.True(t, shouldUseChatCompletionsViaResponses(info, false))
  22. assert.True(t, shouldUseChatCompletionsViaResponses(info, true))
  23. }
  24. func TestShouldUseChatCompletionsViaResponses_NonCodexDisabledByPassThrough(t *testing.T) {
  25. info := &relaycommon.RelayInfo{
  26. RelayMode: relayconstant.RelayModeChatCompletions,
  27. ChannelMeta: &relaycommon.ChannelMeta{
  28. ChannelType: constant.ChannelTypeOpenAI,
  29. ChannelId: 1,
  30. ApiType: constant.APITypeOpenAI,
  31. ChannelSetting: dto.ChannelSettings{
  32. PassThroughBodyEnabled: true,
  33. },
  34. },
  35. }
  36. assert.False(t, shouldUseChatCompletionsViaResponses(info, false))
  37. assert.False(t, shouldUseChatCompletionsViaResponses(info, true))
  38. }