@lobehub/chat 1.43.5 → 1.44.0
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/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/(workspace)/_layout/Desktop/index.tsx +6 -1
- 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 +2 -3
- 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 +115 -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 +250 -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/ModelSwitchPanel/index.tsx +2 -2
- 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/styles/global.ts +1 -1
- package/src/types/aiModel.ts +32 -6
- package/src/types/aiProvider.ts +11 -4
- package/src/utils/fetch/fetchSSE.ts +3 -1
@@ -0,0 +1,346 @@
|
|
1
|
+
import { ModelIcon } from '@lobehub/icons';
|
2
|
+
import { ActionIcon, Tag, copyToClipboard } from '@lobehub/ui';
|
3
|
+
import { App, Switch, Typography } from 'antd';
|
4
|
+
import { createStyles, useTheme } from 'antd-style';
|
5
|
+
import { LucidePencil, TrashIcon } from 'lucide-react';
|
6
|
+
import { memo, useState } from 'react';
|
7
|
+
import { useTranslation } from 'react-i18next';
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
9
|
+
|
10
|
+
import { ModelInfoTags } from '@/components/ModelSelect';
|
11
|
+
import { useIsMobile } from '@/hooks/useIsMobile';
|
12
|
+
import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
|
13
|
+
import { AiModelSourceEnum, AiProviderModelListItem, ChatModelPricing } from '@/types/aiModel';
|
14
|
+
|
15
|
+
import ModelConfigModal from './ModelConfigModal';
|
16
|
+
|
17
|
+
const f = (number: number | undefined, text: string) =>
|
18
|
+
typeof number !== 'undefined' ? text : undefined;
|
19
|
+
|
20
|
+
export const useStyles = createStyles(({ css, token, cx }) => {
|
21
|
+
const config = css`
|
22
|
+
opacity: 0;
|
23
|
+
transition: all 100ms ease-in-out;
|
24
|
+
`;
|
25
|
+
|
26
|
+
return {
|
27
|
+
config,
|
28
|
+
container: css`
|
29
|
+
position: relative;
|
30
|
+
border-radius: 12px;
|
31
|
+
transition: all 200ms ease-in-out;
|
32
|
+
|
33
|
+
&:hover {
|
34
|
+
background-color: ${token.colorFillTertiary};
|
35
|
+
|
36
|
+
.${cx(config)} {
|
37
|
+
opacity: 1;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
`,
|
41
|
+
desc: css`
|
42
|
+
flex: 1;
|
43
|
+
min-width: 0;
|
44
|
+
|
45
|
+
span {
|
46
|
+
overflow: hidden;
|
47
|
+
text-overflow: ellipsis;
|
48
|
+
white-space: nowrap;
|
49
|
+
}
|
50
|
+
`,
|
51
|
+
};
|
52
|
+
});
|
53
|
+
|
54
|
+
interface ModelItemProps extends AiProviderModelListItem {
|
55
|
+
enabled: boolean;
|
56
|
+
id: string;
|
57
|
+
isAzure?: boolean;
|
58
|
+
pricing?: ChatModelPricing;
|
59
|
+
releasedAt?: string;
|
60
|
+
removed?: boolean;
|
61
|
+
}
|
62
|
+
|
63
|
+
const ModelItem = memo<ModelItemProps>(
|
64
|
+
({
|
65
|
+
displayName,
|
66
|
+
id,
|
67
|
+
enabled,
|
68
|
+
// removed,
|
69
|
+
releasedAt,
|
70
|
+
pricing,
|
71
|
+
source,
|
72
|
+
contextWindowTokens,
|
73
|
+
abilities,
|
74
|
+
type,
|
75
|
+
}) => {
|
76
|
+
const { styles } = useStyles();
|
77
|
+
const { t } = useTranslation(['modelProvider', 'components', 'models']);
|
78
|
+
const theme = useTheme();
|
79
|
+
|
80
|
+
const [activeAiProvider, isModelLoading, toggleModelEnabled, removeAiModel] = useAiInfraStore(
|
81
|
+
(s) => [
|
82
|
+
s.activeAiProvider,
|
83
|
+
aiModelSelectors.isModelLoading(id)(s),
|
84
|
+
s.toggleModelEnabled,
|
85
|
+
s.removeAiModel,
|
86
|
+
],
|
87
|
+
);
|
88
|
+
|
89
|
+
const [checked, setChecked] = useState(enabled);
|
90
|
+
const [showConfig, setShowConfig] = useState(false);
|
91
|
+
|
92
|
+
const formatPricing = (): string[] => {
|
93
|
+
switch (type) {
|
94
|
+
case 'chat': {
|
95
|
+
return [
|
96
|
+
f(
|
97
|
+
pricing?.input,
|
98
|
+
t('providerModels.item.pricing.inputTokens', { amount: pricing?.input }),
|
99
|
+
),
|
100
|
+
f(
|
101
|
+
pricing?.output,
|
102
|
+
t('providerModels.item.pricing.outputTokens', { amount: pricing?.output }),
|
103
|
+
),
|
104
|
+
].filter(Boolean) as string[];
|
105
|
+
}
|
106
|
+
case 'embedding': {
|
107
|
+
return [
|
108
|
+
f(
|
109
|
+
pricing?.input,
|
110
|
+
t('providerModels.item.pricing.inputTokens', { amount: pricing?.input }),
|
111
|
+
),
|
112
|
+
].filter(Boolean) as string[];
|
113
|
+
}
|
114
|
+
case 'tts': {
|
115
|
+
return [
|
116
|
+
f(
|
117
|
+
pricing?.input,
|
118
|
+
t('providerModels.item.pricing.inputCharts', { amount: pricing?.input }),
|
119
|
+
),
|
120
|
+
].filter(Boolean) as string[];
|
121
|
+
}
|
122
|
+
case 'stt': {
|
123
|
+
return [
|
124
|
+
f(
|
125
|
+
pricing?.input,
|
126
|
+
t('providerModels.item.pricing.inputMinutes', { amount: pricing?.input }),
|
127
|
+
),
|
128
|
+
].filter(Boolean) as string[];
|
129
|
+
}
|
130
|
+
|
131
|
+
case 'image': {
|
132
|
+
return [];
|
133
|
+
}
|
134
|
+
|
135
|
+
default: {
|
136
|
+
return [];
|
137
|
+
}
|
138
|
+
}
|
139
|
+
};
|
140
|
+
|
141
|
+
const content = [
|
142
|
+
releasedAt && t('providerModels.item.releasedAt', { releasedAt }),
|
143
|
+
...formatPricing(),
|
144
|
+
].filter(Boolean) as string[];
|
145
|
+
const { message, modal } = App.useApp();
|
146
|
+
|
147
|
+
const isMobile = useIsMobile();
|
148
|
+
|
149
|
+
const dom = isMobile ? (
|
150
|
+
<Flexbox
|
151
|
+
align={'center'}
|
152
|
+
gap={12}
|
153
|
+
horizontal
|
154
|
+
justify={'space-between'}
|
155
|
+
padding={'12px 6px'}
|
156
|
+
width={'100%'}
|
157
|
+
>
|
158
|
+
<Flexbox align={'center'} flex={1} gap={16} horizontal style={{ minWidth: 0 }}>
|
159
|
+
<ModelIcon model={id} size={32} />
|
160
|
+
<Flexbox flex={1} gap={4} style={{ minWidth: 0 }}>
|
161
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
162
|
+
{displayName || id}
|
163
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
164
|
+
<ModelInfoTags
|
165
|
+
placement={'top'}
|
166
|
+
{...abilities}
|
167
|
+
contextWindowTokens={contextWindowTokens}
|
168
|
+
/>
|
169
|
+
{/*{removed && (*/}
|
170
|
+
{/* <Tooltip*/}
|
171
|
+
{/* overlayStyle={{ maxWidth: 300 }}*/}
|
172
|
+
{/* placement={'top'}*/}
|
173
|
+
{/* style={{ pointerEvents: 'none' }}*/}
|
174
|
+
{/* title={t('ModelSelect.removed')}*/}
|
175
|
+
{/* >*/}
|
176
|
+
{/* <ActionIcon icon={Recycle} style={{ color: theme.colorWarning }} />*/}
|
177
|
+
{/* </Tooltip>*/}
|
178
|
+
{/*)}*/}
|
179
|
+
</Flexbox>
|
180
|
+
</Flexbox>
|
181
|
+
<div>
|
182
|
+
<Tag
|
183
|
+
onClick={() => {
|
184
|
+
copyToClipboard(id);
|
185
|
+
}}
|
186
|
+
style={{ cursor: 'pointer', marginRight: 0 }}
|
187
|
+
>
|
188
|
+
{id}
|
189
|
+
</Tag>
|
190
|
+
</div>
|
191
|
+
</Flexbox>
|
192
|
+
</Flexbox>
|
193
|
+
<Flexbox align={'center'} gap={4} horizontal>
|
194
|
+
<Flexbox className={styles.config} horizontal style={{ opacity: 1 }}>
|
195
|
+
<ActionIcon
|
196
|
+
icon={LucidePencil}
|
197
|
+
onClick={(e) => {
|
198
|
+
e.stopPropagation();
|
199
|
+
setShowConfig(true);
|
200
|
+
}}
|
201
|
+
size={'small'}
|
202
|
+
title={t('providerModels.item.config')}
|
203
|
+
/>
|
204
|
+
{source !== AiModelSourceEnum.Builtin && (
|
205
|
+
<ActionIcon
|
206
|
+
icon={TrashIcon}
|
207
|
+
onClick={() => {
|
208
|
+
modal.confirm({
|
209
|
+
centered: true,
|
210
|
+
okButtonProps: {
|
211
|
+
danger: true,
|
212
|
+
type: 'primary',
|
213
|
+
},
|
214
|
+
onOk: async () => {
|
215
|
+
await removeAiModel(id, activeAiProvider!);
|
216
|
+
message.success(t('providerModels.item.delete.success'));
|
217
|
+
},
|
218
|
+
title: t('providerModels.item.delete.confirm', {
|
219
|
+
displayName: displayName || id,
|
220
|
+
}),
|
221
|
+
});
|
222
|
+
}}
|
223
|
+
size={'small'}
|
224
|
+
title={t('providerModels.item.delete.title')}
|
225
|
+
/>
|
226
|
+
)}
|
227
|
+
</Flexbox>
|
228
|
+
<Switch
|
229
|
+
checked={checked}
|
230
|
+
loading={isModelLoading}
|
231
|
+
onChange={async (e) => {
|
232
|
+
setChecked(e);
|
233
|
+
await toggleModelEnabled({ enabled: e, id, source });
|
234
|
+
}}
|
235
|
+
size={'small'}
|
236
|
+
/>
|
237
|
+
</Flexbox>
|
238
|
+
</Flexbox>
|
239
|
+
) : (
|
240
|
+
<Flexbox
|
241
|
+
align={'center'}
|
242
|
+
className={styles.container}
|
243
|
+
gap={24}
|
244
|
+
horizontal
|
245
|
+
justify={'space-between'}
|
246
|
+
padding={12}
|
247
|
+
width={'100%'}
|
248
|
+
>
|
249
|
+
<Flexbox align={'center'} flex={1} gap={8} horizontal style={{ minWidth: 0 }}>
|
250
|
+
<ModelIcon model={id} size={32} />
|
251
|
+
<Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
|
252
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
253
|
+
{displayName || id}
|
254
|
+
<Tag
|
255
|
+
onClick={() => {
|
256
|
+
copyToClipboard(id);
|
257
|
+
}}
|
258
|
+
style={{ cursor: 'pointer', marginRight: 0 }}
|
259
|
+
>
|
260
|
+
{id}
|
261
|
+
</Tag>
|
262
|
+
<Flexbox className={styles.config} horizontal>
|
263
|
+
<ActionIcon
|
264
|
+
icon={LucidePencil}
|
265
|
+
onClick={(e) => {
|
266
|
+
e.stopPropagation();
|
267
|
+
setShowConfig(true);
|
268
|
+
}}
|
269
|
+
size={'small'}
|
270
|
+
title={t('providerModels.item.config')}
|
271
|
+
/>
|
272
|
+
{source !== AiModelSourceEnum.Builtin && (
|
273
|
+
<ActionIcon
|
274
|
+
icon={TrashIcon}
|
275
|
+
onClick={() => {
|
276
|
+
modal.confirm({
|
277
|
+
centered: true,
|
278
|
+
okButtonProps: {
|
279
|
+
danger: true,
|
280
|
+
type: 'primary',
|
281
|
+
},
|
282
|
+
onOk: async () => {
|
283
|
+
await removeAiModel(id, activeAiProvider!);
|
284
|
+
message.success(t('providerModels.item.delete.success'));
|
285
|
+
},
|
286
|
+
title: t('providerModels.item.delete.confirm', {
|
287
|
+
displayName: displayName || id,
|
288
|
+
}),
|
289
|
+
});
|
290
|
+
}}
|
291
|
+
size={'small'}
|
292
|
+
title={t('providerModels.item.delete.title')}
|
293
|
+
/>
|
294
|
+
)}
|
295
|
+
</Flexbox>
|
296
|
+
</Flexbox>
|
297
|
+
<Flexbox align={'baseline'} gap={8} horizontal>
|
298
|
+
{content.length > 0 && (
|
299
|
+
<Typography.Text
|
300
|
+
style={{ color: theme.colorTextSecondary, fontSize: 12, marginBottom: 0 }}
|
301
|
+
>
|
302
|
+
{content.join(' · ')}
|
303
|
+
</Typography.Text>
|
304
|
+
)}
|
305
|
+
</Flexbox>
|
306
|
+
</Flexbox>
|
307
|
+
</Flexbox>
|
308
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
309
|
+
<ModelInfoTags
|
310
|
+
placement={'top'}
|
311
|
+
{...abilities}
|
312
|
+
contextWindowTokens={contextWindowTokens}
|
313
|
+
/>
|
314
|
+
{/*{removed && (*/}
|
315
|
+
{/* <Tooltip*/}
|
316
|
+
{/* overlayStyle={{ maxWidth: 300 }}*/}
|
317
|
+
{/* placement={'top'}*/}
|
318
|
+
{/* style={{ pointerEvents: 'none' }}*/}
|
319
|
+
{/* title={t('ModelSelect.removed')}*/}
|
320
|
+
{/* >*/}
|
321
|
+
{/* <ActionIcon icon={Recycle} style={{ color: theme.colorWarning }} />*/}
|
322
|
+
{/* </Tooltip>*/}
|
323
|
+
{/*)}*/}
|
324
|
+
<Switch
|
325
|
+
checked={checked}
|
326
|
+
loading={isModelLoading}
|
327
|
+
onChange={async (e) => {
|
328
|
+
setChecked(e);
|
329
|
+
await toggleModelEnabled({ enabled: e, id, source });
|
330
|
+
}}
|
331
|
+
size={'small'}
|
332
|
+
/>
|
333
|
+
</Flexbox>
|
334
|
+
</Flexbox>
|
335
|
+
);
|
336
|
+
|
337
|
+
return (
|
338
|
+
<>
|
339
|
+
{dom}
|
340
|
+
{showConfig && <ModelConfigModal id={id} open={showConfig} setOpen={setShowConfig} />}
|
341
|
+
</>
|
342
|
+
);
|
343
|
+
},
|
344
|
+
);
|
345
|
+
|
346
|
+
export default ModelItem;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Icon } from '@lobehub/ui';
|
2
|
+
import { Input, InputProps } from 'antd';
|
3
|
+
import { SearchIcon } from 'lucide-react';
|
4
|
+
import { memo, useState } from 'react';
|
5
|
+
import { useTranslation } from 'react-i18next';
|
6
|
+
|
7
|
+
interface SearchProps {
|
8
|
+
onChange: (value: string) => void;
|
9
|
+
value: string;
|
10
|
+
variant?: InputProps['variant'];
|
11
|
+
}
|
12
|
+
|
13
|
+
const Search = memo<SearchProps>(({ value, onChange, variant }) => {
|
14
|
+
const { t } = useTranslation('modelProvider');
|
15
|
+
const [keyword, setValue] = useState<string>(value);
|
16
|
+
|
17
|
+
return (
|
18
|
+
<Input
|
19
|
+
allowClear
|
20
|
+
onBlur={() => {
|
21
|
+
onChange(keyword);
|
22
|
+
}}
|
23
|
+
onChange={(e) => {
|
24
|
+
setValue(e.target.value);
|
25
|
+
}}
|
26
|
+
onPressEnter={() => {
|
27
|
+
onChange(keyword);
|
28
|
+
}}
|
29
|
+
placeholder={t('providerModels.list.search')}
|
30
|
+
prefix={<Icon icon={SearchIcon} />}
|
31
|
+
size={'small'}
|
32
|
+
value={keyword}
|
33
|
+
variant={variant}
|
34
|
+
/>
|
35
|
+
);
|
36
|
+
});
|
37
|
+
export default Search;
|
@@ -0,0 +1,145 @@
|
|
1
|
+
import { ActionIcon, Icon } from '@lobehub/ui';
|
2
|
+
import { Button, Skeleton, Space, Typography } from 'antd';
|
3
|
+
import { useTheme } from 'antd-style';
|
4
|
+
import { CircleX, LucideRefreshCcwDot, PlusIcon } from 'lucide-react';
|
5
|
+
import { memo, useState } from 'react';
|
6
|
+
import { useTranslation } from 'react-i18next';
|
7
|
+
import { Flexbox } from 'react-layout-kit';
|
8
|
+
|
9
|
+
import { useIsMobile } from '@/hooks/useIsMobile';
|
10
|
+
import { useAiInfraStore } from '@/store/aiInfra';
|
11
|
+
import { aiModelSelectors } from '@/store/aiInfra/selectors';
|
12
|
+
|
13
|
+
import CreateNewModelModal from '../CreateNewModelModal';
|
14
|
+
import Search from './Search';
|
15
|
+
|
16
|
+
interface ModelFetcherProps {
|
17
|
+
provider: string;
|
18
|
+
}
|
19
|
+
|
20
|
+
const ModelTitle = memo<ModelFetcherProps>(({ provider }) => {
|
21
|
+
const theme = useTheme();
|
22
|
+
const { t } = useTranslation('modelProvider');
|
23
|
+
const [
|
24
|
+
searchKeyword,
|
25
|
+
totalModels,
|
26
|
+
isEmpty,
|
27
|
+
hasRemoteModels,
|
28
|
+
fetchRemoteModelList,
|
29
|
+
clearObtainedModels,
|
30
|
+
useFetchAiProviderModels,
|
31
|
+
] = useAiInfraStore((s) => [
|
32
|
+
s.modelSearchKeyword,
|
33
|
+
aiModelSelectors.totalAiProviderModelList(s),
|
34
|
+
aiModelSelectors.isEmptyAiProviderModelList(s),
|
35
|
+
aiModelSelectors.hasRemoteModels(s),
|
36
|
+
s.fetchRemoteModelList,
|
37
|
+
s.clearRemoteModels,
|
38
|
+
s.useFetchAiProviderModels,
|
39
|
+
]);
|
40
|
+
|
41
|
+
const { isLoading } = useFetchAiProviderModels(provider);
|
42
|
+
|
43
|
+
const [fetchRemoteModelsLoading, setFetchRemoteModelsLoading] = useState(false);
|
44
|
+
const [clearRemoteModelsLoading, setClearRemoteModelsLoading] = useState(false);
|
45
|
+
const [showModal, setShowModal] = useState(false);
|
46
|
+
|
47
|
+
const mobile = useIsMobile();
|
48
|
+
|
49
|
+
return (
|
50
|
+
<Flexbox
|
51
|
+
gap={12}
|
52
|
+
paddingBlock={8}
|
53
|
+
style={{
|
54
|
+
background: theme.colorBgLayout,
|
55
|
+
position: 'sticky',
|
56
|
+
top: mobile ? -2 : -16,
|
57
|
+
zIndex: 15,
|
58
|
+
}}
|
59
|
+
>
|
60
|
+
<Flexbox align={'center'} gap={0} horizontal justify={'space-between'}>
|
61
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
62
|
+
<Typography.Text style={{ fontSize: 16, fontWeight: 'bold' }}>
|
63
|
+
{t('providerModels.list.title')}
|
64
|
+
</Typography.Text>
|
65
|
+
|
66
|
+
{isLoading ? (
|
67
|
+
<Skeleton.Button active style={{ height: 22 }} />
|
68
|
+
) : (
|
69
|
+
<Typography.Text style={{ fontSize: 12 }} type={'secondary'}>
|
70
|
+
<div style={{ display: 'flex', lineHeight: '24px' }}>
|
71
|
+
{t('providerModels.list.total', { count: totalModels })}
|
72
|
+
{hasRemoteModels && (
|
73
|
+
<ActionIcon
|
74
|
+
icon={CircleX}
|
75
|
+
loading={clearRemoteModelsLoading}
|
76
|
+
onClick={async () => {
|
77
|
+
setClearRemoteModelsLoading(true);
|
78
|
+
await clearObtainedModels(provider);
|
79
|
+
setClearRemoteModelsLoading(false);
|
80
|
+
}}
|
81
|
+
size={'small'}
|
82
|
+
title={t('providerModels.list.fetcher.clear')}
|
83
|
+
/>
|
84
|
+
)}
|
85
|
+
</div>
|
86
|
+
</Typography.Text>
|
87
|
+
)}
|
88
|
+
</Flexbox>
|
89
|
+
{isLoading ? (
|
90
|
+
<Skeleton.Button active size={'small'} style={{ width: 120 }} />
|
91
|
+
) : isEmpty ? null : (
|
92
|
+
<Flexbox gap={8} horizontal>
|
93
|
+
{!mobile && (
|
94
|
+
<Search
|
95
|
+
onChange={(value) => {
|
96
|
+
useAiInfraStore.setState({ modelSearchKeyword: value });
|
97
|
+
}}
|
98
|
+
value={searchKeyword}
|
99
|
+
/>
|
100
|
+
)}
|
101
|
+
<Space.Compact>
|
102
|
+
<Button
|
103
|
+
icon={<Icon icon={LucideRefreshCcwDot} />}
|
104
|
+
loading={fetchRemoteModelsLoading}
|
105
|
+
onClick={async () => {
|
106
|
+
setFetchRemoteModelsLoading(true);
|
107
|
+
try {
|
108
|
+
await fetchRemoteModelList(provider);
|
109
|
+
} catch (e) {
|
110
|
+
console.error(e);
|
111
|
+
}
|
112
|
+
setFetchRemoteModelsLoading(false);
|
113
|
+
}}
|
114
|
+
size={'small'}
|
115
|
+
>
|
116
|
+
{fetchRemoteModelsLoading
|
117
|
+
? t('providerModels.list.fetcher.fetching')
|
118
|
+
: t('providerModels.list.fetcher.fetch')}
|
119
|
+
</Button>
|
120
|
+
<Button
|
121
|
+
icon={<Icon icon={PlusIcon} />}
|
122
|
+
onClick={() => {
|
123
|
+
setShowModal(true);
|
124
|
+
}}
|
125
|
+
size={'small'}
|
126
|
+
/>
|
127
|
+
<CreateNewModelModal open={showModal} setOpen={setShowModal} />
|
128
|
+
</Space.Compact>
|
129
|
+
</Flexbox>
|
130
|
+
)}
|
131
|
+
</Flexbox>
|
132
|
+
|
133
|
+
{mobile && (
|
134
|
+
<Search
|
135
|
+
onChange={(value) => {
|
136
|
+
useAiInfraStore.setState({ modelSearchKeyword: value });
|
137
|
+
}}
|
138
|
+
value={searchKeyword}
|
139
|
+
variant={'filled'}
|
140
|
+
/>
|
141
|
+
)}
|
142
|
+
</Flexbox>
|
143
|
+
);
|
144
|
+
});
|
145
|
+
export default ModelTitle;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { ActionIcon } from '@lobehub/ui';
|
4
|
+
import { Typography } from 'antd';
|
5
|
+
import isEqual from 'fast-deep-equal';
|
6
|
+
import { ToggleRightIcon } from 'lucide-react';
|
7
|
+
import { memo, useState } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
import { Flexbox } from 'react-layout-kit';
|
10
|
+
|
11
|
+
import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
|
12
|
+
|
13
|
+
import ModelItem from './ModelItem';
|
14
|
+
|
15
|
+
const SearchResult = memo(() => {
|
16
|
+
const { t } = useTranslation('modelProvider');
|
17
|
+
|
18
|
+
const searchKeyword = useAiInfraStore((s) => s.modelSearchKeyword);
|
19
|
+
const batchToggleAiModels = useAiInfraStore((s) => s.batchToggleAiModels);
|
20
|
+
|
21
|
+
const filteredModels = useAiInfraStore(aiModelSelectors.filteredAiProviderModelList, isEqual);
|
22
|
+
console.log('filteredModels:', filteredModels);
|
23
|
+
const [batchLoading, setBatchLoading] = useState(false);
|
24
|
+
|
25
|
+
const isEmpty = filteredModels.length === 0;
|
26
|
+
return (
|
27
|
+
<>
|
28
|
+
<Flexbox horizontal justify={'space-between'}>
|
29
|
+
<Typography.Text style={{ fontSize: 12, marginTop: 8 }} type={'secondary'}>
|
30
|
+
{t('providerModels.list.searchResult', { count: filteredModels.length })}
|
31
|
+
</Typography.Text>
|
32
|
+
{!isEmpty && (
|
33
|
+
<Flexbox horizontal>
|
34
|
+
<ActionIcon
|
35
|
+
icon={ToggleRightIcon}
|
36
|
+
loading={batchLoading}
|
37
|
+
onClick={async () => {
|
38
|
+
setBatchLoading(true);
|
39
|
+
await batchToggleAiModels(
|
40
|
+
filteredModels.map((i) => i.id),
|
41
|
+
true,
|
42
|
+
);
|
43
|
+
setBatchLoading(false);
|
44
|
+
}}
|
45
|
+
size={'small'}
|
46
|
+
title={t('providerModels.list.enabledActions.enableAll')}
|
47
|
+
/>
|
48
|
+
</Flexbox>
|
49
|
+
)}
|
50
|
+
</Flexbox>
|
51
|
+
|
52
|
+
{searchKeyword && isEmpty ? (
|
53
|
+
<Flexbox align="center" justify="center" padding={16}>
|
54
|
+
{t('providerModels.searchNotFound')}
|
55
|
+
</Flexbox>
|
56
|
+
) : (
|
57
|
+
<Flexbox gap={4}>
|
58
|
+
{filteredModels.map((item) => (
|
59
|
+
<ModelItem {...item} key={`${item.id}-${item.enabled}`} />
|
60
|
+
))}
|
61
|
+
</Flexbox>
|
62
|
+
)}
|
63
|
+
</>
|
64
|
+
);
|
65
|
+
});
|
66
|
+
|
67
|
+
export default SearchResult;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Skeleton } from 'antd';
|
4
|
+
import { createStyles } from 'antd-style';
|
5
|
+
import { memo } from 'react';
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
7
|
+
|
8
|
+
const useStyles = createStyles(({ css, prefixCls }) => ({
|
9
|
+
avatar: css`
|
10
|
+
width: 32px !important;
|
11
|
+
height: 32px !important;
|
12
|
+
`,
|
13
|
+
container: css`
|
14
|
+
display: flex;
|
15
|
+
align-items: center;
|
16
|
+
justify-content: center;
|
17
|
+
|
18
|
+
height: 56px;
|
19
|
+
padding: 12px;
|
20
|
+
|
21
|
+
.${prefixCls}-skeleton-content {
|
22
|
+
display: flex;
|
23
|
+
flex-direction: column;
|
24
|
+
}
|
25
|
+
`,
|
26
|
+
paragraph: css`
|
27
|
+
> li {
|
28
|
+
height: 22px !important;
|
29
|
+
}
|
30
|
+
`,
|
31
|
+
}));
|
32
|
+
|
33
|
+
export const Placeholder = memo(() => {
|
34
|
+
const { styles } = useStyles();
|
35
|
+
|
36
|
+
return (
|
37
|
+
<Flexbox align={'center'} horizontal justify={'space-between'}>
|
38
|
+
<Skeleton
|
39
|
+
active
|
40
|
+
avatar={{ className: styles.avatar }}
|
41
|
+
className={styles.container}
|
42
|
+
paragraph={{
|
43
|
+
className: styles.paragraph,
|
44
|
+
rows: 1,
|
45
|
+
style: { marginBottom: 0 },
|
46
|
+
width: '40%',
|
47
|
+
}}
|
48
|
+
title={false}
|
49
|
+
/>
|
50
|
+
<Skeleton.Button active size={'small'} />
|
51
|
+
</Flexbox>
|
52
|
+
);
|
53
|
+
});
|
54
|
+
|
55
|
+
export const SkeletonList = memo(() => (
|
56
|
+
<Flexbox gap={4} style={{ paddingTop: 26 }}>
|
57
|
+
{Array.from({ length: 6 }).map((_, i) => (
|
58
|
+
<Placeholder key={i} />
|
59
|
+
))}
|
60
|
+
</Flexbox>
|
61
|
+
));
|
62
|
+
|
63
|
+
export default SkeletonList;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { ModelIcon } from '@lobehub/icons';
|
2
|
+
import { SortableList } from '@lobehub/ui';
|
3
|
+
import { memo } from 'react';
|
4
|
+
import { Flexbox } from 'react-layout-kit';
|
5
|
+
|
6
|
+
import { AiProviderModelListItem } from '@/types/aiModel';
|
7
|
+
|
8
|
+
const ListItem = memo<AiProviderModelListItem>(({ id, displayName }) => {
|
9
|
+
return (
|
10
|
+
<>
|
11
|
+
<Flexbox gap={8} horizontal>
|
12
|
+
<ModelIcon model={id} size={24} type={'avatar'} />
|
13
|
+
{displayName || id}
|
14
|
+
</Flexbox>
|
15
|
+
<SortableList.DragHandle />
|
16
|
+
</>
|
17
|
+
);
|
18
|
+
});
|
19
|
+
|
20
|
+
export default ListItem;
|