@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,96 @@
|
|
1
|
+
import { Modal, SortableList } from '@lobehub/ui';
|
2
|
+
import { App, Button } from 'antd';
|
3
|
+
import { createStyles } from 'antd-style';
|
4
|
+
import { memo, useState } from 'react';
|
5
|
+
import { useTranslation } from 'react-i18next';
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
7
|
+
|
8
|
+
import { useAiInfraStore } from '@/store/aiInfra';
|
9
|
+
import { AiProviderModelListItem } from '@/types/aiModel';
|
10
|
+
|
11
|
+
import ListItem from './ListItem';
|
12
|
+
|
13
|
+
const useStyles = createStyles(({ css, token }) => ({
|
14
|
+
container: css`
|
15
|
+
height: 36px;
|
16
|
+
padding-inline: 8px;
|
17
|
+
border-radius: ${token.borderRadius}px;
|
18
|
+
transition: background 0.2s ease-in-out;
|
19
|
+
|
20
|
+
&:hover {
|
21
|
+
background: ${token.colorFillTertiary};
|
22
|
+
}
|
23
|
+
`,
|
24
|
+
}));
|
25
|
+
|
26
|
+
interface SortModelModalProps {
|
27
|
+
defaultItems: AiProviderModelListItem[];
|
28
|
+
onCancel: () => void;
|
29
|
+
open: boolean;
|
30
|
+
}
|
31
|
+
const SortModelModal = memo<SortModelModalProps>(({ open, onCancel, defaultItems }) => {
|
32
|
+
const { t } = useTranslation('modelProvider');
|
33
|
+
const { styles } = useStyles();
|
34
|
+
const [providerId, updateAiModelsSort] = useAiInfraStore((s) => [
|
35
|
+
s.activeAiProvider,
|
36
|
+
s.updateAiModelsSort,
|
37
|
+
]);
|
38
|
+
const [loading, setLoading] = useState(false);
|
39
|
+
const { message } = App.useApp();
|
40
|
+
|
41
|
+
const [items, setItems] = useState(defaultItems);
|
42
|
+
return (
|
43
|
+
<Modal
|
44
|
+
allowFullscreen
|
45
|
+
footer={null}
|
46
|
+
onCancel={onCancel}
|
47
|
+
open={open}
|
48
|
+
title={t('sortModal.title')}
|
49
|
+
width={400}
|
50
|
+
>
|
51
|
+
<Flexbox gap={16}>
|
52
|
+
<SortableList
|
53
|
+
items={items}
|
54
|
+
onChange={async (items: AiProviderModelListItem[]) => {
|
55
|
+
setItems(items);
|
56
|
+
}}
|
57
|
+
renderItem={(item: AiProviderModelListItem) => (
|
58
|
+
<SortableList.Item
|
59
|
+
align={'center'}
|
60
|
+
className={styles.container}
|
61
|
+
gap={4}
|
62
|
+
horizontal
|
63
|
+
id={item.id}
|
64
|
+
justify={'space-between'}
|
65
|
+
>
|
66
|
+
<ListItem {...item} />
|
67
|
+
</SortableList.Item>
|
68
|
+
)}
|
69
|
+
/>
|
70
|
+
<Button
|
71
|
+
block
|
72
|
+
loading={loading}
|
73
|
+
onClick={async () => {
|
74
|
+
if (!providerId) return;
|
75
|
+
|
76
|
+
const sortMap = items.map((item, index) => ({
|
77
|
+
id: item.id,
|
78
|
+
sort: index,
|
79
|
+
}));
|
80
|
+
|
81
|
+
setLoading(true);
|
82
|
+
await updateAiModelsSort(providerId, sortMap);
|
83
|
+
setLoading(false);
|
84
|
+
message.success(t('sortModal.success'));
|
85
|
+
onCancel();
|
86
|
+
}}
|
87
|
+
type={'primary'}
|
88
|
+
>
|
89
|
+
{t('sortModal.update')}
|
90
|
+
</Button>
|
91
|
+
</Flexbox>
|
92
|
+
</Modal>
|
93
|
+
);
|
94
|
+
});
|
95
|
+
|
96
|
+
export default SortModelModal;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { ReactNode, Suspense, memo } from 'react';
|
4
|
+
import { Flexbox } from 'react-layout-kit';
|
5
|
+
|
6
|
+
import { useIsMobile } from '@/hooks/useIsMobile';
|
7
|
+
import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
|
8
|
+
|
9
|
+
import DisabledModels from './DisabledModels';
|
10
|
+
import EmptyModels from './EmptyModels';
|
11
|
+
import EnabledModelList from './EnabledModelList';
|
12
|
+
import ModelTitle from './ModelTitle';
|
13
|
+
import SearchResult from './SearchResult';
|
14
|
+
import SkeletonList from './SkeletonList';
|
15
|
+
|
16
|
+
const Content = memo<{ id: string }>(({ id }) => {
|
17
|
+
const [isSearching, isEmpty, useFetchAiProviderModels] = useAiInfraStore((s) => [
|
18
|
+
!!s.modelSearchKeyword,
|
19
|
+
aiModelSelectors.isEmptyAiProviderModelList(s),
|
20
|
+
s.useFetchAiProviderModels,
|
21
|
+
]);
|
22
|
+
|
23
|
+
const { isLoading } = useFetchAiProviderModels(id);
|
24
|
+
|
25
|
+
if (isLoading) return <SkeletonList />;
|
26
|
+
|
27
|
+
if (isSearching) return <SearchResult />;
|
28
|
+
|
29
|
+
return isEmpty ? (
|
30
|
+
<EmptyModels provider={id} />
|
31
|
+
) : (
|
32
|
+
<Flexbox>
|
33
|
+
<EnabledModelList />
|
34
|
+
<DisabledModels />
|
35
|
+
</Flexbox>
|
36
|
+
);
|
37
|
+
});
|
38
|
+
|
39
|
+
interface ModelListProps {
|
40
|
+
id: string;
|
41
|
+
notFoundContent?: ReactNode;
|
42
|
+
placeholder?: string;
|
43
|
+
showAzureDeployName?: boolean;
|
44
|
+
}
|
45
|
+
|
46
|
+
const ModelList = memo<ModelListProps>(({ id }) => {
|
47
|
+
const mobile = useIsMobile();
|
48
|
+
|
49
|
+
return (
|
50
|
+
<Flexbox gap={16} paddingInline={mobile ? 12 : 0}>
|
51
|
+
<ModelTitle provider={id} />
|
52
|
+
<Suspense fallback={<SkeletonList />}>
|
53
|
+
<Content id={id} />
|
54
|
+
</Suspense>
|
55
|
+
</Flexbox>
|
56
|
+
);
|
57
|
+
});
|
58
|
+
|
59
|
+
export default ModelList;
|
@@ -0,0 +1,120 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { CheckCircleFilled } from '@ant-design/icons';
|
4
|
+
import { Alert, Highlighter } from '@lobehub/ui';
|
5
|
+
import { Button } from 'antd';
|
6
|
+
import { useTheme } from 'antd-style';
|
7
|
+
import { memo, useState } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
import { Flexbox } from 'react-layout-kit';
|
10
|
+
|
11
|
+
import { TraceNameMap } from '@/const/trace';
|
12
|
+
import { useIsMobile } from '@/hooks/useIsMobile';
|
13
|
+
import { useProviderName } from '@/hooks/useProviderName';
|
14
|
+
import { chatService } from '@/services/chat';
|
15
|
+
import { ChatMessageError } from '@/types/message';
|
16
|
+
|
17
|
+
interface ConnectionCheckerProps {
|
18
|
+
model: string;
|
19
|
+
provider: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
const Error = memo<{ error: ChatMessageError }>(({ error }) => {
|
23
|
+
const { t } = useTranslation('error');
|
24
|
+
const providerName = useProviderName(error.body?.provider);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
|
28
|
+
<Alert
|
29
|
+
banner
|
30
|
+
extra={
|
31
|
+
<Flexbox>
|
32
|
+
<Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
|
33
|
+
{JSON.stringify(error.body || error, null, 2)}
|
34
|
+
</Highlighter>
|
35
|
+
</Flexbox>
|
36
|
+
}
|
37
|
+
message={t(`response.${error.type}` as any, { provider: providerName })}
|
38
|
+
showIcon
|
39
|
+
type={'error'}
|
40
|
+
/>
|
41
|
+
</Flexbox>
|
42
|
+
);
|
43
|
+
});
|
44
|
+
|
45
|
+
const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
|
46
|
+
const { t } = useTranslation('setting');
|
47
|
+
|
48
|
+
const [loading, setLoading] = useState(false);
|
49
|
+
const [pass, setPass] = useState(false);
|
50
|
+
|
51
|
+
const theme = useTheme();
|
52
|
+
const [error, setError] = useState<ChatMessageError | undefined>();
|
53
|
+
|
54
|
+
const checkConnection = async () => {
|
55
|
+
let isError = false;
|
56
|
+
|
57
|
+
await chatService.fetchPresetTaskResult({
|
58
|
+
onError: (_, rawError) => {
|
59
|
+
setError(rawError);
|
60
|
+
setPass(false);
|
61
|
+
isError = true;
|
62
|
+
},
|
63
|
+
onFinish: async (value) => {
|
64
|
+
if (!isError && value) {
|
65
|
+
setError(undefined);
|
66
|
+
setPass(true);
|
67
|
+
} else {
|
68
|
+
setPass(false);
|
69
|
+
setError({
|
70
|
+
body: value,
|
71
|
+
message: t('response.ConnectionCheckFailed', { ns: 'error' }),
|
72
|
+
type: 'ConnectionCheckFailed',
|
73
|
+
});
|
74
|
+
}
|
75
|
+
},
|
76
|
+
onLoadingChange: (loading) => {
|
77
|
+
setLoading(loading);
|
78
|
+
},
|
79
|
+
params: {
|
80
|
+
messages: [
|
81
|
+
{
|
82
|
+
content: '你好',
|
83
|
+
role: 'user',
|
84
|
+
},
|
85
|
+
],
|
86
|
+
model,
|
87
|
+
provider,
|
88
|
+
},
|
89
|
+
trace: {
|
90
|
+
sessionId: `connection:${provider}`,
|
91
|
+
topicId: model,
|
92
|
+
traceName: TraceNameMap.ConnectivityChecker,
|
93
|
+
},
|
94
|
+
});
|
95
|
+
};
|
96
|
+
const isMobile = useIsMobile();
|
97
|
+
|
98
|
+
return (
|
99
|
+
<Flexbox align={isMobile ? 'flex-start' : 'flex-end'} gap={8}>
|
100
|
+
<Flexbox align={'center'} direction={isMobile ? 'horizontal-reverse' : 'horizontal'} gap={12}>
|
101
|
+
{pass && (
|
102
|
+
<Flexbox gap={4} horizontal>
|
103
|
+
<CheckCircleFilled
|
104
|
+
style={{
|
105
|
+
color: theme.colorSuccess,
|
106
|
+
}}
|
107
|
+
/>
|
108
|
+
{t('llm.checker.pass')}
|
109
|
+
</Flexbox>
|
110
|
+
)}
|
111
|
+
<Button loading={loading} onClick={checkConnection}>
|
112
|
+
{t('llm.checker.button')}
|
113
|
+
</Button>
|
114
|
+
</Flexbox>
|
115
|
+
{error && <Error error={error} />}
|
116
|
+
</Flexbox>
|
117
|
+
);
|
118
|
+
});
|
119
|
+
|
120
|
+
export default Checker;
|
package/src/app/(main)/settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
import { FormModal, Icon } from '@lobehub/ui';
|
2
|
+
import type { FormItemProps } from '@lobehub/ui/es/Form/components/FormItem';
|
3
|
+
import { App, Button, Input } from 'antd';
|
4
|
+
import { BrainIcon } from 'lucide-react';
|
5
|
+
import { useRouter } from 'next/navigation';
|
6
|
+
import { memo, useState } from 'react';
|
7
|
+
import { useTranslation } from 'react-i18next';
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
9
|
+
|
10
|
+
import { useAiInfraStore } from '@/store/aiInfra/store';
|
11
|
+
import { AiProviderDetailItem, UpdateAiProviderParams } from '@/types/aiProvider';
|
12
|
+
|
13
|
+
interface CreateNewProviderProps {
|
14
|
+
id: string;
|
15
|
+
initialValues: AiProviderDetailItem;
|
16
|
+
onClose?: () => void;
|
17
|
+
open?: boolean;
|
18
|
+
}
|
19
|
+
|
20
|
+
const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open, initialValues, id }) => {
|
21
|
+
const { t } = useTranslation(['modelProvider', 'common']);
|
22
|
+
const [loading, setLoading] = useState(false);
|
23
|
+
const [updateAiProvider, deleteAiProvider] = useAiInfraStore((s) => [
|
24
|
+
s.updateAiProvider,
|
25
|
+
s.deleteAiProvider,
|
26
|
+
]);
|
27
|
+
|
28
|
+
const { message, modal } = App.useApp();
|
29
|
+
const router = useRouter();
|
30
|
+
|
31
|
+
const onFinish = async (values: UpdateAiProviderParams) => {
|
32
|
+
setLoading(true);
|
33
|
+
|
34
|
+
try {
|
35
|
+
await updateAiProvider(id, values);
|
36
|
+
setLoading(false);
|
37
|
+
message.success(t('updateAiProvider.updateSuccess'));
|
38
|
+
onClose?.();
|
39
|
+
} catch (e) {
|
40
|
+
console.error(e);
|
41
|
+
setLoading(false);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
const basicItems: FormItemProps[] = [
|
46
|
+
{
|
47
|
+
children: initialValues.id,
|
48
|
+
label: t('createNewAiProvider.id.title'),
|
49
|
+
minWidth: 400,
|
50
|
+
rules: [{ message: t('createNewAiProvider.id.required'), required: true }],
|
51
|
+
},
|
52
|
+
{
|
53
|
+
children: (
|
54
|
+
<Input placeholder={t('createNewAiProvider.name.placeholder')} variant={'filled'} />
|
55
|
+
),
|
56
|
+
label: t('createNewAiProvider.name.title'),
|
57
|
+
minWidth: 400,
|
58
|
+
name: 'name',
|
59
|
+
rules: [{ message: t('createNewAiProvider.name.required'), required: true }],
|
60
|
+
},
|
61
|
+
{
|
62
|
+
children: (
|
63
|
+
<Input.TextArea
|
64
|
+
placeholder={t('createNewAiProvider.description.placeholder')}
|
65
|
+
style={{ minHeight: 80 }}
|
66
|
+
variant={'filled'}
|
67
|
+
/>
|
68
|
+
),
|
69
|
+
label: t('createNewAiProvider.description.title'),
|
70
|
+
minWidth: 400,
|
71
|
+
name: 'description',
|
72
|
+
},
|
73
|
+
{
|
74
|
+
children: <Input allowClear placeholder={'https://logo-url'} variant={'filled'} />,
|
75
|
+
label: t('createNewAiProvider.logo.title'),
|
76
|
+
minWidth: 400,
|
77
|
+
name: 'logo',
|
78
|
+
},
|
79
|
+
];
|
80
|
+
|
81
|
+
return (
|
82
|
+
<FormModal
|
83
|
+
footer={
|
84
|
+
<Flexbox horizontal justify={'space-between'}>
|
85
|
+
<Button
|
86
|
+
danger
|
87
|
+
disabled={loading}
|
88
|
+
onClick={() => {
|
89
|
+
modal.confirm({
|
90
|
+
okButtonProps: {
|
91
|
+
danger: true,
|
92
|
+
},
|
93
|
+
okText: t('delete', { ns: 'common' }),
|
94
|
+
onOk: async () => {
|
95
|
+
await deleteAiProvider(id);
|
96
|
+
router.push('/settings/provider');
|
97
|
+
|
98
|
+
onClose?.();
|
99
|
+
message.success(t('updateAiProvider.deleteSuccess'));
|
100
|
+
},
|
101
|
+
title: t('updateAiProvider.confirmDelete'),
|
102
|
+
});
|
103
|
+
}}
|
104
|
+
type={'primary'}
|
105
|
+
>
|
106
|
+
{t('delete', { ns: 'common' })}
|
107
|
+
</Button>
|
108
|
+
<Flexbox gap={8} horizontal>
|
109
|
+
<Button htmlType={'submit'} loading={loading} type={'primary'}>
|
110
|
+
{t('update', { ns: 'common' })}
|
111
|
+
</Button>
|
112
|
+
</Flexbox>
|
113
|
+
</Flexbox>
|
114
|
+
}
|
115
|
+
initialValues={initialValues}
|
116
|
+
items={[
|
117
|
+
{
|
118
|
+
children: basicItems,
|
119
|
+
title: t('createNewAiProvider.basicTitle'),
|
120
|
+
},
|
121
|
+
]}
|
122
|
+
onCancel={onClose}
|
123
|
+
onFinish={onFinish}
|
124
|
+
open={open}
|
125
|
+
scrollToFirstError={{ behavior: 'instant', block: 'end', focus: true }}
|
126
|
+
submitText={t('createNewAiProvider.confirm')}
|
127
|
+
title={
|
128
|
+
<Flexbox gap={8} horizontal>
|
129
|
+
<Icon icon={BrainIcon} />
|
130
|
+
{t('createNewAiProvider.title')}
|
131
|
+
</Flexbox>
|
132
|
+
}
|
133
|
+
/>
|
134
|
+
);
|
135
|
+
});
|
136
|
+
|
137
|
+
export default CreateNewProvider;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Icon, Tooltip } from '@lobehub/ui';
|
4
|
+
import { Button } from 'antd';
|
5
|
+
import isEqual from 'fast-deep-equal';
|
6
|
+
import { SettingsIcon } from 'lucide-react';
|
7
|
+
import { memo, useState } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
|
10
|
+
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
11
|
+
|
12
|
+
import SettingModal from './SettingModal';
|
13
|
+
|
14
|
+
const UpdateProviderInfo = memo(() => {
|
15
|
+
const { t } = useTranslation('modelProvider');
|
16
|
+
|
17
|
+
const [open, setOpen] = useState(false);
|
18
|
+
const providerConfig = useAiInfraStore(aiProviderSelectors.activeProviderConfig, isEqual);
|
19
|
+
|
20
|
+
return (
|
21
|
+
<>
|
22
|
+
<Tooltip title={t('updateAiProvider.tooltip')}>
|
23
|
+
<Button
|
24
|
+
color={'default'}
|
25
|
+
icon={<Icon icon={SettingsIcon} />}
|
26
|
+
onClick={(e) => {
|
27
|
+
e.preventDefault();
|
28
|
+
e.stopPropagation();
|
29
|
+
setOpen(true);
|
30
|
+
}}
|
31
|
+
size={'small'}
|
32
|
+
variant={'text'}
|
33
|
+
/>
|
34
|
+
</Tooltip>
|
35
|
+
{open && providerConfig && (
|
36
|
+
<SettingModal
|
37
|
+
id={providerConfig.id}
|
38
|
+
initialValues={providerConfig}
|
39
|
+
onClose={() => {
|
40
|
+
setOpen(false);
|
41
|
+
}}
|
42
|
+
open={open}
|
43
|
+
/>
|
44
|
+
)}
|
45
|
+
</>
|
46
|
+
);
|
47
|
+
});
|
48
|
+
|
49
|
+
export default UpdateProviderInfo;
|