api_type.go 1.6 KB

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