api_type.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. APITypeZhipu_v4
  17. APITypeDummy // this one is only for count, do not add any channel after this
  18. )
  19. func ChannelType2APIType(channelType int) int {
  20. apiType := APITypeOpenAI
  21. switch channelType {
  22. case common.ChannelTypeAnthropic:
  23. apiType = APITypeAnthropic
  24. case common.ChannelTypeBaidu:
  25. apiType = APITypeBaidu
  26. case common.ChannelTypePaLM:
  27. apiType = APITypePaLM
  28. case common.ChannelTypeZhipu:
  29. apiType = APITypeZhipu
  30. case common.ChannelTypeAli:
  31. apiType = APITypeAli
  32. case common.ChannelTypeXunfei:
  33. apiType = APITypeXunfei
  34. case common.ChannelTypeAIProxyLibrary:
  35. apiType = APITypeAIProxyLibrary
  36. case common.ChannelTypeTencent:
  37. apiType = APITypeTencent
  38. case common.ChannelTypeGemini:
  39. apiType = APITypeGemini
  40. case common.ChannelTypeZhipu_v4:
  41. apiType = APITypeZhipu_v4
  42. }
  43. return apiType
  44. }