@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,67 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Markdown } from '@lobehub/ui';
|
4
|
+
import { Input } from 'antd';
|
5
|
+
import { createStyles } from 'antd-style';
|
6
|
+
import { useTranslation } from 'react-i18next';
|
7
|
+
|
8
|
+
import { HuggingFaceProviderCard } from '@/config/modelProviders';
|
9
|
+
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
10
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
11
|
+
|
12
|
+
import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
|
13
|
+
import { SkeletonInput } from '../../features/ProviderConfig';
|
14
|
+
import { ProviderItem } from '../../type';
|
15
|
+
import ProviderDetail from '../[id]';
|
16
|
+
|
17
|
+
const useStyles = createStyles(({ css, token }) => ({
|
18
|
+
markdown: css`
|
19
|
+
p {
|
20
|
+
color: ${token.colorTextDescription} !important;
|
21
|
+
}
|
22
|
+
`,
|
23
|
+
tip: css`
|
24
|
+
font-size: 12px;
|
25
|
+
color: ${token.colorTextDescription};
|
26
|
+
`,
|
27
|
+
}));
|
28
|
+
|
29
|
+
const providerKey: GlobalLLMProviderKey = 'huggingface';
|
30
|
+
|
31
|
+
// Same as OpenAIProvider, but replace API Key with HuggingFace Access Token
|
32
|
+
const useProviderCard = (): ProviderItem => {
|
33
|
+
const { t } = useTranslation('modelProvider');
|
34
|
+
const { styles } = useStyles();
|
35
|
+
const isLoading = useAiInfraStore(aiProviderSelectors.isAiProviderConfigLoading(providerKey));
|
36
|
+
|
37
|
+
return {
|
38
|
+
...HuggingFaceProviderCard,
|
39
|
+
apiKeyItems: [
|
40
|
+
{
|
41
|
+
children: isLoading ? (
|
42
|
+
<SkeletonInput />
|
43
|
+
) : (
|
44
|
+
<Input.Password
|
45
|
+
autoComplete={'new-password'}
|
46
|
+
placeholder={t(`${providerKey}.accessToken.placeholder`)}
|
47
|
+
/>
|
48
|
+
),
|
49
|
+
desc: (
|
50
|
+
<Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
|
51
|
+
{t(`${providerKey}.accessToken.desc`)}
|
52
|
+
</Markdown>
|
53
|
+
),
|
54
|
+
label: t(`${providerKey}.accessToken.title`),
|
55
|
+
name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
|
56
|
+
},
|
57
|
+
],
|
58
|
+
};
|
59
|
+
};
|
60
|
+
|
61
|
+
const Page = () => {
|
62
|
+
const card = useProviderCard();
|
63
|
+
|
64
|
+
return <ProviderDetail {...card} />;
|
65
|
+
};
|
66
|
+
|
67
|
+
export default Page;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { CheckCircleFilled } from '@ant-design/icons';
|
2
|
+
import { Alert, Highlighter } from '@lobehub/ui';
|
3
|
+
import { Button } from 'antd';
|
4
|
+
import { useTheme } from 'antd-style';
|
5
|
+
import { ListResponse } from 'ollama/browser';
|
6
|
+
import { memo } from 'react';
|
7
|
+
import { useTranslation } from 'react-i18next';
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
9
|
+
import useSWR from 'swr';
|
10
|
+
|
11
|
+
import { useIsMobile } from '@/hooks/useIsMobile';
|
12
|
+
import { ollamaService } from '@/services/ollama';
|
13
|
+
|
14
|
+
const OllamaChecker = memo(() => {
|
15
|
+
const { t } = useTranslation('setting');
|
16
|
+
|
17
|
+
const theme = useTheme();
|
18
|
+
|
19
|
+
const { data, error, isLoading, mutate } = useSWR<ListResponse>(
|
20
|
+
'ollama.list',
|
21
|
+
ollamaService.getModels,
|
22
|
+
{
|
23
|
+
revalidateOnFocus: false,
|
24
|
+
revalidateOnMount: false,
|
25
|
+
revalidateOnReconnect: false,
|
26
|
+
},
|
27
|
+
);
|
28
|
+
|
29
|
+
const checkConnection = () => {
|
30
|
+
mutate().catch();
|
31
|
+
};
|
32
|
+
|
33
|
+
const isMobile = useIsMobile();
|
34
|
+
|
35
|
+
return (
|
36
|
+
<Flexbox align={isMobile ? 'flex-start' : 'flex-end'} gap={8}>
|
37
|
+
<Flexbox align={'center'} direction={isMobile ? 'horizontal-reverse' : 'horizontal'} gap={12}>
|
38
|
+
{!error && data?.models && (
|
39
|
+
<Flexbox gap={4} horizontal>
|
40
|
+
<CheckCircleFilled
|
41
|
+
style={{
|
42
|
+
color: theme.colorSuccess,
|
43
|
+
}}
|
44
|
+
/>
|
45
|
+
{t('llm.checker.pass')}
|
46
|
+
</Flexbox>
|
47
|
+
)}
|
48
|
+
<Button loading={isLoading} onClick={checkConnection}>
|
49
|
+
{t('llm.checker.button')}
|
50
|
+
</Button>
|
51
|
+
</Flexbox>
|
52
|
+
{error && (
|
53
|
+
<Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
|
54
|
+
<Alert
|
55
|
+
banner
|
56
|
+
extra={
|
57
|
+
<Flexbox>
|
58
|
+
<Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
|
59
|
+
{JSON.stringify(error.body || error, null, 2)}
|
60
|
+
</Highlighter>
|
61
|
+
</Flexbox>
|
62
|
+
}
|
63
|
+
message={t(`response.${error.type}` as any, { ns: 'error' })}
|
64
|
+
showIcon
|
65
|
+
type={'error'}
|
66
|
+
/>
|
67
|
+
</Flexbox>
|
68
|
+
)}
|
69
|
+
</Flexbox>
|
70
|
+
);
|
71
|
+
});
|
72
|
+
|
73
|
+
export default OllamaChecker;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { useTranslation } from 'react-i18next';
|
4
|
+
|
5
|
+
import { OllamaProviderCard } from '@/config/modelProviders';
|
6
|
+
|
7
|
+
import ProviderDetail from '../[id]';
|
8
|
+
import Checker from './Checker';
|
9
|
+
|
10
|
+
const Page = () => {
|
11
|
+
const { t } = useTranslation('modelProvider');
|
12
|
+
|
13
|
+
return (
|
14
|
+
<ProviderDetail
|
15
|
+
{...OllamaProviderCard}
|
16
|
+
checkerItem={{
|
17
|
+
children: <Checker />,
|
18
|
+
desc: t('ollama.checker.desc'),
|
19
|
+
label: t('ollama.checker.title'),
|
20
|
+
minWidth: undefined,
|
21
|
+
}}
|
22
|
+
settings={{
|
23
|
+
...OllamaProviderCard.settings,
|
24
|
+
proxyUrl: {
|
25
|
+
desc: t('ollama.endpoint.desc'),
|
26
|
+
placeholder: 'http://127.0.0.1:11434',
|
27
|
+
title: t('ollama.endpoint.title'),
|
28
|
+
},
|
29
|
+
}}
|
30
|
+
/>
|
31
|
+
);
|
32
|
+
};
|
33
|
+
|
34
|
+
export default Page;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { serverFeatureFlags } from '@/config/featureFlags';
|
2
|
+
import { OpenAIProviderCard } from '@/config/modelProviders';
|
3
|
+
|
4
|
+
import ProviderDetail from '../[id]';
|
5
|
+
|
6
|
+
const Page = async () => {
|
7
|
+
const { showOpenAIProxyUrl, showOpenAIApiKey } = serverFeatureFlags();
|
8
|
+
|
9
|
+
return (
|
10
|
+
<ProviderDetail
|
11
|
+
{...OpenAIProviderCard}
|
12
|
+
settings={{
|
13
|
+
...OpenAIProviderCard.settings,
|
14
|
+
proxyUrl: showOpenAIProxyUrl && {
|
15
|
+
placeholder: 'https://api.openai.com/v1',
|
16
|
+
},
|
17
|
+
showApiKey: showOpenAIApiKey,
|
18
|
+
}}
|
19
|
+
/>
|
20
|
+
);
|
21
|
+
};
|
22
|
+
|
23
|
+
export default Page;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Input } from 'antd';
|
4
|
+
import { useTranslation } from 'react-i18next';
|
5
|
+
|
6
|
+
import { WenxinProviderCard } from '@/config/modelProviders';
|
7
|
+
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
8
|
+
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
9
|
+
|
10
|
+
import { KeyVaultsConfigKey } from '../../const';
|
11
|
+
import { SkeletonInput } from '../../features/ProviderConfig';
|
12
|
+
import { ProviderItem } from '../../type';
|
13
|
+
import ProviderDetail from '../[id]';
|
14
|
+
|
15
|
+
const providerKey: GlobalLLMProviderKey = 'wenxin';
|
16
|
+
|
17
|
+
const useProviderCard = (): ProviderItem => {
|
18
|
+
const { t } = useTranslation('modelProvider');
|
19
|
+
|
20
|
+
const isLoading = useAiInfraStore(aiProviderSelectors.isAiProviderConfigLoading(providerKey));
|
21
|
+
|
22
|
+
return {
|
23
|
+
...WenxinProviderCard,
|
24
|
+
apiKeyItems: [
|
25
|
+
{
|
26
|
+
children: isLoading ? (
|
27
|
+
<SkeletonInput />
|
28
|
+
) : (
|
29
|
+
<Input.Password
|
30
|
+
autoComplete={'new-password'}
|
31
|
+
placeholder={t(`${providerKey}.accessKey.placeholder`)}
|
32
|
+
/>
|
33
|
+
),
|
34
|
+
desc: t(`${providerKey}.accessKey.desc`),
|
35
|
+
label: t(`${providerKey}.accessKey.title`),
|
36
|
+
name: [KeyVaultsConfigKey, 'accessKey'],
|
37
|
+
},
|
38
|
+
{
|
39
|
+
children: isLoading ? (
|
40
|
+
<SkeletonInput />
|
41
|
+
) : (
|
42
|
+
<Input.Password
|
43
|
+
autoComplete={'new-password'}
|
44
|
+
placeholder={t(`${providerKey}.secretKey.placeholder`)}
|
45
|
+
/>
|
46
|
+
),
|
47
|
+
desc: t(`${providerKey}.secretKey.desc`),
|
48
|
+
label: t(`${providerKey}.secretKey.title`),
|
49
|
+
name: [KeyVaultsConfigKey, 'secretKey'],
|
50
|
+
},
|
51
|
+
],
|
52
|
+
};
|
53
|
+
};
|
54
|
+
|
55
|
+
const Page = () => {
|
56
|
+
const card = useProviderCard();
|
57
|
+
|
58
|
+
return <ProviderDetail {...card} />;
|
59
|
+
};
|
60
|
+
|
61
|
+
export default Page;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { useTheme } from 'antd-style';
|
4
|
+
import Link from 'next/link';
|
5
|
+
import { memo } from 'react';
|
6
|
+
import { Trans } from 'react-i18next';
|
7
|
+
import { Center } from 'react-layout-kit';
|
8
|
+
|
9
|
+
import { MORE_MODEL_PROVIDER_REQUEST_URL } from '@/const/url';
|
10
|
+
|
11
|
+
const Footer = memo(() => {
|
12
|
+
const theme = useTheme();
|
13
|
+
return (
|
14
|
+
<Center
|
15
|
+
style={{
|
16
|
+
background: theme.colorFillQuaternary,
|
17
|
+
border: `1px dashed ${theme.colorFillSecondary}`,
|
18
|
+
borderRadius: theme.borderRadiusLG,
|
19
|
+
padding: 12,
|
20
|
+
}}
|
21
|
+
width={'100%'}
|
22
|
+
>
|
23
|
+
<div style={{ color: theme.colorTextSecondary, fontSize: 12, textAlign: 'center' }}>
|
24
|
+
<Trans i18nKey="llm.waitingForMore" ns={'setting'}>
|
25
|
+
更多模型正在
|
26
|
+
<Link aria-label={'todo'} href={MORE_MODEL_PROVIDER_REQUEST_URL} target="_blank">
|
27
|
+
计划接入
|
28
|
+
</Link>
|
29
|
+
中 ,敬请期待
|
30
|
+
</Trans>
|
31
|
+
</div>
|
32
|
+
</Center>
|
33
|
+
);
|
34
|
+
});
|
35
|
+
|
36
|
+
export default Footer;
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import { ProviderCombine, ProviderIcon } from '@lobehub/icons';
|
2
|
+
import { Avatar } from '@lobehub/ui';
|
3
|
+
import { Divider, Skeleton, Typography } from 'antd';
|
4
|
+
import { createStyles } from 'antd-style';
|
5
|
+
import Link from 'next/link';
|
6
|
+
import { memo } from 'react';
|
7
|
+
import { useTranslation } from 'react-i18next';
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
9
|
+
|
10
|
+
import InstantSwitch from '@/components/InstantSwitch';
|
11
|
+
import { useAiInfraStore } from '@/store/aiInfra';
|
12
|
+
import { AiProviderListItem } from '@/types/aiProvider';
|
13
|
+
|
14
|
+
const { Paragraph } = Typography;
|
15
|
+
|
16
|
+
const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
17
|
+
banner: css`
|
18
|
+
opacity: ${isDarkMode ? 0.9 : 0.4};
|
19
|
+
`,
|
20
|
+
container: css`
|
21
|
+
position: relative;
|
22
|
+
|
23
|
+
overflow: hidden;
|
24
|
+
|
25
|
+
height: 100%;
|
26
|
+
border-radius: 12px;
|
27
|
+
|
28
|
+
background: ${token.colorBgContainer};
|
29
|
+
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillQuaternary : token.colorFillSecondary}
|
30
|
+
inset;
|
31
|
+
|
32
|
+
transition: box-shadow 0.2s ${token.motionEaseInOut};
|
33
|
+
|
34
|
+
&:hover {
|
35
|
+
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillSecondary : token.colorFill} inset;
|
36
|
+
}
|
37
|
+
`,
|
38
|
+
desc: css`
|
39
|
+
min-height: 44px;
|
40
|
+
margin-block-end: 0 !important;
|
41
|
+
color: ${token.colorTextDescription};
|
42
|
+
`,
|
43
|
+
tagBlue: css`
|
44
|
+
color: ${token.geekblue};
|
45
|
+
background: ${token.geekblue1};
|
46
|
+
`,
|
47
|
+
tagGreen: css`
|
48
|
+
color: ${token.green};
|
49
|
+
background: ${token.green1};
|
50
|
+
`,
|
51
|
+
time: css`
|
52
|
+
color: ${token.colorTextDescription};
|
53
|
+
`,
|
54
|
+
title: css`
|
55
|
+
zoom: 1.2;
|
56
|
+
margin-block-end: 0 !important;
|
57
|
+
font-size: 18px !important;
|
58
|
+
font-weight: bold;
|
59
|
+
`,
|
60
|
+
token: css`
|
61
|
+
font-family: ${token.fontFamilyCode};
|
62
|
+
`,
|
63
|
+
}));
|
64
|
+
|
65
|
+
interface ProviderCardProps extends AiProviderListItem {
|
66
|
+
loading?: boolean;
|
67
|
+
}
|
68
|
+
const ProviderCard = memo<ProviderCardProps>(
|
69
|
+
({ id, description, name, enabled, source, logo, loading }) => {
|
70
|
+
const { t } = useTranslation('providers');
|
71
|
+
const { cx, styles, theme } = useStyles();
|
72
|
+
const toggleProviderEnabled = useAiInfraStore((s) => s.toggleProviderEnabled);
|
73
|
+
|
74
|
+
if (loading)
|
75
|
+
return (
|
76
|
+
<Flexbox className={cx(styles.container)} gap={24} padding={16}>
|
77
|
+
<Skeleton active />
|
78
|
+
</Flexbox>
|
79
|
+
);
|
80
|
+
|
81
|
+
return (
|
82
|
+
<Flexbox className={cx(styles.container)} gap={24}>
|
83
|
+
<Flexbox gap={12} padding={16} width={'100%'}>
|
84
|
+
<Link href={`/settings/provider/${id}`}>
|
85
|
+
<Flexbox gap={12} width={'100%'}>
|
86
|
+
<Flexbox align={'center'} horizontal justify={'space-between'}>
|
87
|
+
{source === 'builtin' ? (
|
88
|
+
<ProviderCombine
|
89
|
+
provider={id}
|
90
|
+
size={24}
|
91
|
+
style={{ color: theme.colorText }}
|
92
|
+
title={name}
|
93
|
+
/>
|
94
|
+
) : (
|
95
|
+
<Flexbox align={'center'} gap={12} horizontal>
|
96
|
+
{logo ? (
|
97
|
+
<Avatar alt={name || id} avatar={logo} size={28} />
|
98
|
+
) : (
|
99
|
+
<ProviderIcon
|
100
|
+
provider={id}
|
101
|
+
size={24}
|
102
|
+
style={{ borderRadius: 6 }}
|
103
|
+
type={'avatar'}
|
104
|
+
/>
|
105
|
+
)}
|
106
|
+
<Typography.Text style={{ fontSize: 16, fontWeight: 'bold' }}>
|
107
|
+
{name || id}
|
108
|
+
</Typography.Text>
|
109
|
+
</Flexbox>
|
110
|
+
)}
|
111
|
+
</Flexbox>
|
112
|
+
<Paragraph className={styles.desc} ellipsis={{ rows: 2, tooltip: true }}>
|
113
|
+
{source === 'custom' ? description : t(`${id}.description`)}
|
114
|
+
</Paragraph>
|
115
|
+
</Flexbox>
|
116
|
+
</Link>
|
117
|
+
<Divider style={{ margin: '4px 0' }} />
|
118
|
+
<Flexbox horizontal justify={'space-between'} paddingBlock={'8px 0'}>
|
119
|
+
<div />
|
120
|
+
<InstantSwitch
|
121
|
+
enabled={enabled}
|
122
|
+
onChange={async (checked) => {
|
123
|
+
await toggleProviderEnabled(id, checked);
|
124
|
+
}}
|
125
|
+
size={'small'}
|
126
|
+
/>
|
127
|
+
</Flexbox>
|
128
|
+
</Flexbox>
|
129
|
+
</Flexbox>
|
130
|
+
);
|
131
|
+
},
|
132
|
+
);
|
133
|
+
|
134
|
+
export default ProviderCard;
|
@@ -0,0 +1,91 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Grid } from '@lobehub/ui';
|
4
|
+
import { Typography } from 'antd';
|
5
|
+
import { createStyles } from 'antd-style';
|
6
|
+
import isEqual from 'fast-deep-equal';
|
7
|
+
import { memo } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
import { Center, Flexbox } from 'react-layout-kit';
|
10
|
+
|
11
|
+
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
12
|
+
|
13
|
+
import Card from './Card';
|
14
|
+
|
15
|
+
const useStyles = createStyles(({ css, responsive, token }) => ({
|
16
|
+
count: css`
|
17
|
+
height: 20px;
|
18
|
+
padding-block: 0;
|
19
|
+
padding-inline: 6px;
|
20
|
+
border-radius: 12px;
|
21
|
+
|
22
|
+
color: ${token.colorTextDescription};
|
23
|
+
|
24
|
+
background: ${token.colorFillSecondary};
|
25
|
+
`,
|
26
|
+
grid: css`
|
27
|
+
grid-template-columns: repeat(2, 1fr);
|
28
|
+
|
29
|
+
${responsive.desktop} {
|
30
|
+
grid-template-columns: repeat(3, 1fr);
|
31
|
+
}
|
32
|
+
`,
|
33
|
+
}));
|
34
|
+
|
35
|
+
const loadingArr = Array.from({ length: 12 })
|
36
|
+
.fill('-')
|
37
|
+
.map((item, index) => `${index}x${item}`);
|
38
|
+
|
39
|
+
const List = memo(() => {
|
40
|
+
const { t } = useTranslation('modelProvider');
|
41
|
+
const { styles } = useStyles();
|
42
|
+
const enabledList = useAiInfraStore(aiProviderSelectors.enabledAiProviderList, isEqual);
|
43
|
+
const disabledList = useAiInfraStore(aiProviderSelectors.disabledAiProviderList, isEqual);
|
44
|
+
const [initAiProviderList] = useAiInfraStore((s) => [s.initAiProviderList]);
|
45
|
+
|
46
|
+
if (!initAiProviderList)
|
47
|
+
return (
|
48
|
+
<Flexbox gap={12} paddingBlock={'0 16px'}>
|
49
|
+
<Flexbox align={'center'} gap={4} horizontal>
|
50
|
+
<Typography.Text style={{ fontSize: 16, fontWeight: 'bold' }}>
|
51
|
+
{t('list.title.enabled')}
|
52
|
+
</Typography.Text>
|
53
|
+
</Flexbox>
|
54
|
+
<Grid>
|
55
|
+
{loadingArr.map((item) => (
|
56
|
+
<Card enabled={false} id={item} key={item} loading source={'builtin'} />
|
57
|
+
))}
|
58
|
+
</Grid>
|
59
|
+
</Flexbox>
|
60
|
+
);
|
61
|
+
|
62
|
+
return (
|
63
|
+
<Flexbox gap={24} paddingBlock={'0 16px'}>
|
64
|
+
<Flexbox gap={12}>
|
65
|
+
<Flexbox align={'center'} gap={4} horizontal>
|
66
|
+
<Typography.Text style={{ fontSize: 16, fontWeight: 'bold' }}>
|
67
|
+
{t('list.title.enabled')}
|
68
|
+
</Typography.Text>
|
69
|
+
<Center className={styles.count}>{enabledList.length}</Center>
|
70
|
+
</Flexbox>
|
71
|
+
<Grid className={styles.grid}>
|
72
|
+
{enabledList.map((item) => (
|
73
|
+
<Card {...item} key={item.id} />
|
74
|
+
))}
|
75
|
+
</Grid>
|
76
|
+
</Flexbox>
|
77
|
+
<Flexbox gap={12}>
|
78
|
+
<Typography.Text style={{ fontSize: 16, fontWeight: 'bold' }}>
|
79
|
+
{t('list.title.disabled')}
|
80
|
+
</Typography.Text>
|
81
|
+
<Grid className={styles.grid}>
|
82
|
+
{disabledList.map((item) => (
|
83
|
+
<Card {...item} key={item.id} />
|
84
|
+
))}
|
85
|
+
</Grid>
|
86
|
+
</Flexbox>
|
87
|
+
</Flexbox>
|
88
|
+
);
|
89
|
+
});
|
90
|
+
|
91
|
+
export default List;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { isCustomBranding } from '@/const/version';
|
4
|
+
|
5
|
+
import Footer from './Footer';
|
6
|
+
import ProviderGrid from './ProviderGrid';
|
7
|
+
|
8
|
+
const Page = () => {
|
9
|
+
return (
|
10
|
+
<>
|
11
|
+
<ProviderGrid />
|
12
|
+
{!isCustomBranding && <Footer />}
|
13
|
+
</>
|
14
|
+
);
|
15
|
+
};
|
16
|
+
|
17
|
+
Page.displayName = 'ProviderGrid';
|
18
|
+
|
19
|
+
export default Page;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Icon, Tooltip } from '@lobehub/ui';
|
4
|
+
import { Button } from 'antd';
|
5
|
+
import { PlusIcon } from 'lucide-react';
|
6
|
+
import { useState } from 'react';
|
7
|
+
import { useTranslation } from 'react-i18next';
|
8
|
+
|
9
|
+
import CreateNewProvider from '../features/CreateNewProvider';
|
10
|
+
|
11
|
+
const AddNewProvider = () => {
|
12
|
+
const { t } = useTranslation('modelProvider');
|
13
|
+
const [open, setOpen] = useState(false);
|
14
|
+
|
15
|
+
return (
|
16
|
+
<Tooltip title={t('menu.addCustomProvider')}>
|
17
|
+
<Button
|
18
|
+
color={'default'}
|
19
|
+
icon={<Icon icon={PlusIcon} />}
|
20
|
+
onClick={() => setOpen(true)}
|
21
|
+
variant={'filled'}
|
22
|
+
/>
|
23
|
+
<CreateNewProvider onClose={() => setOpen(false)} open={open} />
|
24
|
+
</Tooltip>
|
25
|
+
);
|
26
|
+
};
|
27
|
+
|
28
|
+
export default AddNewProvider;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Icon } from '@lobehub/ui';
|
2
|
+
import { WalletCards } from 'lucide-react';
|
3
|
+
import Link from 'next/link';
|
4
|
+
import { usePathname } from 'next/navigation';
|
5
|
+
import { memo } from 'react';
|
6
|
+
import { useTranslation } from 'react-i18next';
|
7
|
+
import { Center, Flexbox } from 'react-layout-kit';
|
8
|
+
|
9
|
+
import { useStyles } from './Item';
|
10
|
+
|
11
|
+
const ALL_PATH = '/settings/provider';
|
12
|
+
|
13
|
+
const All = memo(() => {
|
14
|
+
const { t } = useTranslation('modelProvider');
|
15
|
+
const { styles, cx } = useStyles();
|
16
|
+
const pathname = usePathname();
|
17
|
+
|
18
|
+
return (
|
19
|
+
<Link className={cx(styles.container, pathname === ALL_PATH && styles.active)} href={ALL_PATH}>
|
20
|
+
<Flexbox gap={8} horizontal>
|
21
|
+
<Center width={24}>
|
22
|
+
<Icon icon={WalletCards} size={{ fontSize: 18 }} />
|
23
|
+
</Center>
|
24
|
+
{t('menu.all')}
|
25
|
+
</Flexbox>
|
26
|
+
</Link>
|
27
|
+
);
|
28
|
+
});
|
29
|
+
export default All;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { ProviderIcon } from '@lobehub/icons';
|
2
|
+
import { Avatar } from '@lobehub/ui';
|
3
|
+
import { Badge } from 'antd';
|
4
|
+
import { createStyles } from 'antd-style';
|
5
|
+
import Link from 'next/link';
|
6
|
+
import { usePathname } from 'next/navigation';
|
7
|
+
import { memo } from 'react';
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
9
|
+
|
10
|
+
import { AiProviderListItem, AiProviderSourceEnum } from '@/types/aiProvider';
|
11
|
+
|
12
|
+
export const useStyles = createStyles(({ css, token }) => ({
|
13
|
+
active: css`
|
14
|
+
background: ${token.colorFillSecondary};
|
15
|
+
`,
|
16
|
+
container: css`
|
17
|
+
cursor: pointer;
|
18
|
+
|
19
|
+
display: flex;
|
20
|
+
gap: 8px;
|
21
|
+
align-items: center;
|
22
|
+
justify-content: space-between;
|
23
|
+
|
24
|
+
padding-block: 8px;
|
25
|
+
padding-inline: 12px;
|
26
|
+
border-radius: ${token.borderRadius}px;
|
27
|
+
|
28
|
+
color: inherit;
|
29
|
+
|
30
|
+
transition: all 0.2s ease-in-out;
|
31
|
+
|
32
|
+
&:hover {
|
33
|
+
color: inherit;
|
34
|
+
background-color: ${token.colorFill};
|
35
|
+
}
|
36
|
+
`,
|
37
|
+
}));
|
38
|
+
|
39
|
+
const ProviderItem = memo<AiProviderListItem>(({ id, name, source, enabled, logo }) => {
|
40
|
+
const { styles, cx } = useStyles();
|
41
|
+
const pathname = usePathname();
|
42
|
+
|
43
|
+
const activeKey = pathname.split('/').pop();
|
44
|
+
|
45
|
+
const isCustom = source === AiProviderSourceEnum.Custom;
|
46
|
+
return (
|
47
|
+
<Link
|
48
|
+
className={cx(styles.container, activeKey === id && styles.active)}
|
49
|
+
href={`/settings/provider/${id}`}
|
50
|
+
>
|
51
|
+
<Flexbox gap={8} horizontal>
|
52
|
+
{isCustom && logo ? (
|
53
|
+
<Avatar
|
54
|
+
alt={name || id}
|
55
|
+
avatar={logo}
|
56
|
+
shape={'square'}
|
57
|
+
size={24}
|
58
|
+
style={{ borderRadius: 6 }}
|
59
|
+
/>
|
60
|
+
) : (
|
61
|
+
<ProviderIcon provider={id} size={24} style={{ borderRadius: 6 }} type={'avatar'} />
|
62
|
+
)}
|
63
|
+
{name}
|
64
|
+
</Flexbox>
|
65
|
+
{enabled && <Badge status="success" />}
|
66
|
+
</Link>
|
67
|
+
);
|
68
|
+
});
|
69
|
+
export default ProviderItem;
|