relay-minimax.go 905 B

123456789101112131415161718192021222324252627282930
  1. package minimax
  2. import (
  3. "fmt"
  4. channelconstant "github.com/QuantumNous/new-api/constant"
  5. relaycommon "github.com/QuantumNous/new-api/relay/common"
  6. "github.com/QuantumNous/new-api/relay/constant"
  7. "github.com/QuantumNous/new-api/types"
  8. )
  9. func GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
  10. baseUrl := info.ChannelBaseUrl
  11. if baseUrl == "" {
  12. baseUrl = channelconstant.ChannelBaseURLs[channelconstant.ChannelTypeMiniMax]
  13. }
  14. switch info.RelayFormat {
  15. case types.RelayFormatClaude:
  16. return fmt.Sprintf("%s/anthropic/v1/messages", info.ChannelBaseUrl), nil
  17. default:
  18. switch info.RelayMode {
  19. case constant.RelayModeChatCompletions:
  20. return fmt.Sprintf("%s/v1/text/chatcompletion_v2", baseUrl), nil
  21. case constant.RelayModeAudioSpeech:
  22. return fmt.Sprintf("%s/v1/t2a_v2", baseUrl), nil
  23. default:
  24. return "", fmt.Errorf("unsupported relay mode: %d", info.RelayMode)
  25. }
  26. }
  27. }