api_type.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. APITypeZhipu_v4
  17. APITypeOllama
  18. APITypePerplexity
  19. APITypeAws
  20. APITypeCohere
  21. APITypeDummy // this one is only for count, do not add any channel after this
  22. )
  23. func ChannelType2APIType(channelType int) int {
  24. apiType := APITypeOpenAI
  25. switch channelType {
  26. case common.ChannelTypeAnthropic:
  27. apiType = APITypeAnthropic
  28. case common.ChannelTypeBaidu:
  29. apiType = APITypeBaidu
  30. case common.ChannelTypePaLM:
  31. apiType = APITypePaLM
  32. case common.ChannelTypeZhipu:
  33. apiType = APITypeZhipu
  34. case common.ChannelTypeAli:
  35. apiType = APITypeAli
  36. case common.ChannelTypeXunfei:
  37. apiType = APITypeXunfei
  38. case common.ChannelTypeAIProxyLibrary:
  39. apiType = APITypeAIProxyLibrary
  40. case common.ChannelTypeTencent:
  41. apiType = APITypeTencent
  42. case common.ChannelTypeGemini:
  43. apiType = APITypeGemini
  44. case common.ChannelTypeZhipu_v4:
  45. apiType = APITypeZhipu_v4
  46. case common.ChannelTypeOllama:
  47. apiType = APITypeOllama
  48. case common.ChannelTypePerplexity:
  49. apiType = APITypePerplexity
  50. case common.ChannelTypeAws:
  51. apiType = APITypeAws
  52. case common.ChannelTypeCohere:
  53. apiType = APITypeCohere
  54. }
  55. return apiType
  56. }