Skip to content

Commit dfc32cc

Browse files
klb3713康龙彪songquanpeng
authored
feat: add support for bytedance's doubao (songquanpeng#1438)
* 增加豆包大模型支持 * chore: update channel options & add prompt --------- Co-authored-by: 康龙彪 <longbiao.kang@i-tudou.com> Co-authored-by: JustSong <songquanpeng@foxmail.com>
1 parent 17ad4cf commit dfc32cc

File tree

10 files changed

+51
-2
lines changed

10 files changed

+51
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
6868
+ [x] [Anthropic Claude 系列模型](https://anthropic.com) (支持 AWS Claude)
6969
+ [x] [Google PaLM2/Gemini 系列模型](https://developers.generativeai.google)
7070
+ [x] [Mistral 系列模型](https://mistral.ai/)
71+
+ [x] [字节跳动豆包大模型](https://console.volcengine.com/ark/region:ark+cn-beijing/model)
7172
+ [x] [百度文心一言系列模型](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html)
7273
+ [x] [阿里通义千问系列模型](https://help.aliyun.com/document_detail/2400395.html)
7374
+ [x] [讯飞星火认知大模型](https://www.xfyun.cn/doc/spark/Web.html)
@@ -76,7 +77,6 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
7677
+ [x] [腾讯混元大模型](https://cloud.tencent.com/document/product/1729)
7778
+ [x] [Moonshot AI](https://platform.moonshot.cn/)
7879
+ [x] [百川大模型](https://platform.baichuan-ai.com)
79-
+ [ ] [字节云雀大模型](https://www.volcengine.com/product/ark) (WIP)
8080
+ [x] [MINIMAX](https://api.minimax.chat/)
8181
+ [x] [Groq](https://wow.groq.com/)
8282
+ [x] [Ollama](https://github.com/ollama/ollama)

relay/adaptor/doubao/constants.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package doubao
2+
3+
// https://console.volcengine.com/ark/region:ark+cn-beijing/model
4+
5+
var ModelList = []string{
6+
"Doubao-pro-128k",
7+
"Doubao-pro-32k",
8+
"Doubao-pro-4k",
9+
"Doubao-lite-128k",
10+
"Doubao-lite-32k",
11+
"Doubao-lite-4k",
12+
"Doubao-embedding",
13+
}

relay/adaptor/doubao/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package doubao
2+
3+
import (
4+
"fmt"
5+
"github.com/songquanpeng/one-api/relay/meta"
6+
"github.com/songquanpeng/one-api/relay/relaymode"
7+
)
8+
9+
func GetRequestURL(meta *meta.Meta) (string, error) {
10+
if meta.Mode == relaymode.ChatCompletions {
11+
return fmt.Sprintf("%s/api/v3/chat/completions", meta.BaseURL), nil
12+
}
13+
return "", fmt.Errorf("unsupported relay mode %d for doubao", meta.Mode)
14+
}

relay/adaptor/openai/adaptor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/gin-gonic/gin"
77
"github.com/songquanpeng/one-api/relay/adaptor"
8+
"github.com/songquanpeng/one-api/relay/adaptor/doubao"
89
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
910
"github.com/songquanpeng/one-api/relay/channeltype"
1011
"github.com/songquanpeng/one-api/relay/meta"
@@ -45,6 +46,8 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
4546
return GetFullRequestURL(meta.BaseURL, requestURL, meta.ChannelType), nil
4647
case channeltype.Minimax:
4748
return minimax.GetRequestURL(meta)
49+
case channeltype.Doubao:
50+
return doubao.GetRequestURL(meta)
4851
default:
4952
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
5053
}

relay/adaptor/openai/compatible.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/songquanpeng/one-api/relay/adaptor/ai360"
55
"github.com/songquanpeng/one-api/relay/adaptor/baichuan"
66
"github.com/songquanpeng/one-api/relay/adaptor/deepseek"
7+
"github.com/songquanpeng/one-api/relay/adaptor/doubao"
78
"github.com/songquanpeng/one-api/relay/adaptor/groq"
89
"github.com/songquanpeng/one-api/relay/adaptor/lingyiwanwu"
910
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
@@ -20,6 +21,7 @@ var CompatibleChannels = []int{
2021
channeltype.Moonshot,
2122
channeltype.Baichuan,
2223
channeltype.Minimax,
24+
channeltype.Doubao,
2325
channeltype.Mistral,
2426
channeltype.Groq,
2527
channeltype.LingYiWanWu,
@@ -52,6 +54,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
5254
return "deepseek", deepseek.ModelList
5355
case channeltype.TogetherAI:
5456
return "together.ai", togetherai.ModelList
57+
case channeltype.Doubao:
58+
return "doubao", doubao.ModelList
5559
default:
5660
return "openai", ModelList
5761
}

relay/channeltype/define.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ const (
4141
Cloudflare
4242
DeepL
4343
TogetherAI
44-
44+
Doubao
4545
Dummy
4646
)

relay/channeltype/url.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var ChannelBaseURLs = []string{
4141
"https://api.cloudflare.com", // 37
4242
"https://api-free.deepl.com", // 38
4343
"https://api.together.xyz", // 39
44+
"https://ark.cn-beijing.volces.com", // 40
4445
}
4546

4647
func init() {

web/berry/src/constants/ChannelConstants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ export const CHANNEL_OPTIONS = {
4747
value: 28,
4848
color: 'warning'
4949
},
50+
40: {
51+
key: 40,
52+
text: '字节跳动豆包',
53+
value: 40,
54+
color: 'primary'
55+
},
5056
15: {
5157
key: 15,
5258
text: '百度文心千帆',

web/default/src/constants/channel.constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const CHANNEL_OPTIONS = [
66
{key: 11, text: 'Google PaLM2', value: 11, color: 'orange'},
77
{key: 24, text: 'Google Gemini', value: 24, color: 'orange'},
88
{key: 28, text: 'Mistral AI', value: 28, color: 'orange'},
9+
{key: 40, text: '字节跳动豆包', value: 40, color: 'blue'},
910
{key: 15, text: '百度文心千帆', value: 15, color: 'blue'},
1011
{key: 17, text: '阿里通义千问', value: 17, color: 'orange'},
1112
{key: 18, text: '讯飞星火认知', value: 18, color: 'blue'},

web/default/src/pages/Channel/EditChannel.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ const EditChannel = () => {
362362
</Message>
363363
)
364364
}
365+
{
366+
inputs.type === 40 && (
367+
<Message>
368+
对于豆包而言,需要手动去 <a target="_blank" href="https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint">模型推理页面</a> 创建推理接入点,以接入点名称作为模型名称,例如:`ep-20240608051426-tkxvl`。
369+
</Message>
370+
)
371+
}
365372
<Form.Field>
366373
<Form.Dropdown
367374
label='模型'

0 commit comments

Comments
 (0)