Merge pull request #1832 from seefs001/feature/deepseek-claude-code
feat: deepseek claude endpoint
This commit is contained in:
@@ -3,17 +3,17 @@ package deepseek
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
"one-api/relay/channel"
|
"one-api/relay/channel"
|
||||||
|
"one-api/relay/channel/claude"
|
||||||
"one-api/relay/channel/openai"
|
"one-api/relay/channel/openai"
|
||||||
relaycommon "one-api/relay/common"
|
relaycommon "one-api/relay/common"
|
||||||
"one-api/relay/constant"
|
"one-api/relay/constant"
|
||||||
"one-api/types"
|
"one-api/types"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Adaptor struct {
|
type Adaptor struct {
|
||||||
@@ -25,7 +25,7 @@ func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error) {
|
func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error) {
|
||||||
adaptor := openai.Adaptor{}
|
adaptor := claude.Adaptor{}
|
||||||
return adaptor.ConvertClaudeRequest(c, info, req)
|
return adaptor.ConvertClaudeRequest(c, info, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,14 +44,19 @@ 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) {
|
||||||
fimBaseUrl := info.ChannelBaseUrl
|
fimBaseUrl := info.ChannelBaseUrl
|
||||||
if !strings.HasSuffix(info.ChannelBaseUrl, "/beta") {
|
switch info.RelayFormat {
|
||||||
fimBaseUrl += "/beta"
|
case types.RelayFormatClaude:
|
||||||
}
|
return fmt.Sprintf("%s/anthropic/v1/messages", info.ChannelBaseUrl), nil
|
||||||
switch info.RelayMode {
|
|
||||||
case constant.RelayModeCompletions:
|
|
||||||
return fmt.Sprintf("%s/completions", fimBaseUrl), nil
|
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("%s/v1/chat/completions", info.ChannelBaseUrl), nil
|
if !strings.HasSuffix(info.ChannelBaseUrl, "/beta") {
|
||||||
|
fimBaseUrl += "/beta"
|
||||||
|
}
|
||||||
|
switch info.RelayMode {
|
||||||
|
case constant.RelayModeCompletions:
|
||||||
|
return fmt.Sprintf("%s/completions", fimBaseUrl), nil
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("%s/v1/chat/completions", info.ChannelBaseUrl), nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user