api_type.go 1.4 KB

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