api_type.go 1.8 KB

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