@lobehub/chat 1.43.6 → 1.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/server-database/docker-compose.mdx +2 -2
- package/locales/ar/common.json +1 -0
- package/locales/ar/modelProvider.json +176 -0
- package/locales/ar/setting.json +1 -0
- package/locales/bg-BG/common.json +1 -0
- package/locales/bg-BG/modelProvider.json +176 -0
- package/locales/bg-BG/setting.json +1 -0
- package/locales/de-DE/common.json +1 -0
- package/locales/de-DE/modelProvider.json +176 -0
- package/locales/de-DE/setting.json +1 -0
- package/locales/en-US/common.json +1 -0
- package/locales/en-US/modelProvider.json +176 -0
- package/locales/en-US/setting.json +1 -0
- package/locales/es-ES/common.json +1 -0
- package/locales/es-ES/modelProvider.json +176 -0
- package/locales/es-ES/setting.json +1 -0
- package/locales/fa-IR/common.json +1 -0
- package/locales/fa-IR/modelProvider.json +176 -0
- package/locales/fa-IR/setting.json +1 -0
- package/locales/fr-FR/common.json +1 -0
- package/locales/fr-FR/modelProvider.json +176 -0
- package/locales/fr-FR/setting.json +1 -0
- package/locales/it-IT/common.json +1 -0
- package/locales/it-IT/modelProvider.json +176 -0
- package/locales/it-IT/setting.json +1 -0
- package/locales/ja-JP/common.json +1 -0
- package/locales/ja-JP/modelProvider.json +176 -0
- package/locales/ja-JP/setting.json +1 -0
- package/locales/ko-KR/common.json +1 -0
- package/locales/ko-KR/modelProvider.json +176 -0
- package/locales/ko-KR/setting.json +1 -0
- package/locales/nl-NL/common.json +1 -0
- package/locales/nl-NL/modelProvider.json +176 -0
- package/locales/nl-NL/setting.json +1 -0
- package/locales/pl-PL/common.json +1 -0
- package/locales/pl-PL/modelProvider.json +176 -0
- package/locales/pl-PL/setting.json +1 -0
- package/locales/pt-BR/common.json +1 -0
- package/locales/pt-BR/modelProvider.json +176 -0
- package/locales/pt-BR/setting.json +1 -0
- package/locales/ru-RU/common.json +1 -0
- package/locales/ru-RU/modelProvider.json +176 -0
- package/locales/ru-RU/setting.json +1 -0
- package/locales/tr-TR/common.json +1 -0
- package/locales/tr-TR/modelProvider.json +176 -0
- package/locales/tr-TR/setting.json +1 -0
- package/locales/vi-VN/common.json +1 -0
- package/locales/vi-VN/modelProvider.json +176 -0
- package/locales/vi-VN/setting.json +1 -0
- package/locales/zh-CN/common.json +1 -0
- package/locales/zh-CN/modelProvider.json +176 -0
- package/locales/zh-CN/setting.json +1 -0
- package/locales/zh-TW/common.json +1 -0
- package/locales/zh-TW/modelProvider.json +176 -0
- package/locales/zh-TW/setting.json +1 -0
- package/next.config.ts +1 -1
- package/package.json +4 -4
- package/src/app/(main)/(mobile)/me/settings/features/Category.tsx +1 -1
- package/src/app/(main)/(mobile)/me/settings/features/useCategory.tsx +12 -5
- package/src/app/(main)/changelog/features/VersionTag.tsx +1 -2
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/Thread.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/ThreadItem.tsx +1 -2
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/index.tsx +0 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/InboxWelcome/AgentsSuggest.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/InboxWelcome/QuestionSuggest.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ZenModeToast/Toast.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@topic/features/TopicListContent/ThreadItem/index.tsx +0 -2
- package/src/app/(main)/chat/(workspace)/@topic/features/TopicListContent/TopicItem/index.tsx +0 -1
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Tags.tsx +2 -3
- package/src/app/(main)/chat/@session/features/SessionListContent/CollapseGroup/index.tsx +1 -1
- package/src/app/(main)/chat/features/Migration/Start.tsx +1 -1
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/TopicList.tsx +4 -3
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx +1 -1
- package/src/app/(main)/discover/(detail)/features/ShareButton.tsx +2 -1
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Header.tsx +1 -1
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx +1 -1
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/Header.tsx +1 -1
- package/src/app/(main)/discover/(list)/_layout/Desktop/Nav.tsx +0 -1
- package/src/app/(main)/discover/(list)/assistants/features/Card.tsx +1 -1
- package/src/app/(main)/discover/(list)/models/features/Card.tsx +1 -1
- package/src/app/(main)/discover/(list)/plugins/features/Card.tsx +1 -1
- package/src/app/(main)/discover/(list)/providers/features/Card.tsx +1 -1
- package/src/app/(main)/discover/components/GridLoadingCard.tsx +2 -1
- package/src/app/(main)/discover/components/Title.tsx +1 -1
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/EmptyStatus.tsx +1 -1
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/Item/index.tsx +0 -1
- package/src/app/(main)/files/(content)/@modal/(.)[id]/FullscreenModal.tsx +2 -2
- package/src/app/(main)/files/(content)/NotSupportClient.tsx +2 -2
- package/src/app/(main)/profile/_layout/Desktop/SideBar.tsx +1 -1
- package/src/app/(main)/profile/stats/features/ShareButton/Preview.tsx +5 -5
- package/src/app/(main)/repos/[id]/evals/components/Container.tsx +1 -1
- package/src/app/(main)/repos/[id]/evals/dataset/DatasetList/Item.tsx +0 -1
- package/src/app/(main)/settings/_layout/Desktop/SideBar.tsx +1 -1
- package/src/app/(main)/settings/about/features/ItemCard.tsx +3 -3
- package/src/app/(main)/settings/about/features/Version.tsx +1 -1
- package/src/app/(main)/settings/hooks/useCategory.tsx +22 -9
- package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +2 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +0 -1
- package/src/app/(main)/settings/provider/(detail)/[id]/index.tsx +19 -0
- package/src/app/(main)/settings/provider/(detail)/[id]/page.tsx +95 -0
- package/src/app/(main)/settings/provider/(detail)/azure/page.tsx +119 -0
- package/src/app/(main)/settings/provider/(detail)/bedrock/page.tsx +91 -0
- package/src/app/(main)/settings/provider/(detail)/cloudflare/page.tsx +58 -0
- package/src/app/(main)/settings/provider/(detail)/github/page.tsx +67 -0
- package/src/app/(main)/settings/provider/(detail)/huggingface/page.tsx +67 -0
- package/src/app/(main)/settings/provider/(detail)/ollama/Checker.tsx +73 -0
- package/src/app/(main)/settings/provider/(detail)/ollama/page.tsx +34 -0
- package/src/app/(main)/settings/provider/(detail)/openai/page.tsx +23 -0
- package/src/app/(main)/settings/provider/(detail)/wenxin/page.tsx +61 -0
- package/src/app/(main)/settings/provider/(list)/Footer.tsx +36 -0
- package/src/app/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +134 -0
- package/src/app/(main)/settings/provider/(list)/ProviderGrid/index.tsx +91 -0
- package/src/app/(main)/settings/provider/(list)/index.tsx +19 -0
- package/src/app/(main)/settings/provider/ProviderMenu/AddNew.tsx +28 -0
- package/src/app/(main)/settings/provider/ProviderMenu/All.tsx +29 -0
- package/src/app/(main)/settings/provider/ProviderMenu/Item.tsx +69 -0
- package/src/app/(main)/settings/provider/ProviderMenu/List.tsx +76 -0
- package/src/app/(main)/settings/provider/ProviderMenu/SearchResult.tsx +43 -0
- package/src/app/(main)/settings/provider/ProviderMenu/SkeletonList.tsx +60 -0
- package/src/app/(main)/settings/provider/ProviderMenu/SortProviderModal/GroupItem.tsx +30 -0
- package/src/app/(main)/settings/provider/ProviderMenu/SortProviderModal/index.tsx +91 -0
- package/src/app/(main)/settings/provider/ProviderMenu/index.tsx +80 -0
- package/src/app/(main)/settings/provider/_layout/Desktop.tsx +37 -0
- package/src/app/(main)/settings/provider/_layout/Mobile.tsx +14 -0
- package/src/app/(main)/settings/provider/const.ts +20 -0
- package/src/app/(main)/settings/provider/features/CreateNewProvider/index.tsx +146 -0
- package/src/app/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx +105 -0
- package/src/app/(main)/settings/provider/features/ModelList/CreateNewModelModal/index.tsx +69 -0
- package/src/app/(main)/settings/provider/features/ModelList/DisabledModels.tsx +29 -0
- package/src/app/(main)/settings/provider/features/ModelList/EmptyModels.tsx +101 -0
- package/src/app/(main)/settings/provider/features/ModelList/EnabledModelList/index.tsx +85 -0
- package/src/app/(main)/settings/provider/features/ModelList/ModelConfigModal/Form.tsx +109 -0
- package/src/app/(main)/settings/provider/features/ModelList/ModelConfigModal/index.tsx +76 -0
- package/src/app/(main)/settings/provider/features/ModelList/ModelItem.tsx +346 -0
- package/src/app/(main)/settings/provider/features/ModelList/ModelTitle/Search.tsx +37 -0
- package/src/app/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx +145 -0
- package/src/app/(main)/settings/provider/features/ModelList/SearchResult.tsx +67 -0
- package/src/app/(main)/settings/provider/features/ModelList/SkeletonList.tsx +63 -0
- package/src/app/(main)/settings/provider/features/ModelList/SortModelModal/ListItem.tsx +20 -0
- package/src/app/(main)/settings/provider/features/ModelList/SortModelModal/index.tsx +96 -0
- package/src/app/(main)/settings/provider/features/ModelList/index.tsx +59 -0
- package/src/app/(main)/settings/provider/features/ProviderConfig/Checker.tsx +120 -0
- package/src/app/(main)/settings/provider/features/ProviderConfig/SkeletonInput.tsx +5 -0
- package/src/app/(main)/settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx +137 -0
- package/src/app/(main)/settings/provider/features/ProviderConfig/UpdateProviderInfo/index.tsx +49 -0
- package/src/app/(main)/settings/provider/features/ProviderConfig/index.tsx +343 -0
- package/src/app/(main)/settings/provider/layout.tsx +21 -0
- package/src/app/(main)/settings/provider/page.tsx +17 -0
- package/src/app/(main)/settings/provider/type.ts +5 -0
- package/src/app/(main)/settings/sync/features/DeviceInfo/Card.tsx +1 -1
- package/src/app/(main)/settings/sync/features/DeviceInfo/index.tsx +1 -1
- package/src/app/@modal/(.)changelog/modal/features/ReadDetail.tsx +1 -1
- package/src/app/@modal/(.)changelog/modal/features/VersionTag.tsx +1 -2
- package/src/app/@modal/(.)changelog/modal/layout.tsx +1 -1
- package/src/components/Cell/index.tsx +1 -1
- package/src/components/DragUpload/index.tsx +2 -3
- package/src/components/FeatureList/index.tsx +1 -1
- package/src/components/FileParsingStatus/EmbeddingStatus.tsx +1 -1
- package/src/components/FileParsingStatus/index.tsx +1 -1
- package/src/components/FunctionModal/style.tsx +2 -2
- package/src/components/GoBack/index.tsx +1 -2
- package/src/components/HotKeys/index.tsx +1 -1
- package/src/components/InstantSwitch/index.tsx +28 -0
- package/src/components/Menu/index.tsx +1 -1
- package/src/components/ModelSelect/index.tsx +20 -10
- package/src/components/Notification/index.tsx +2 -1
- package/src/components/StatisticCard/index.tsx +5 -6
- package/src/config/aiModels/ai21.ts +38 -0
- package/src/config/aiModels/ai360.ts +71 -0
- package/src/config/aiModels/anthropic.ts +152 -0
- package/src/config/aiModels/azure.ts +86 -0
- package/src/config/aiModels/baichuan.ts +107 -0
- package/src/config/aiModels/bedrock.ts +315 -0
- package/src/config/aiModels/cloudflare.ts +88 -0
- package/src/config/aiModels/deepseek.ts +27 -0
- package/src/config/aiModels/fireworksai.ts +232 -0
- package/src/config/aiModels/giteeai.ts +137 -0
- package/src/config/aiModels/github.ts +273 -0
- package/src/config/aiModels/google.ts +317 -0
- package/src/config/aiModels/groq.ts +202 -0
- package/src/config/aiModels/higress.ts +2828 -0
- package/src/config/aiModels/huggingface.ts +56 -0
- package/src/config/aiModels/hunyuan.ts +151 -0
- package/src/config/aiModels/index.ts +98 -0
- package/src/config/aiModels/internlm.ts +40 -0
- package/src/config/aiModels/minimax.ts +55 -0
- package/src/config/aiModels/mistral.ts +172 -0
- package/src/config/aiModels/moonshot.ts +44 -0
- package/src/config/aiModels/novita.ts +124 -0
- package/src/config/aiModels/ollama.ts +412 -0
- package/src/config/aiModels/openai.ts +537 -0
- package/src/config/aiModels/openrouter.ts +252 -0
- package/src/config/aiModels/perplexity.ts +67 -0
- package/src/config/aiModels/qwen.ts +302 -0
- package/src/config/aiModels/sensenova.ts +114 -0
- package/src/config/aiModels/siliconcloud.ts +679 -0
- package/src/config/aiModels/spark.ts +68 -0
- package/src/config/aiModels/stepfun.ts +153 -0
- package/src/config/aiModels/taichu.ts +19 -0
- package/src/config/aiModels/togetherai.ts +334 -0
- package/src/config/aiModels/upstage.ts +37 -0
- package/src/config/aiModels/wenxin.ts +171 -0
- package/src/config/aiModels/xai.ts +72 -0
- package/src/config/aiModels/zeroone.ts +156 -0
- package/src/config/aiModels/zhipu.ts +235 -0
- package/src/config/featureFlags/schema.ts +3 -0
- package/src/config/modelProviders/anthropic.ts +1 -0
- package/src/config/modelProviders/github.ts +0 -1
- package/src/config/modelProviders/google.ts +1 -0
- package/src/config/modelProviders/stepfun.ts +2 -0
- package/src/database/migrations/0013_add_ai_infra.sql +44 -0
- package/src/database/migrations/meta/0013_snapshot.json +3598 -0
- package/src/database/migrations/meta/_journal.json +7 -0
- package/src/database/repositories/aiInfra/index.ts +117 -0
- package/src/database/schemas/aiInfra.ts +69 -0
- package/src/database/schemas/index.ts +1 -0
- package/src/database/server/models/__tests__/aiModel.test.ts +318 -0
- package/src/database/server/models/__tests__/aiProvider.test.ts +373 -0
- package/src/database/server/models/aiModel.ts +251 -0
- package/src/database/server/models/aiProvider.ts +234 -0
- package/src/features/AgentSetting/AgentPrompt/index.tsx +2 -2
- package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +2 -1
- package/src/features/ChatInput/ActionBar/Tools/index.tsx +2 -3
- package/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx +2 -3
- package/src/features/ChatInput/Desktop/FilePreview/FileItem/index.tsx +3 -2
- package/src/features/ChatInput/Desktop/FilePreview/FileList.tsx +2 -2
- package/src/features/ChatInput/Mobile/Files/FileItem/File.tsx +2 -2
- package/src/features/ChatInput/Mobile/InputArea/index.tsx +1 -1
- package/src/features/ChatInput/STT/common.tsx +1 -1
- package/src/features/Conversation/Error/style.tsx +2 -2
- package/src/features/Conversation/Messages/Assistant/FileChunks/Item/style.ts +2 -2
- package/src/features/Conversation/Messages/Assistant/FileChunks/index.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/ToolCallItem/Inspector/style.ts +2 -3
- package/src/features/Conversation/Messages/Assistant/ToolCallItem/style.ts +2 -3
- package/src/features/Conversation/Messages/User/FileListViewer/Item.tsx +0 -1
- package/src/features/Conversation/components/BackBottom/style.ts +2 -2
- package/src/features/Conversation/components/MarkdownElements/LobeArtifact/Render/Icon.tsx +2 -3
- package/src/features/Conversation/components/MarkdownElements/LobeArtifact/Render/index.tsx +3 -3
- package/src/features/Conversation/components/MarkdownElements/LobeThinking/Render.tsx +1 -1
- package/src/features/Conversation/components/OTPInput.tsx +2 -2
- package/src/features/DataImporter/Loading.tsx +1 -1
- package/src/features/FileManager/FileList/EmptyStatus.tsx +1 -1
- package/src/features/FileManager/FileList/index.tsx +1 -1
- package/src/features/FileManager/UploadDock/Item.tsx +1 -1
- package/src/features/FileManager/UploadDock/index.tsx +4 -4
- package/src/features/FileViewer/NotSupport/index.tsx +1 -1
- package/src/features/FileViewer/Renderer/MSDoc/index.tsx +0 -1
- package/src/features/FileViewer/Renderer/TXT/index.tsx +1 -1
- package/src/features/InitClientDB/EnableModal.tsx +1 -1
- package/src/features/InitClientDB/ErrorResult.tsx +1 -1
- package/src/features/InitClientDB/InitIndicator.tsx +1 -1
- package/src/features/KnowledgeBaseModal/AddFilesToKnowledgeBase/SelectForm.tsx +0 -1
- package/src/features/ModelSelect/index.tsx +8 -1
- package/src/features/ModelSwitchPanel/index.tsx +10 -3
- package/src/features/PluginsUI/Render/Loading.tsx +0 -1
- package/src/features/Portal/Home/Body/Files/FileList/Item.tsx +1 -1
- package/src/features/Portal/Home/Body/Plugins/ArtifactList/Item/style.ts +1 -2
- package/src/features/Setting/SettingContainer.tsx +8 -1
- package/src/features/ShareModal/ShareImage/style.ts +2 -2
- package/src/features/ShareModal/style.ts +2 -2
- package/src/features/User/DataStatistics.tsx +1 -1
- package/src/hooks/useEnabledChatModels.ts +10 -1
- package/src/hooks/useModelSupportToolUse.ts +15 -0
- package/src/hooks/useModelSupportVision.ts +15 -0
- package/src/layout/AuthProvider/Clerk/useAppearance.ts +3 -3
- package/src/layout/GlobalProvider/AppTheme.tsx +1 -1
- package/src/layout/GlobalProvider/StoreInitialization.tsx +5 -0
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/modelProvider.ts +178 -0
- package/src/locales/default/setting.ts +1 -0
- package/src/server/modules/KeyVaultsEncrypt/index.ts +1 -1
- package/src/server/routers/lambda/aiModel.ts +128 -0
- package/src/server/routers/lambda/aiProvider.ts +127 -0
- package/src/server/routers/lambda/index.ts +4 -0
- package/src/services/__tests__/_auth.test.ts +16 -49
- package/src/services/__tests__/chat.test.ts +2 -0
- package/src/services/_auth.ts +42 -25
- package/src/services/aiModel.ts +52 -0
- package/src/services/aiProvider.ts +47 -0
- package/src/services/chat.ts +62 -18
- package/src/store/aiInfra/index.ts +2 -0
- package/src/store/aiInfra/initialState.ts +11 -0
- package/src/store/aiInfra/selectors.ts +2 -0
- package/src/store/aiInfra/slices/aiModel/action.ts +146 -0
- package/src/store/aiInfra/slices/aiModel/index.ts +3 -0
- package/src/store/aiInfra/slices/aiModel/initialState.ts +14 -0
- package/src/store/aiInfra/slices/aiModel/selectors.ts +63 -0
- package/src/store/aiInfra/slices/aiProvider/action.ts +208 -0
- package/src/store/aiInfra/slices/aiProvider/index.ts +3 -0
- package/src/store/aiInfra/slices/aiProvider/initialState.ts +32 -0
- package/src/store/aiInfra/slices/aiProvider/selectors.ts +99 -0
- package/src/store/aiInfra/store.ts +25 -0
- package/src/store/global/initialState.ts +1 -0
- package/src/store/serverConfig/selectors.test.ts +1 -0
- package/src/store/user/slices/modelList/selectors/modelProvider.ts +1 -0
- package/src/styles/global.ts +1 -1
- package/src/types/aiModel.ts +36 -6
- package/src/types/aiProvider.ts +14 -5
- package/src/utils/fetch/fetchSSE.ts +3 -1
@@ -0,0 +1,99 @@
|
|
1
|
+
import { isProviderDisableBroswerRequest } from '@/config/modelProviders';
|
2
|
+
import { AIProviderStoreState } from '@/store/aiInfra/initialState';
|
3
|
+
import { AiProviderRuntimeConfig } from '@/types/aiProvider';
|
4
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
5
|
+
|
6
|
+
// List
|
7
|
+
const enabledAiProviderList = (s: AIProviderStoreState) =>
|
8
|
+
s.aiProviderList.filter((item) => item.enabled).sort((a, b) => a.sort! - b.sort!);
|
9
|
+
|
10
|
+
const disabledAiProviderList = (s: AIProviderStoreState) =>
|
11
|
+
s.aiProviderList.filter((item) => !item.enabled);
|
12
|
+
|
13
|
+
const isProviderEnabled = (id: string) => (s: AIProviderStoreState) =>
|
14
|
+
enabledAiProviderList(s).some((i) => i.id === id);
|
15
|
+
|
16
|
+
const isProviderLoading = (id: string) => (s: AIProviderStoreState) =>
|
17
|
+
s.aiProviderLoadingIds.includes(id);
|
18
|
+
|
19
|
+
const activeProviderConfig = (s: AIProviderStoreState) => s.aiProviderDetail;
|
20
|
+
|
21
|
+
// Detail
|
22
|
+
|
23
|
+
const isAiProviderConfigLoading = (id: string) => (s: AIProviderStoreState) =>
|
24
|
+
s.activeAiProvider !== id;
|
25
|
+
|
26
|
+
const providerWhitelist = new Set(['ollama']);
|
27
|
+
|
28
|
+
const activeProviderKeyVaults = (s: AIProviderStoreState) => activeProviderConfig(s)?.keyVaults;
|
29
|
+
|
30
|
+
const isActiveProviderEndpointNotEmpty = (s: AIProviderStoreState) => {
|
31
|
+
const vault = activeProviderKeyVaults(s);
|
32
|
+
return !!vault?.baseURL || !!vault?.endpoint;
|
33
|
+
};
|
34
|
+
|
35
|
+
const isActiveProviderApiKeyNotEmpty = (s: AIProviderStoreState) => {
|
36
|
+
const vault = activeProviderKeyVaults(s);
|
37
|
+
return !!vault?.apiKey || !!vault?.accessKeyId || !!vault?.secretAccessKey;
|
38
|
+
};
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @description The conditions to enable client fetch
|
42
|
+
* 1. If no baseUrl and apikey input, force on Server.
|
43
|
+
* 2. If only contains baseUrl, force on Client
|
44
|
+
* 3. Follow the user settings.
|
45
|
+
* 4. On Server, by default.
|
46
|
+
*/
|
47
|
+
const isProviderFetchOnClient =
|
48
|
+
(provider: GlobalLLMProviderKey | string) => (s: AIProviderStoreState) => {
|
49
|
+
const config = activeProviderConfig(s);
|
50
|
+
|
51
|
+
// If the provider already disable broswer request in model config, force on Server.
|
52
|
+
if (isProviderDisableBroswerRequest(provider)) return false;
|
53
|
+
|
54
|
+
// If the provider in the whitelist, follow the user settings
|
55
|
+
if (providerWhitelist.has(provider) && typeof config?.fetchOnClient !== 'undefined')
|
56
|
+
return config?.fetchOnClient;
|
57
|
+
|
58
|
+
// 1. If no baseUrl and apikey input, force on Server.
|
59
|
+
const isProviderEndpointNotEmpty = isActiveProviderEndpointNotEmpty(s);
|
60
|
+
const isProviderApiKeyNotEmpty = isActiveProviderApiKeyNotEmpty(s);
|
61
|
+
if (!isProviderEndpointNotEmpty && !isProviderApiKeyNotEmpty) return false;
|
62
|
+
|
63
|
+
// 2. If only contains baseUrl, force on Client
|
64
|
+
if (isProviderEndpointNotEmpty && !isProviderApiKeyNotEmpty) return true;
|
65
|
+
|
66
|
+
// 3. Follow the user settings.
|
67
|
+
if (typeof config?.fetchOnClient !== 'undefined') return config?.fetchOnClient;
|
68
|
+
|
69
|
+
// 4. On Server, by default.
|
70
|
+
return false;
|
71
|
+
};
|
72
|
+
|
73
|
+
const providerKeyVaults = (provider: string | undefined) => (s: AIProviderStoreState) => {
|
74
|
+
if (!provider) return undefined;
|
75
|
+
|
76
|
+
return s.aiProviderRuntimeConfig?.[provider]?.keyVaults;
|
77
|
+
};
|
78
|
+
|
79
|
+
const providerConfigById =
|
80
|
+
(id: string) =>
|
81
|
+
(s: AIProviderStoreState): AiProviderRuntimeConfig | undefined => {
|
82
|
+
if (!id) return undefined;
|
83
|
+
|
84
|
+
return s.aiProviderRuntimeConfig?.[id];
|
85
|
+
};
|
86
|
+
|
87
|
+
export const aiProviderSelectors = {
|
88
|
+
activeProviderConfig,
|
89
|
+
disabledAiProviderList,
|
90
|
+
enabledAiProviderList,
|
91
|
+
isActiveProviderApiKeyNotEmpty,
|
92
|
+
isActiveProviderEndpointNotEmpty,
|
93
|
+
isAiProviderConfigLoading,
|
94
|
+
isProviderEnabled,
|
95
|
+
isProviderFetchOnClient,
|
96
|
+
isProviderLoading,
|
97
|
+
providerConfigById,
|
98
|
+
providerKeyVaults,
|
99
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { shallow } from 'zustand/shallow';
|
2
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
3
|
+
import { StateCreator } from 'zustand/vanilla';
|
4
|
+
|
5
|
+
import { createDevtools } from '../middleware/createDevtools';
|
6
|
+
import { AIProviderStoreState, initialState } from './initialState';
|
7
|
+
import { AiModelAction, createAiModelSlice } from './slices/aiModel';
|
8
|
+
import { AiProviderAction, createAiProviderSlice } from './slices/aiProvider';
|
9
|
+
|
10
|
+
// =============== 聚合 createStoreFn ============ //
|
11
|
+
|
12
|
+
export interface AiInfraStore extends AIProviderStoreState, AiProviderAction, AiModelAction {
|
13
|
+
/* empty */
|
14
|
+
}
|
15
|
+
|
16
|
+
const createStore: StateCreator<AiInfraStore, [['zustand/devtools', never]]> = (...parameters) => ({
|
17
|
+
...initialState,
|
18
|
+
...createAiModelSlice(...parameters),
|
19
|
+
...createAiProviderSlice(...parameters),
|
20
|
+
});
|
21
|
+
|
22
|
+
// =============== 实装 useStore ============ //
|
23
|
+
const devtools = createDevtools('aiInfra');
|
24
|
+
|
25
|
+
export const useAiInfraStore = createWithEqualityFn<AiInfraStore>()(devtools(createStore), shallow);
|
package/src/styles/global.ts
CHANGED
@@ -36,9 +36,9 @@ export default ({ token }: { prefixCls: string; token: Theme }) => css`
|
|
36
36
|
}
|
37
37
|
|
38
38
|
:hover::-webkit-scrollbar-thumb {
|
39
|
+
border: 3px solid transparent;
|
39
40
|
background-color: ${token.colorText};
|
40
41
|
background-clip: content-box;
|
41
|
-
border: 3px solid transparent;
|
42
42
|
}
|
43
43
|
|
44
44
|
::-webkit-scrollbar-track {
|
package/src/types/aiModel.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { AiProviderSourceType } from '@/types/aiProvider';
|
4
|
+
|
3
5
|
export type ModelPriceCurrency = 'CNY' | 'USD';
|
4
6
|
|
5
7
|
export const AiModelSourceEnum = {
|
@@ -16,7 +18,8 @@ export type AiModelType =
|
|
16
18
|
| 'stt'
|
17
19
|
| 'image'
|
18
20
|
| 'text2video'
|
19
|
-
| 'text2music'
|
21
|
+
| 'text2music'
|
22
|
+
| 'realtime';
|
20
23
|
|
21
24
|
export interface ModelAbilities {
|
22
25
|
/**
|
@@ -91,7 +94,7 @@ export interface ChatModelPricing extends BasicModelPricing {
|
|
91
94
|
writeCacheInput?: number;
|
92
95
|
}
|
93
96
|
|
94
|
-
interface AIBaseModelCard {
|
97
|
+
export interface AIBaseModelCard {
|
95
98
|
/**
|
96
99
|
* the context window (or input + output tokens limit)
|
97
100
|
*/
|
@@ -115,6 +118,13 @@ interface AIBaseModelCard {
|
|
115
118
|
releasedAt?: string;
|
116
119
|
}
|
117
120
|
|
121
|
+
export interface AiModelConfig {
|
122
|
+
/**
|
123
|
+
* used in azure and doubao
|
124
|
+
*/
|
125
|
+
deploymentName?: string;
|
126
|
+
}
|
127
|
+
|
118
128
|
export interface AIChatModelCard extends AIBaseModelCard {
|
119
129
|
abilities?: {
|
120
130
|
/**
|
@@ -130,10 +140,7 @@ export interface AIChatModelCard extends AIBaseModelCard {
|
|
130
140
|
*/
|
131
141
|
vision?: boolean;
|
132
142
|
};
|
133
|
-
|
134
|
-
* used in azure and doubao
|
135
|
-
*/
|
136
|
-
deploymentName?: string;
|
143
|
+
config?: AiModelConfig;
|
137
144
|
maxOutput?: number;
|
138
145
|
pricing?: ChatModelPricing;
|
139
146
|
type: 'chat';
|
@@ -221,6 +228,21 @@ export interface AIRealtimeModelCard extends AIBaseModelCard {
|
|
221
228
|
type: 'realtime';
|
222
229
|
}
|
223
230
|
|
231
|
+
export interface AiFullModelCard extends AIBaseModelCard {
|
232
|
+
abilities?: ModelAbilities;
|
233
|
+
contextWindowTokens?: number;
|
234
|
+
displayName?: string;
|
235
|
+
id: string;
|
236
|
+
maxDimension?: number;
|
237
|
+
pricing?: ChatModelPricing;
|
238
|
+
type: AiModelType;
|
239
|
+
}
|
240
|
+
|
241
|
+
export interface LobeDefaultAiModelListItem extends AiFullModelCard {
|
242
|
+
abilities: ModelAbilities;
|
243
|
+
providerId: string;
|
244
|
+
}
|
245
|
+
|
224
246
|
// create
|
225
247
|
export const CreateAiModelSchema = z.object({
|
226
248
|
abilities: AiModelAbilitiesSchema.optional(),
|
@@ -241,6 +263,7 @@ export type CreateAiModelParams = z.infer<typeof CreateAiModelSchema>;
|
|
241
263
|
|
242
264
|
export interface AiProviderModelListItem {
|
243
265
|
abilities?: ModelAbilities;
|
266
|
+
config?: AiModelConfig;
|
244
267
|
contextWindowTokens?: number;
|
245
268
|
displayName?: string;
|
246
269
|
enabled: boolean;
|
@@ -254,6 +277,11 @@ export interface AiProviderModelListItem {
|
|
254
277
|
// Update
|
255
278
|
export const UpdateAiModelSchema = z.object({
|
256
279
|
abilities: AiModelAbilitiesSchema.optional(),
|
280
|
+
config: z
|
281
|
+
.object({
|
282
|
+
deploymentName: z.string().optional(),
|
283
|
+
})
|
284
|
+
.optional(),
|
257
285
|
contextWindowTokens: z.number().optional(),
|
258
286
|
displayName: z.string().optional(),
|
259
287
|
});
|
@@ -286,5 +314,7 @@ interface AiModelForSelect {
|
|
286
314
|
export interface EnabledProviderWithModels {
|
287
315
|
children: AiModelForSelect[];
|
288
316
|
id: string;
|
317
|
+
logo?: string;
|
289
318
|
name: string;
|
319
|
+
source: AiProviderSourceType;
|
290
320
|
}
|
package/src/types/aiProvider.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { AiModelConfig, AiModelType, ModelAbilities } from '@/types/aiModel';
|
4
4
|
import { SmoothingParams } from '@/types/llm';
|
5
5
|
|
6
6
|
export const AiProviderSourceEnum = {
|
@@ -167,7 +167,7 @@ export type UpdateAiProviderParams = z.infer<typeof UpdateAiProviderSchema>;
|
|
167
167
|
|
168
168
|
export const UpdateAiProviderConfigSchema = z.object({
|
169
169
|
checkModel: z.string().optional(),
|
170
|
-
fetchOnClient: z.boolean().optional(),
|
170
|
+
fetchOnClient: z.boolean().nullable().optional(),
|
171
171
|
keyVaults: z.object({}).passthrough().optional(),
|
172
172
|
});
|
173
173
|
|
@@ -182,21 +182,30 @@ export interface AiProviderSortMap {
|
|
182
182
|
|
183
183
|
export interface EnabledProvider {
|
184
184
|
id: string;
|
185
|
+
logo?: string;
|
185
186
|
name?: string;
|
186
|
-
source:
|
187
|
+
source: AiProviderSourceType;
|
187
188
|
}
|
188
189
|
|
189
190
|
export interface EnabledAiModel {
|
190
191
|
abilities: ModelAbilities;
|
192
|
+
config?: AiModelConfig;
|
191
193
|
contextWindowTokens?: number;
|
192
194
|
displayName?: string;
|
193
195
|
id: string;
|
194
196
|
providerId: string;
|
197
|
+
sort?: number;
|
195
198
|
type: AiModelType;
|
196
199
|
}
|
197
200
|
|
198
|
-
export interface
|
201
|
+
export interface AiProviderRuntimeConfig {
|
202
|
+
fetchOnClient?: boolean;
|
203
|
+
keyVaults: Record<string, object>;
|
204
|
+
settings: AiProviderSettings;
|
205
|
+
}
|
206
|
+
|
207
|
+
export interface AiProviderRuntimeState {
|
199
208
|
enabledAiModels: EnabledAiModel[];
|
200
209
|
enabledAiProviders: EnabledProvider[];
|
201
|
-
|
210
|
+
runtimeConfig: Record<string, AiProviderRuntimeConfig>;
|
202
211
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { isObject } from 'lodash-es';
|
2
|
+
|
1
3
|
import { MESSAGE_CANCEL_FLAT } from '@/const/message';
|
2
4
|
import { LOBE_CHAT_OBSERVATION_ID, LOBE_CHAT_TRACE_ID } from '@/const/trace';
|
3
5
|
import { ChatErrorType } from '@/types/fetch';
|
@@ -243,7 +245,7 @@ export const fetchSSE = async (url: string, options: RequestInit & FetchSSEOptio
|
|
243
245
|
const textSmoothing = typeof smoothing === 'boolean' ? smoothing : smoothing?.text;
|
244
246
|
const toolsCallingSmoothing =
|
245
247
|
typeof smoothing === 'boolean' ? smoothing : (smoothing?.toolsCalling ?? true);
|
246
|
-
const smoothingSpeed =
|
248
|
+
const smoothingSpeed = isObject(smoothing) ? smoothing.speed : undefined;
|
247
249
|
|
248
250
|
const textController = createSmoothMessage({
|
249
251
|
onTextUpdate: (delta, text) => {
|