api_type.go 2.2 KB

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