mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-17 11:03:41 +08:00
feat: add doubao channel
This commit is contained in:
15
relay/channel/doubao/constants.go
Normal file
15
relay/channel/doubao/constants.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package doubao
|
||||
|
||||
// https://console.volcengine.com/ark/region:ark+cn-beijing/model
|
||||
|
||||
var ModelList = []string{
|
||||
"Doubao-pro-128k",
|
||||
"Doubao-pro-32k",
|
||||
"Doubao-pro-4k",
|
||||
"Doubao-lite-128k",
|
||||
"Doubao-lite-32k",
|
||||
"Doubao-lite-4k",
|
||||
"Doubao-embedding",
|
||||
}
|
||||
|
||||
var ChannelName = "doubao"
|
||||
10
relay/channel/doubao/relay-doubao.go
Normal file
10
relay/channel/doubao/relay-doubao.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package doubao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
relaycommon "one-api/relay/common"
|
||||
)
|
||||
|
||||
func GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||
return fmt.Sprintf("%s/api/v3/chat/completions", info.BaseUrl), nil
|
||||
}
|
||||
@@ -3,19 +3,21 @@ package openai
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io"
|
||||
"net/http"
|
||||
"one-api/common"
|
||||
"one-api/dto"
|
||||
"one-api/relay/channel"
|
||||
"one-api/relay/channel/ai360"
|
||||
"one-api/relay/channel/doubao"
|
||||
"one-api/relay/channel/lingyiwanwu"
|
||||
"one-api/relay/channel/minimax"
|
||||
"one-api/relay/channel/moonshot"
|
||||
relaycommon "one-api/relay/common"
|
||||
"one-api/service"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Adaptor struct {
|
||||
@@ -41,6 +43,8 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||
return relaycommon.GetFullRequestURL(info.BaseUrl, requestURL, info.ChannelType), nil
|
||||
case common.ChannelTypeMiniMax:
|
||||
return minimax.GetRequestURL(info)
|
||||
case common.ChannelTypeDoubao:
|
||||
return doubao.GetRequestURL(info)
|
||||
case common.ChannelTypeCustom:
|
||||
url := info.BaseUrl
|
||||
url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
|
||||
@@ -101,6 +105,8 @@ func (a *Adaptor) GetModelList() []string {
|
||||
return lingyiwanwu.ModelList
|
||||
case common.ChannelTypeMiniMax:
|
||||
return minimax.ModelList
|
||||
case common.ChannelTypeDoubao:
|
||||
return doubao.ModelList
|
||||
default:
|
||||
return ModelList
|
||||
}
|
||||
@@ -116,6 +122,8 @@ func (a *Adaptor) GetChannelName() string {
|
||||
return lingyiwanwu.ChannelName
|
||||
case common.ChannelTypeMiniMax:
|
||||
return minimax.ChannelName
|
||||
case common.ChannelTypeDoubao:
|
||||
return doubao.ChannelName
|
||||
default:
|
||||
return ChannelName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user