-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Support Doubao Models (#5481)
* feat(config): add Doubao provider * fix * fix * add * fix * fix * src/server/globalConfig/index.ts * src/app/(main)/settings/provider/(detail)/doubao/page.tsx * fix * try * try * rec * follow review * test * 👌try * Update doubao.ts * Update index.ts * Delete src/app/(main)/settings/llm/ProviderList/Doubao/index.tsx * Update providers.tsx * Update providers.tsx --------- Co-authored-by: Arvin Xu <arvinx@foxmail.com>
- Loading branch information
Showing
15 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client'; | ||
|
||
import { DoubaoProviderCard } from '@/config/modelProviders'; | ||
import { ModelProvider } from '@/libs/agent-runtime'; | ||
import { useUserStore } from '@/store/user'; | ||
import { modelProviderSelectors } from '@/store/user/selectors'; | ||
|
||
import { ProviderItem } from '../../type'; | ||
import ProviderDetail from '../[id]'; | ||
|
||
const providerKey = ModelProvider.Doubao; | ||
|
||
const useProviderCard = (): ProviderItem => { | ||
|
||
// Get the first model card's deployment name as the check model | ||
const checkModel = useUserStore((s) => { | ||
const chatModelCards = modelProviderSelectors.getModelCardsById(providerKey)(s); | ||
|
||
if (chatModelCards.length > 0) { | ||
return chatModelCards[0].deploymentName; | ||
} | ||
|
||
return 'Doubao-lite-4k'; | ||
}); | ||
return { | ||
...DoubaoProviderCard, | ||
checkModel, | ||
modelList: { | ||
azureDeployName: true, | ||
}, | ||
}; | ||
}; | ||
|
||
const Page = () => { | ||
const card = useProviderCard(); | ||
|
||
return <ProviderDetail {...card} />; | ||
}; | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { AIChatModelCard } from '@/types/aiModel'; | ||
|
||
const doubaoChatModels: AIChatModelCard[] = [ | ||
{ | ||
contextWindowTokens: 4096, | ||
description: | ||
'拥有极致的响应速度,更好的性价比,为客户不同场景提供更灵活的选择。支持 4k 上下文窗口的推理和精调。', | ||
displayName: 'Doubao Lite 4k', | ||
enabled: true, | ||
id: 'Doubao-lite-4k', | ||
type: 'chat', | ||
}, | ||
{ | ||
contextWindowTokens: 32_768, | ||
description: | ||
'拥有极致的响应速度,更好的性价比,为客户不同场景提供更灵活的选择。支持 32k 上下文窗口的推理和精调。', | ||
displayName: 'Doubao Lite 32k', | ||
enabled: true, | ||
id: 'Doubao-lite-32k', | ||
type: 'chat', | ||
}, | ||
{ | ||
contextWindowTokens: 128_000, | ||
description: | ||
'拥有极致的响应速度,更好的性价比,为客户不同场景提供更灵活的选择。支持 128k 上下文窗口的推理和精调。', | ||
displayName: 'Doubao Lite 128k', | ||
enabled: true, | ||
id: 'Doubao-lite-128k', | ||
type: 'chat', | ||
}, | ||
{ | ||
contextWindowTokens: 4096, | ||
description: | ||
'效果最好的主力模型,适合处理复杂任务,在参考问答、总结摘要、创作、文本分类、角色扮演等场景都有很好的效果。支持 4k 上下文窗口的推理和精调。', | ||
displayName: 'Doubao Pro 4k', | ||
enabled: true, | ||
id: 'Doubao-pro-4k', | ||
type: 'chat', | ||
}, | ||
{ | ||
config: { | ||
deploymentName: 'Doubao-pro-test', | ||
}, | ||
contextWindowTokens: 32_768, | ||
description: | ||
'效果最好的主力模型,适合处理复杂任务,在参考问答、总结摘要、创作、文本分类、角色扮演等场景都有很好的效果。支持 32k 上下文窗口的推理和精调。', | ||
displayName: 'Doubao Pro 32k', | ||
enabled: true, | ||
id: 'Doubao-pro-32k', | ||
type: 'chat', | ||
}, | ||
{ | ||
contextWindowTokens: 128_000, | ||
description: | ||
'效果最好的主力模型,适合处理复杂任务,在参考问答、总结摘要、创作、文本分类、角色扮演等场景都有很好的效果。支持 128k 上下文窗口的推理和精调。', | ||
displayName: 'Doubao Pro 128k', | ||
enabled: true, | ||
id: 'Doubao-pro-128k', | ||
type: 'chat', | ||
}, | ||
]; | ||
|
||
export const allModels = [...doubaoChatModels]; | ||
|
||
export default allModels; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ModelProviderCard } from '@/types/llm'; | ||
|
||
// ref https://www.volcengine.com/docs/82379/1330310 | ||
const Doubao: ModelProviderCard = { | ||
chatModels: [], | ||
// checkModel: 'Doubao-lite-4k', | ||
description: '字节跳动推出的自研大模型。通过字节跳动内部50+业务场景实践验证,每日万亿级tokens大使用量持续打磨,提供多种模态能力,以优质模型效果为企业打造丰富的业务体验。', | ||
id: 'doubao', | ||
modelsUrl: 'https://www.volcengine.com/product/doubao', | ||
name: '豆包', | ||
settings: { | ||
disableBrowserRequest: true, // CORS error | ||
sdkType: 'doubao', | ||
// showModelFetcher: false, | ||
smoothing: { | ||
speed: 2, | ||
text: true, | ||
}, | ||
}, | ||
url: 'https://www.volcengine.com/product/doubao', | ||
}; | ||
|
||
export default Doubao; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ModelProvider } from '../types'; | ||
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; | ||
|
||
export const LobeDoubaoAI = LobeOpenAICompatibleFactory({ | ||
baseURL: 'https://ark.cn-beijing.volces.com/api/v3', | ||
debug: { | ||
chatCompletion: () => process.env.DEBUG_DOUBAO_CHAT_COMPLETION === '1', | ||
}, | ||
provider: ModelProvider.Doubao, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters