api_type.go 1.9 KB

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