api_type.go 1.5 KB

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