api_type.go 1.8 KB

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