-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
✨ feat: Support Doubao Models #5481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a026bc3
feat(config): add Doubao provider
sxjeru 7210508
fix
sxjeru 2fb3cce
fix
sxjeru ff5dab2
add
sxjeru 993c402
fix
sxjeru d46c2f9
fix
sxjeru aa107c2
src/server/globalConfig/index.ts
sxjeru e7bef1d
src/app/(main)/settings/provider/(detail)/doubao/page.tsx
sxjeru e0a9f98
fix
sxjeru 6b71917
try
sxjeru c2820e7
try
sxjeru b768646
rec
sxjeru dd95298
follow review
sxjeru 6dc17b3
test
sxjeru 80054d1
Merge branch 'lobehub:main' into doubao2
sxjeru 41a6f3e
👌try
sxjeru 7041a8e
Update doubao.ts
sxjeru bf9cfe9
Update index.ts
sxjeru 32e1614
Merge branch 'main' into doubao2
sxjeru 13907f6
Delete src/app/(main)/settings/llm/ProviderList/Doubao/index.tsx
arvinxx 26472a9
Update providers.tsx
arvinxx a40fc83
Update providers.tsx
arvinxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
arvinxx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or 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,31 @@ | ||
| 'use client'; | ||
|
|
||
| import { DoubaoProviderCard } from '@/config/modelProviders'; | ||
| import { useUserStore } from '@/store/user'; | ||
| import { modelProviderSelectors } from '@/store/user/selectors'; | ||
| import { GlobalLLMProviderKey } from '@/types/user/settings'; | ||
|
|
||
| import { ProviderItem } from '../../type'; | ||
|
|
||
| const providerKey: GlobalLLMProviderKey = 'doubao'; | ||
|
|
||
| export const useDoubaoProvider = (): 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 'no-model'; | ||
| }); | ||
|
|
||
| return { | ||
| ...DoubaoProviderCard, | ||
| checkModel, | ||
| modelList: { | ||
| azureDeployName: true, | ||
| }, | ||
| }; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/llm 路径下不再做任何变更
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分大概旧版设置页(/settings/llm)还在用吧,貌似本地调试还没有更新到服务端数据库在用的 /settings/provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本地的话需要配置
NEXT_PUBLIC_CLIENT_DB=pglite开启新版,估计再迭代 2~3 个中版本,client db 就准备全量迁移 pglite 了。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我已升级到v1.51.12,但大模型列表中没有豆包选项,请问任何开启?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果不是服务端数据库版本,需要在环境变量添加
NEXT_PUBLIC_CLIENT_DB=pglite