api_type.go 1.5 KB

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