api_type.go 1.2 KB

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