api_type.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. APITypeZhipuV4
  17. APITypeOllama
  18. APITypePerplexity
  19. APITypeAws
  20. APITypeCohere
  21. APITypeDify
  22. APITypeJina
  23. APITypeCloudflare
  24. APITypeSiliconFlow
  25. APITypeVertexAi
  26. APITypeMistral
  27. APITypeDeepSeek
  28. APITypeMokaAI
  29. APITypeVolcEngine
  30. APITypeBaiduV2
  31. APITypeOpenRouter
  32. APITypeXinference
  33. APITypeDummy // this one is only for count, do not add any channel after this
  34. )
  35. func ChannelType2APIType(channelType int) (int, bool) {
  36. apiType := -1
  37. switch channelType {
  38. case common.ChannelTypeOpenAI:
  39. apiType = APITypeOpenAI
  40. case common.ChannelTypeAnthropic:
  41. apiType = APITypeAnthropic
  42. case common.ChannelTypeBaidu:
  43. apiType = APITypeBaidu
  44. case common.ChannelTypePaLM:
  45. apiType = APITypePaLM
  46. case common.ChannelTypeZhipu:
  47. apiType = APITypeZhipu
  48. case common.ChannelTypeAli:
  49. apiType = APITypeAli
  50. case common.ChannelTypeXunfei:
  51. apiType = APITypeXunfei
  52. case common.ChannelTypeAIProxyLibrary:
  53. apiType = APITypeAIProxyLibrary
  54. case common.ChannelTypeTencent:
  55. apiType = APITypeTencent
  56. case common.ChannelTypeGemini:
  57. apiType = APITypeGemini
  58. case common.ChannelTypeZhipu_v4:
  59. apiType = APITypeZhipuV4
  60. case common.ChannelTypeOllama:
  61. apiType = APITypeOllama
  62. case common.ChannelTypePerplexity:
  63. apiType = APITypePerplexity
  64. case common.ChannelTypeAws:
  65. apiType = APITypeAws
  66. case common.ChannelTypeCohere:
  67. apiType = APITypeCohere
  68. case common.ChannelTypeDify:
  69. apiType = APITypeDify
  70. case common.ChannelTypeJina:
  71. apiType = APITypeJina
  72. case common.ChannelCloudflare:
  73. apiType = APITypeCloudflare
  74. case common.ChannelTypeSiliconFlow:
  75. apiType = APITypeSiliconFlow
  76. case common.ChannelTypeVertexAi:
  77. apiType = APITypeVertexAi
  78. case common.ChannelTypeMistral:
  79. apiType = APITypeMistral
  80. case common.ChannelTypeDeepSeek:
  81. apiType = APITypeDeepSeek
  82. case common.ChannelTypeMokaAI:
  83. apiType = APITypeMokaAI
  84. case common.ChannelTypeVolcEngine:
  85. apiType = APITypeVolcEngine
  86. case common.ChannelTypeBaiduV2:
  87. apiType = APITypeBaiduV2
  88. case common.ChannelTypeOpenRouter:
  89. apiType = APITypeOpenRouter
  90. case common.ChannelTypeXinference:
  91. apiType = APITypeXinference
  92. }
  93. if apiType == -1 {
  94. return APITypeOpenAI, false
  95. }
  96. return apiType, true
  97. }