endpoint_type.go 1.2 KB

1234567891011121314151617181920212223242526272829
  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.ChannelTypeAws:
  10. fallthrough
  11. case constant.ChannelTypeAnthropic:
  12. endpointTypes = []constant.EndpointType{constant.EndpointTypeAnthropic, constant.EndpointTypeOpenAI}
  13. case constant.ChannelTypeVertexAi:
  14. fallthrough
  15. case constant.ChannelTypeGemini:
  16. endpointTypes = []constant.EndpointType{constant.EndpointTypeGemini, constant.EndpointTypeOpenAI}
  17. case constant.ChannelTypeOpenRouter: // OpenRouter 只支持 OpenAI 端点
  18. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
  19. default:
  20. if IsOpenAIResponseOnlyModel(modelName) {
  21. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAIResponse}
  22. } else {
  23. endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
  24. }
  25. }
  26. return endpointTypes
  27. }