api_type.go 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package constant
  2. import (
  3. "one-api/common"
  4. )
  5. const (
  6. APITypeOpenAI = iota
  7. APITypeAnthropic
  8. APITypePaLM
  9. APITypeBaidu
  10. APITypeZhipu
  11. APITypeAli
  12. APITypeXunfei
  13. APITypeAIProxyLibrary
  14. APITypeTencent
  15. APITypeGemini
  16. APITypeDummy // this one is only for count, do not add any channel after this
  17. )
  18. func ChannelType2APIType(channelType int) int {
  19. apiType := APITypeOpenAI
  20. switch channelType {
  21. case common.ChannelTypeAnthropic:
  22. apiType = APITypeAnthropic
  23. case common.ChannelTypeBaidu:
  24. apiType = APITypeBaidu
  25. case common.ChannelTypePaLM:
  26. apiType = APITypePaLM
  27. case common.ChannelTypeZhipu:
  28. apiType = APITypeZhipu
  29. case common.ChannelTypeAli:
  30. apiType = APITypeAli
  31. case common.ChannelTypeXunfei:
  32. apiType = APITypeXunfei
  33. case common.ChannelTypeAIProxyLibrary:
  34. apiType = APITypeAIProxyLibrary
  35. case common.ChannelTypeTencent:
  36. apiType = APITypeTencent
  37. case common.ChannelTypeGemini:
  38. apiType = APITypeGemini
  39. }
  40. return apiType
  41. }