endpoint_type.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package common
  2. import "github.com/QuantumNous/new-api/constant"
  3. // GetEndpointTypesByChannelType 获取渠道最优先端点类型(所有的渠道都支持 OpenAI 端点)
  4. func GetEndpointTypesByChannelType(channelType int, modelName string) []constant.EndpointType {
  5. var endpointTypes []constant.EndpointType
  6. switch channelType {
  7. case constant.ChannelTypeJina:
  8. endpointTypes = []constant.EndpointType{constant.EndpointTypeJinaRerank}
  9. //case constant.ChannelTypeMidjourney, constant.ChannelTypeMidjourneyPlus:
  10. // endpointTypes = []constant.EndpointType{constant.EndpointTypeMidjourney}
  11. //case constant.ChannelTypeSunoAPI:
  12. // endpointTypes = []constant.EndpointType{constant.EndpointTypeSuno}
  13. //case constant.ChannelTypeKling:
  14. // endpointTypes = []constant.EndpointType{constant.EndpointTypeKling}
  15. //case constant.ChannelTypeJimeng:
  16. // endpointTypes = []constant.EndpointType{constant.EndpointTypeJimeng}
  17. case constant.ChannelTypeAws:
  18. fallthrough
  19. case constant.ChannelTypeAnthropic:
  20. endpointTypes = []constant.EndpointType{constant.EndpointTypeAnthropic, constant.EndpointTypeOpenAI}
  21. case constant.ChannelTypeVertexAi:
  22. fallthrough
  23. case constant.ChannelTypeGemini:
  24. endpointTypes = []constant.EndpointType{constant.EndpointTypeGemini, constant.EndpointTypeOpenAI}
  25. case constant.ChannelTypeOpenRouter: // OpenRouter 只支持 OpenAI 端点
  26. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
  27. case constant.ChannelTypeSora:
  28. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAIVideo}
  29. default:
  30. if IsOpenAIResponseOnlyModel(modelName) {
  31. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAIResponse}
  32. } else {
  33. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
  34. }
  35. }
  36. if IsImageGenerationModel(modelName) {
  37. // add to first
  38. endpointTypes = append([]constant.EndpointType{constant.EndpointTypeImageGeneration}, endpointTypes...)
  39. }
  40. return endpointTypes
  41. }