api_type.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 := -1
  25. switch channelType {
  26. case common.ChannelTypeOpenAI:
  27. apiType = APITypeOpenAI
  28. case common.ChannelTypeAzure:
  29. apiType = APITypeOpenAI
  30. case common.ChannelTypeMoonshot:
  31. apiType = APITypeOpenAI
  32. case common.ChannelTypeLingYiWanWu:
  33. apiType = APITypeOpenAI
  34. case common.ChannelType360:
  35. apiType = APITypeOpenAI
  36. case common.ChannelTypeAnthropic:
  37. apiType = APITypeAnthropic
  38. case common.ChannelTypeBaidu:
  39. apiType = APITypeBaidu
  40. case common.ChannelTypePaLM:
  41. apiType = APITypePaLM
  42. case common.ChannelTypeZhipu:
  43. apiType = APITypeZhipu
  44. case common.ChannelTypeAli:
  45. apiType = APITypeAli
  46. case common.ChannelTypeXunfei:
  47. apiType = APITypeXunfei
  48. case common.ChannelTypeAIProxyLibrary:
  49. apiType = APITypeAIProxyLibrary
  50. case common.ChannelTypeTencent:
  51. apiType = APITypeTencent
  52. case common.ChannelTypeGemini:
  53. apiType = APITypeGemini
  54. case common.ChannelTypeZhipu_v4:
  55. apiType = APITypeZhipu_v4
  56. case common.ChannelTypeOllama:
  57. apiType = APITypeOllama
  58. case common.ChannelTypePerplexity:
  59. apiType = APITypePerplexity
  60. case common.ChannelTypeAws:
  61. apiType = APITypeAws
  62. case common.ChannelTypeCohere:
  63. apiType = APITypeCohere
  64. }
  65. return apiType
  66. }