Просмотр исходного кода

feat: Add support for DeepSeek completions endpoint

1808837298@qq.com 1 год назад
Родитель
Сommit
7b384cb933
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      relay/channel/deepseek/adaptor.go

+ 7 - 1
relay/channel/deepseek/adaptor.go

@@ -10,6 +10,7 @@ import (
 	"one-api/relay/channel"
 	"one-api/relay/channel"
 	"one-api/relay/channel/openai"
 	"one-api/relay/channel/openai"
 	relaycommon "one-api/relay/common"
 	relaycommon "one-api/relay/common"
+	"one-api/relay/constant"
 )
 )
 
 
 type Adaptor struct {
 type Adaptor struct {
@@ -29,7 +30,12 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
 }
 }
 
 
 func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
 func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
-	return fmt.Sprintf("%s/v1/chat/completions", info.BaseUrl), nil
+	switch info.RelayMode {
+	case constant.RelayModeCompletions:
+		return fmt.Sprintf("%s/beta/completions", info.BaseUrl), nil
+	default:
+		return fmt.Sprintf("%s/v1/chat/completions", info.BaseUrl), nil
+	}
 }
 }
 
 
 func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error {
 func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error {