api_type.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. APITypeDummy // this one is only for count, do not add any channel after this
  30. )
  31. func ChannelType2APIType(channelType int) (int, bool) {
  32. apiType := -1
  33. switch channelType {
  34. case common.ChannelTypeOpenAI:
  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 = APITypeZhipuV4
  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. case common.ChannelTypeDify:
  65. apiType = APITypeDify
  66. case common.ChannelTypeJina:
  67. apiType = APITypeJina
  68. case common.ChannelCloudflare:
  69. apiType = APITypeCloudflare
  70. case common.ChannelTypeSiliconFlow:
  71. apiType = APITypeSiliconFlow
  72. case common.ChannelTypeVertexAi:
  73. apiType = APITypeVertexAi
  74. case common.ChannelTypeMistral:
  75. apiType = APITypeMistral
  76. case common.ChannelTypeDeepSeek:
  77. apiType = APITypeDeepSeek
  78. case common.ChannelTypeMokaAI:
  79. apiType = APITypeMokaAI
  80. }
  81. if apiType == -1 {
  82. return APITypeOpenAI, false
  83. }
  84. return apiType, true
  85. }