api_type.go 2.1 KB

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