mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-27 04:16:37 +08:00
feat: add doubao channel
This commit is contained in:
parent
318a086e10
commit
023d141e4a
@ -232,6 +232,7 @@ const (
|
|||||||
ChannelTypeCohere = 34
|
ChannelTypeCohere = 34
|
||||||
ChannelTypeMiniMax = 35
|
ChannelTypeMiniMax = 35
|
||||||
ChannelTypeScholarAI = 36
|
ChannelTypeScholarAI = 36
|
||||||
|
ChannelTypeDoubao = 37
|
||||||
|
|
||||||
ChannelTypeDummy // this one is only for count, do not add any channel after this
|
ChannelTypeDummy // this one is only for count, do not add any channel after this
|
||||||
)
|
)
|
||||||
@ -274,4 +275,5 @@ var ChannelBaseURLs = []string{
|
|||||||
"https://api.cohere.ai", //34
|
"https://api.cohere.ai", //34
|
||||||
"https://api.minimax.chat", //35
|
"https://api.minimax.chat", //35
|
||||||
"https://api.scholarai.io", //36
|
"https://api.scholarai.io", //36
|
||||||
|
"https://ark.cn-beijing.volces.com", //37
|
||||||
}
|
}
|
||||||
|
@ -125,8 +125,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
channelId2Models = make(map[int][]string)
|
channelId2Models = make(map[int][]string)
|
||||||
for i := 1; i <= common.ChannelTypeDummy; i++ {
|
for i := 1; i <= common.ChannelTypeDummy; i++ {
|
||||||
apiType, success := relayconstant.ChannelType2APIType(i)
|
apiType, _ := relayconstant.ChannelType2APIType(i)
|
||||||
if !success || apiType == relayconstant.APITypeAIProxyLibrary {
|
if apiType == relayconstant.APITypeAIProxyLibrary {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
meta := &relaycommon.RelayInfo{ChannelType: i}
|
meta := &relaycommon.RelayInfo{ChannelType: i}
|
||||||
|
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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
"one-api/relay/channel"
|
"one-api/relay/channel"
|
||||||
"one-api/relay/channel/ai360"
|
"one-api/relay/channel/ai360"
|
||||||
|
"one-api/relay/channel/doubao"
|
||||||
"one-api/relay/channel/lingyiwanwu"
|
"one-api/relay/channel/lingyiwanwu"
|
||||||
"one-api/relay/channel/minimax"
|
"one-api/relay/channel/minimax"
|
||||||
"one-api/relay/channel/moonshot"
|
"one-api/relay/channel/moonshot"
|
||||||
relaycommon "one-api/relay/common"
|
relaycommon "one-api/relay/common"
|
||||||
"one-api/service"
|
"one-api/service"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Adaptor struct {
|
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
|
return relaycommon.GetFullRequestURL(info.BaseUrl, requestURL, info.ChannelType), nil
|
||||||
case common.ChannelTypeMiniMax:
|
case common.ChannelTypeMiniMax:
|
||||||
return minimax.GetRequestURL(info)
|
return minimax.GetRequestURL(info)
|
||||||
|
case common.ChannelTypeDoubao:
|
||||||
|
return doubao.GetRequestURL(info)
|
||||||
case common.ChannelTypeCustom:
|
case common.ChannelTypeCustom:
|
||||||
url := info.BaseUrl
|
url := info.BaseUrl
|
||||||
url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
|
url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
|
||||||
@ -101,6 +105,8 @@ func (a *Adaptor) GetModelList() []string {
|
|||||||
return lingyiwanwu.ModelList
|
return lingyiwanwu.ModelList
|
||||||
case common.ChannelTypeMiniMax:
|
case common.ChannelTypeMiniMax:
|
||||||
return minimax.ModelList
|
return minimax.ModelList
|
||||||
|
case common.ChannelTypeDoubao:
|
||||||
|
return doubao.ModelList
|
||||||
default:
|
default:
|
||||||
return ModelList
|
return ModelList
|
||||||
}
|
}
|
||||||
@ -116,6 +122,8 @@ func (a *Adaptor) GetChannelName() string {
|
|||||||
return lingyiwanwu.ChannelName
|
return lingyiwanwu.ChannelName
|
||||||
case common.ChannelTypeMiniMax:
|
case common.ChannelTypeMiniMax:
|
||||||
return minimax.ChannelName
|
return minimax.ChannelName
|
||||||
|
case common.ChannelTypeDoubao:
|
||||||
|
return doubao.ChannelName
|
||||||
default:
|
default:
|
||||||
return ChannelName
|
return ChannelName
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ export const CHANNEL_OPTIONS = [
|
|||||||
{ key: 31, text: '零一万物', value: 31, color: 'green', label: '零一万物' },
|
{ key: 31, text: '零一万物', value: 31, color: 'green', label: '零一万物' },
|
||||||
{ key: 35, text: 'MiniMax', value: 35, color: 'green', label: 'MiniMax' },
|
{ key: 35, text: 'MiniMax', value: 35, color: 'green', label: 'MiniMax' },
|
||||||
{ key: 36, text: 'ScholarAI', value: 36, color: 'green', label: 'ScholarAI' },
|
{ key: 36, text: 'ScholarAI', value: 36, color: 'green', label: 'ScholarAI' },
|
||||||
|
{ key: 37, text: '豆包', value: 37, color: 'green', label: '豆包' },
|
||||||
{ key: 8, text: '自定义渠道', value: 8, color: 'pink', label: '自定义渠道' },
|
{ key: 8, text: '自定义渠道', value: 8, color: 'pink', label: '自定义渠道' },
|
||||||
{
|
{
|
||||||
key: 22,
|
key: 22,
|
||||||
|
2538
web/yarn.lock
2538
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user