endpoint_type.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package common
  2. import "one-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. default:
  28. if IsOpenAIResponseOnlyModel(modelName) {
  29. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAIResponse}
  30. } else {
  31. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
  32. }
  33. }
  34. if IsImageGenerationModel(modelName) {
  35. // add to first
  36. endpointTypes = append([]constant.EndpointType{constant.EndpointTypeImageGeneration}, endpointTypes...)
  37. }
  38. return endpointTypes
  39. }