@lobehub/chat 1.11.8 → 1.12.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/.github/workflows/release.yml +2 -1
- package/.github/workflows/test.yml +2 -1
- package/CHANGELOG.md +50 -0
- package/Dockerfile.database +2 -0
- package/docs/self-hosting/advanced/knowledge-base.zh-CN.mdx +65 -0
- package/locales/ar/chat.json +46 -3
- package/locales/ar/common.json +1 -0
- package/locales/ar/components.json +2 -0
- package/locales/ar/error.json +1 -0
- package/locales/ar/file.json +91 -0
- package/locales/ar/knowledgeBase.json +31 -0
- package/locales/ar/portal.json +1 -0
- package/locales/bg-BG/chat.json +46 -3
- package/locales/bg-BG/common.json +1 -0
- package/locales/bg-BG/components.json +2 -0
- package/locales/bg-BG/error.json +1 -0
- package/locales/bg-BG/file.json +91 -0
- package/locales/bg-BG/knowledgeBase.json +31 -0
- package/locales/bg-BG/portal.json +1 -0
- package/locales/de-DE/chat.json +46 -3
- package/locales/de-DE/common.json +1 -0
- package/locales/de-DE/components.json +2 -0
- package/locales/de-DE/error.json +1 -0
- package/locales/de-DE/file.json +91 -0
- package/locales/de-DE/knowledgeBase.json +31 -0
- package/locales/de-DE/portal.json +1 -0
- package/locales/en-US/chat.json +46 -3
- package/locales/en-US/common.json +1 -0
- package/locales/en-US/components.json +2 -0
- package/locales/en-US/error.json +1 -0
- package/locales/en-US/file.json +91 -0
- package/locales/en-US/knowledgeBase.json +31 -0
- package/locales/en-US/portal.json +1 -0
- package/locales/es-ES/chat.json +46 -3
- package/locales/es-ES/common.json +1 -0
- package/locales/es-ES/components.json +2 -0
- package/locales/es-ES/error.json +1 -0
- package/locales/es-ES/file.json +91 -0
- package/locales/es-ES/knowledgeBase.json +31 -0
- package/locales/es-ES/portal.json +1 -0
- package/locales/fr-FR/chat.json +46 -3
- package/locales/fr-FR/common.json +1 -0
- package/locales/fr-FR/components.json +2 -0
- package/locales/fr-FR/error.json +1 -0
- package/locales/fr-FR/file.json +91 -0
- package/locales/fr-FR/knowledgeBase.json +31 -0
- package/locales/fr-FR/portal.json +1 -0
- package/locales/it-IT/chat.json +46 -3
- package/locales/it-IT/common.json +1 -0
- package/locales/it-IT/components.json +2 -0
- package/locales/it-IT/error.json +1 -0
- package/locales/it-IT/file.json +91 -0
- package/locales/it-IT/knowledgeBase.json +31 -0
- package/locales/it-IT/portal.json +1 -0
- package/locales/ja-JP/chat.json +46 -3
- package/locales/ja-JP/common.json +1 -0
- package/locales/ja-JP/components.json +2 -0
- package/locales/ja-JP/error.json +1 -0
- package/locales/ja-JP/file.json +91 -0
- package/locales/ja-JP/knowledgeBase.json +31 -0
- package/locales/ja-JP/portal.json +1 -0
- package/locales/ko-KR/chat.json +46 -3
- package/locales/ko-KR/common.json +1 -0
- package/locales/ko-KR/components.json +2 -0
- package/locales/ko-KR/error.json +1 -0
- package/locales/ko-KR/file.json +91 -0
- package/locales/ko-KR/knowledgeBase.json +31 -0
- package/locales/ko-KR/portal.json +1 -0
- package/locales/nl-NL/chat.json +46 -3
- package/locales/nl-NL/common.json +1 -0
- package/locales/nl-NL/components.json +2 -0
- package/locales/nl-NL/error.json +1 -0
- package/locales/nl-NL/file.json +91 -0
- package/locales/nl-NL/knowledgeBase.json +31 -0
- package/locales/nl-NL/portal.json +1 -0
- package/locales/pl-PL/chat.json +46 -3
- package/locales/pl-PL/common.json +1 -0
- package/locales/pl-PL/components.json +2 -0
- package/locales/pl-PL/error.json +1 -0
- package/locales/pl-PL/file.json +91 -0
- package/locales/pl-PL/knowledgeBase.json +31 -0
- package/locales/pl-PL/portal.json +1 -0
- package/locales/pt-BR/chat.json +46 -3
- package/locales/pt-BR/common.json +1 -0
- package/locales/pt-BR/components.json +2 -0
- package/locales/pt-BR/error.json +1 -0
- package/locales/pt-BR/file.json +91 -0
- package/locales/pt-BR/knowledgeBase.json +31 -0
- package/locales/pt-BR/portal.json +1 -0
- package/locales/ru-RU/chat.json +46 -3
- package/locales/ru-RU/common.json +1 -0
- package/locales/ru-RU/components.json +2 -0
- package/locales/ru-RU/error.json +1 -0
- package/locales/ru-RU/file.json +91 -0
- package/locales/ru-RU/knowledgeBase.json +31 -0
- package/locales/ru-RU/portal.json +1 -0
- package/locales/tr-TR/chat.json +46 -3
- package/locales/tr-TR/common.json +1 -0
- package/locales/tr-TR/components.json +2 -0
- package/locales/tr-TR/error.json +1 -0
- package/locales/tr-TR/file.json +91 -0
- package/locales/tr-TR/knowledgeBase.json +31 -0
- package/locales/tr-TR/portal.json +1 -0
- package/locales/vi-VN/chat.json +46 -3
- package/locales/vi-VN/common.json +1 -0
- package/locales/vi-VN/components.json +2 -0
- package/locales/vi-VN/error.json +1 -0
- package/locales/vi-VN/file.json +91 -0
- package/locales/vi-VN/knowledgeBase.json +31 -0
- package/locales/vi-VN/portal.json +1 -0
- package/locales/zh-CN/chat.json +46 -3
- package/locales/zh-CN/common.json +1 -0
- package/locales/zh-CN/components.json +2 -0
- package/locales/zh-CN/error.json +1 -0
- package/locales/zh-CN/file.json +91 -0
- package/locales/zh-CN/knowledgeBase.json +31 -0
- package/locales/zh-CN/portal.json +1 -0
- package/locales/zh-TW/chat.json +46 -3
- package/locales/zh-TW/common.json +1 -0
- package/locales/zh-TW/components.json +2 -0
- package/locales/zh-TW/error.json +1 -0
- package/locales/zh-TW/file.json +91 -0
- package/locales/zh-TW/knowledgeBase.json +31 -0
- package/locales/zh-TW/portal.json +1 -0
- package/package.json +3 -2
- package/scripts/migrateServerDB/docker.cjs +6 -0
- package/scripts/migrateServerDB/errorHint.js +17 -0
- package/scripts/migrateServerDB/index.ts +6 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/Content.tsx +37 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/index.tsx +87 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/style.ts +4 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/utils.ts +28 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileList.tsx +41 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/index.tsx +40 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/SendMore.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/index.tsx +7 -22
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +2 -4
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/File.tsx +72 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/Image.tsx +74 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/index.tsx +39 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/style.ts +1 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/index.tsx +33 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/InputArea/Container.tsx +41 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/InputArea/index.tsx +154 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Send.tsx +34 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/index.tsx +24 -11
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/components/UploadDetail/UploadStatus.tsx +71 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/components/UploadDetail/index.tsx +49 -0
- package/src/app/(main)/chat/(workspace)/@portal/FilePreview/index.tsx +26 -0
- package/src/app/(main)/chat/(workspace)/@portal/Home/Files/FileList/Item.tsx +53 -0
- package/src/app/(main)/chat/(workspace)/@portal/Home/Files/FileList/index.tsx +50 -0
- package/src/app/(main)/chat/(workspace)/@portal/Home/Files/index.tsx +21 -0
- package/src/app/(main)/chat/(workspace)/@portal/Home/index.tsx +2 -0
- package/src/app/(main)/chat/(workspace)/@portal/router.tsx +4 -0
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/KnowledgeTag.tsx +41 -0
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Tags.tsx +7 -2
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/HotKeys.tsx +1 -1
- package/src/app/(main)/files/(content)/@menu/default.tsx +27 -0
- package/src/app/(main)/files/(content)/@menu/features/FileMenu/index.tsx +97 -0
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/EmptyStatus.tsx +53 -0
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/Item/Content.tsx +175 -0
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/Item/index.tsx +69 -0
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/KnowledgeBaseList.tsx +30 -0
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/SkeletonList.tsx +57 -0
- package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/index.tsx +54 -0
- package/src/app/(main)/files/(content)/@modal/(.)[id]/FileDetail.tsx +16 -0
- package/src/app/(main)/files/(content)/@modal/(.)[id]/FilePreview.tsx +15 -0
- package/src/app/(main)/files/(content)/@modal/(.)[id]/FullscreenModal.tsx +85 -0
- package/src/app/(main)/files/(content)/@modal/(.)[id]/page.tsx +19 -0
- package/src/app/(main)/files/(content)/@modal/default.tsx +3 -0
- package/src/app/(main)/files/(content)/NotSupportClient.tsx +152 -0
- package/src/app/(main)/files/(content)/_layout/Desktop/index.tsx +28 -0
- package/src/app/(main)/files/(content)/_layout/Mobile.tsx +47 -0
- package/src/app/(main)/files/(content)/_layout/type.ts +7 -0
- package/src/app/(main)/files/(content)/layout.tsx +18 -0
- package/src/app/(main)/files/(content)/page.tsx +14 -0
- package/src/app/(main)/files/[id]/Header.tsx +63 -0
- package/src/app/(main)/files/[id]/page.tsx +44 -0
- package/src/app/(main)/files/features/FileDetail.tsx +93 -0
- package/src/app/(main)/files/hooks/useFileCategory.ts +9 -0
- package/src/app/(main)/files/layout.tsx +12 -0
- package/src/app/(main)/files/loading.tsx +21 -0
- package/src/app/(main)/repos/[id]/@menu/Head/index.tsx +33 -0
- package/src/app/(main)/repos/[id]/@menu/Menu/index.tsx +56 -0
- package/src/app/(main)/repos/[id]/@menu/default.tsx +25 -0
- package/src/app/(main)/repos/[id]/_layout/Desktop/index.tsx +25 -0
- package/src/app/(main)/repos/[id]/_layout/Mobile.tsx +47 -0
- package/src/app/(main)/repos/[id]/_layout/type.ts +6 -0
- package/src/app/(main)/repos/[id]/hooks/useKnowledgeItem.ts +7 -0
- package/src/app/(main)/repos/[id]/layout.tsx +13 -0
- package/src/app/(main)/repos/[id]/page.tsx +18 -0
- package/src/app/(main)/repos/layout.tsx +13 -0
- package/src/app/(main)/repos/page.tsx +5 -0
- package/src/app/trpc/async/[trpc]/route.ts +28 -0
- package/src/chains/abstractChunk.ts +19 -0
- package/src/chains/answerWithContext.ts +34 -0
- package/src/chains/rewriteQuery.ts +22 -0
- package/src/components/DragUpload/index.tsx +6 -99
- package/src/components/DragUpload/useDragUpload.tsx +146 -0
- package/src/components/FeatureList/index.tsx +64 -0
- package/src/components/FileParsingStatus/index.tsx +230 -0
- package/src/components/ImageItem/index.tsx +10 -2
- package/src/components/KnowledgeIcon/index.tsx +28 -0
- package/src/config/app.ts +6 -1
- package/src/config/featureFlags/schema.ts +1 -1
- package/src/config/modelProviders/bedrock.ts +5 -5
- package/src/const/file.ts +1 -0
- package/src/const/url.ts +1 -0
- package/src/database/client/models/file.ts +8 -2
- package/src/database/server/migrations/0005_pgvector.sql +2 -0
- package/src/database/server/migrations/0006_add_knowledge_base.sql +307 -0
- package/src/database/server/migrations/meta/0005_snapshot.json +2119 -0
- package/src/database/server/migrations/meta/0006_snapshot.json +3006 -0
- package/src/database/server/migrations/meta/_journal.json +14 -0
- package/src/database/server/models/__tests__/_test_template.ts +155 -0
- package/src/database/server/models/__tests__/agent.test.ts +226 -0
- package/src/database/server/models/__tests__/asyncTask.test.ts +176 -0
- package/src/database/server/models/__tests__/chunk.test.ts +336 -0
- package/src/database/server/models/__tests__/file.test.ts +317 -29
- package/src/database/server/models/__tests__/fixtures/embedding.ts +568 -0
- package/src/database/server/models/__tests__/knowledgeBase.test.ts +132 -0
- package/src/database/server/models/__tests__/message.test.ts +7 -4
- package/src/database/server/models/_template.ts +10 -1
- package/src/database/server/models/agent.ts +165 -0
- package/src/database/server/models/asyncTask.ts +96 -0
- package/src/database/server/models/chunk.ts +203 -0
- package/src/database/server/models/embedding.ts +47 -0
- package/src/database/server/models/file.ts +231 -12
- package/src/database/server/models/knowledgeBase.ts +94 -0
- package/src/database/server/models/message.ts +156 -30
- package/src/database/server/models/user.ts +12 -1
- package/src/database/server/schemas/lobechat/agent.ts +93 -0
- package/src/database/server/schemas/lobechat/discover.ts +1 -1
- package/src/database/server/schemas/lobechat/file.ts +118 -1
- package/src/database/server/schemas/lobechat/index.ts +5 -1
- package/src/database/server/schemas/lobechat/message.ts +169 -0
- package/src/database/server/schemas/lobechat/rag.ts +51 -0
- package/src/database/server/schemas/lobechat/relations.ts +68 -48
- package/src/database/server/schemas/lobechat/session.ts +77 -0
- package/src/database/server/schemas/lobechat/topic.ts +32 -0
- package/src/database/server/schemas/lobechat/user.ts +40 -25
- package/src/database/server/utils/idGenerator.ts +1 -0
- package/src/features/ChatInput/ActionBar/Clear.tsx +1 -1
- package/src/features/ChatInput/ActionBar/Knowledge/Dropdown.tsx +160 -0
- package/src/features/ChatInput/ActionBar/Knowledge/ListItem.tsx +52 -0
- package/src/features/ChatInput/ActionBar/Knowledge/index.tsx +54 -0
- package/src/features/ChatInput/ActionBar/Tools/index.tsx +1 -1
- package/src/features/ChatInput/ActionBar/Upload/ClientMode.tsx +52 -0
- package/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx +104 -0
- package/src/features/ChatInput/ActionBar/Upload/index.tsx +8 -0
- package/src/features/ChatInput/ActionBar/config.ts +14 -5
- package/src/features/ChatInput/useSend.ts +16 -7
- package/src/features/Conversation/Messages/Assistant/FileChunks/Item/index.tsx +51 -0
- package/src/features/Conversation/Messages/Assistant/FileChunks/Item/style.ts +38 -0
- package/src/features/Conversation/Messages/Assistant/FileChunks/index.tsx +76 -0
- package/src/features/Conversation/Messages/Assistant/index.tsx +13 -4
- package/src/features/Conversation/Messages/Default.tsx +4 -0
- package/src/features/Conversation/Messages/User/BelowMessage.tsx +78 -0
- package/src/features/Conversation/Messages/User/FileListViewer/Item.tsx +53 -0
- package/src/features/Conversation/Messages/User/FileListViewer/index.tsx +21 -0
- package/src/{components/FileList/FileListViewer.tsx → features/Conversation/Messages/User/ImageFileListViewer.tsx} +10 -2
- package/src/features/Conversation/Messages/{User.tsx → User/index.tsx} +11 -2
- package/src/features/Conversation/Messages/index.ts +8 -3
- package/src/features/Conversation/components/ChatItem/index.tsx +33 -10
- package/src/features/Conversation/components/InboxWelcome/QuestionSuggest.tsx +1 -1
- package/src/features/Conversation/types/index.tsx +1 -0
- package/src/features/FileManager/ChunkDrawer/ChunkList/ChunkItem.tsx +61 -0
- package/src/features/FileManager/ChunkDrawer/ChunkList/index.tsx +42 -0
- package/src/features/FileManager/ChunkDrawer/Content.tsx +38 -0
- package/src/features/FileManager/ChunkDrawer/Loading/index.tsx +16 -0
- package/src/features/FileManager/ChunkDrawer/SimilaritySearchList/Item.tsx +62 -0
- package/src/features/FileManager/ChunkDrawer/SimilaritySearchList/index.tsx +31 -0
- package/src/features/FileManager/ChunkDrawer/index.tsx +48 -0
- package/src/features/FileManager/FileList/EmptyStatus.tsx +153 -0
- package/src/features/FileManager/FileList/FileListItem/ChunkTag.tsx +35 -0
- package/src/features/FileManager/FileList/FileListItem/DropdownMenu.tsx +150 -0
- package/src/features/FileManager/FileList/FileListItem/index.tsx +211 -0
- package/src/features/FileManager/FileList/FileSkeleton.tsx +25 -0
- package/src/features/FileManager/FileList/ToolBar/Config.tsx +28 -0
- package/src/features/FileManager/FileList/ToolBar/MultiSelectActions.tsx +152 -0
- package/src/features/FileManager/FileList/ToolBar/index.tsx +114 -0
- package/src/features/FileManager/FileList/index.tsx +143 -0
- package/src/features/FileManager/FileList/useCheckTaskStatus.ts +27 -0
- package/src/features/FileManager/Header/FilesSearchBar.tsx +41 -0
- package/src/features/FileManager/Header/UploadFileButton.tsx +79 -0
- package/src/features/FileManager/Header/index.tsx +39 -0
- package/src/features/FileManager/UploadDock/Item.tsx +124 -0
- package/src/features/FileManager/UploadDock/index.tsx +183 -0
- package/src/features/FileManager/index.tsx +38 -0
- package/src/features/FileSidePanel/index.tsx +79 -0
- package/src/features/FileViewer/NotSupport/index.tsx +54 -0
- package/src/features/FileViewer/PDFViewer/HighlightLayer.tsx +81 -0
- package/src/features/FileViewer/PDFViewer/index.tsx +93 -0
- package/src/features/FileViewer/PDFViewer/style.ts +20 -0
- package/src/features/FileViewer/PDFViewer/useResizeObserver.ts +33 -0
- package/src/features/FileViewer/TXTViewer/index.tsx +41 -0
- package/src/features/FileViewer/index.tsx +45 -0
- package/src/features/KnowledgeBaseModal/AddFilesToKnowledgeBase/SelectForm.tsx +115 -0
- package/src/features/KnowledgeBaseModal/AddFilesToKnowledgeBase/index.tsx +43 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/Action.tsx +103 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/EditCustomPlugin.tsx +55 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/PluginTag.tsx +58 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/index.tsx +70 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/List.tsx +49 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Loading.tsx +13 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/index.tsx +39 -0
- package/src/features/KnowledgeBaseModal/CreateNew/CreateForm.tsx +73 -0
- package/src/features/KnowledgeBaseModal/CreateNew/index.tsx +35 -0
- package/src/features/KnowledgeBaseModal/index.ts +3 -0
- package/src/libs/langchain/loaders/pdf/index.ts +2 -2
- package/src/libs/trpc/async/asyncAuth.ts +24 -0
- package/src/libs/trpc/async/index.ts +10 -0
- package/src/libs/trpc/async/init.ts +11 -0
- package/src/libs/trpc/client/async.ts +14 -0
- package/src/libs/trpc/client/index.ts +1 -0
- package/src/libs/trpc/client/lambda.ts +9 -0
- package/src/libs/trpc/middleware/keyVaults.ts +18 -0
- package/src/libs/unstructured/__tests__/index.test.ts +0 -10
- package/src/libs/unstructured/index.ts +6 -11
- package/src/locales/default/chat.ts +47 -3
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/components.ts +2 -0
- package/src/locales/default/error.ts +6 -1
- package/src/locales/default/file.ts +92 -0
- package/src/locales/default/index.ts +4 -0
- package/src/locales/default/knowledgeBase.ts +31 -0
- package/src/locales/default/portal.ts +1 -0
- package/src/middleware.ts +3 -0
- package/src/server/asyncContext.ts +40 -0
- package/src/server/modules/ContentChunk/index.ts +135 -0
- package/src/server/modules/S3/index.ts +30 -5
- package/src/server/routers/async/caller.ts +27 -0
- package/src/server/routers/async/file.ts +247 -0
- package/src/server/routers/async/index.ts +12 -0
- package/src/server/routers/lambda/_template.ts +77 -0
- package/src/server/routers/lambda/agent.ts +159 -0
- package/src/server/routers/lambda/chunk.ts +189 -0
- package/src/server/routers/lambda/file.ts +129 -5
- package/src/server/routers/lambda/index.ts +6 -0
- package/src/server/routers/lambda/knowledgeBase.ts +79 -0
- package/src/server/routers/lambda/message.ts +6 -0
- package/src/server/routers/lambda/session.ts +0 -25
- package/src/server/routers/lambda/user.ts +5 -1
- package/src/server/services/chunk/index.ts +74 -0
- package/src/server/utils/files.ts +9 -0
- package/src/services/__tests__/chat.test.ts +18 -20
- package/src/services/__tests__/{upload.test.ts → upload_legacy.test.ts} +1 -1
- package/src/services/agent.ts +45 -0
- package/src/services/chat.ts +17 -15
- package/src/services/file/client.test.ts +1 -50
- package/src/services/file/client.ts +12 -25
- package/src/services/file/server.ts +25 -3
- package/src/services/file/type.ts +7 -4
- package/src/services/knowledgeBase.ts +34 -0
- package/src/services/message/client.test.ts +1 -1
- package/src/services/message/client.ts +29 -3
- package/src/services/message/index.ts +0 -2
- package/src/services/message/server.ts +9 -3
- package/src/services/message/type.ts +1 -13
- package/src/services/rag.ts +29 -0
- package/src/services/session/server.ts +1 -1
- package/src/services/upload.ts +89 -84
- package/src/services/upload_legacy.ts +104 -0
- package/src/services/user/client.ts +7 -2
- package/src/services/user/server.ts +6 -2
- package/src/services/user/type.ts +3 -2
- package/src/store/agent/slices/chat/action.ts +90 -18
- package/src/store/agent/slices/chat/initialState.ts +1 -0
- package/src/store/agent/slices/chat/selectors.ts +58 -0
- package/src/store/chat/slices/builtinTool/action.test.ts +2 -2
- package/src/store/chat/slices/builtinTool/action.ts +2 -2
- package/src/store/chat/slices/message/action.test.ts +2 -1
- package/src/store/chat/slices/message/action.ts +102 -26
- package/src/store/chat/slices/message/actions/rag.ts +148 -0
- package/src/store/chat/slices/message/initialState.ts +7 -0
- package/src/store/chat/slices/message/reducer.ts +6 -2
- package/src/store/chat/slices/message/selectors.ts +38 -3
- package/src/store/chat/slices/plugin/action.ts +8 -2
- package/src/store/chat/slices/portal/action.ts +8 -0
- package/src/store/chat/slices/portal/initialState.ts +3 -0
- package/src/store/chat/slices/portal/selectors.ts +8 -2
- package/src/store/file/initialState.ts +5 -1
- package/src/store/file/reducers/uploadFileList.ts +133 -0
- package/src/store/file/selectors.ts +3 -0
- package/src/store/file/slices/chat/action.test.ts +90 -90
- package/src/store/file/slices/chat/action.ts +164 -109
- package/src/store/file/slices/chat/initialState.ts +7 -2
- package/src/store/file/slices/chat/selectors.test.ts +84 -61
- package/src/store/file/slices/chat/selectors.ts +22 -32
- package/src/store/file/slices/chunk/action.ts +36 -0
- package/src/store/file/slices/chunk/index.ts +3 -0
- package/src/store/file/slices/chunk/initialState.ts +15 -0
- package/src/store/file/slices/chunk/selectors.ts +10 -0
- package/src/store/file/slices/fileManager/action.ts +187 -0
- package/src/store/file/slices/fileManager/index.ts +3 -0
- package/src/store/file/slices/fileManager/initialState.ts +18 -0
- package/src/store/file/slices/fileManager/selectors.ts +58 -0
- package/src/store/file/slices/tts/action.test.ts +1 -1
- package/src/store/file/slices/tts/action.ts +2 -2
- package/src/store/file/slices/upload/action.ts +164 -0
- package/src/store/file/store.ts +12 -1
- package/src/store/knowledgeBase/index.ts +2 -0
- package/src/store/knowledgeBase/initialState.ts +7 -0
- package/src/store/knowledgeBase/selectors.ts +1 -0
- package/src/store/knowledgeBase/slices/content/action.ts +27 -0
- package/src/store/knowledgeBase/slices/content/index.ts +1 -0
- package/src/store/knowledgeBase/slices/crud/action.ts +78 -0
- package/src/store/knowledgeBase/slices/crud/index.ts +3 -0
- package/src/store/knowledgeBase/slices/crud/initialState.ts +12 -0
- package/src/store/knowledgeBase/slices/crud/selectors.ts +7 -0
- package/src/store/knowledgeBase/store.ts +30 -0
- package/src/store/serverConfig/selectors.test.ts +1 -1
- package/src/store/user/slices/preference/selectors.ts +8 -0
- package/src/store/user/slices/settings/selectors/systemAgent.ts +2 -0
- package/src/tools/dalle/Render/Item/ImageFileItem.tsx +3 -23
- package/src/types/agent/index.ts +9 -0
- package/src/types/asyncTask.ts +31 -0
- package/src/types/chunk/document.ts +9 -0
- package/src/types/chunk/index.ts +52 -0
- package/src/types/files/index.ts +35 -0
- package/src/types/files/list.ts +44 -0
- package/src/types/files/upload.ts +91 -0
- package/src/types/knowledgeBase/index.ts +45 -0
- package/src/types/message/index.ts +54 -5
- package/src/types/rag.ts +16 -0
- package/src/utils/filter.test.ts +2 -0
- package/src/utils/server/auth.ts +23 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/LocalFiles.tsx +0 -46
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files.tsx +0 -19
- package/src/components/FileList/EditableFileList.tsx +0 -47
- package/src/components/FileList/index.ts +0 -2
- package/src/components/FileList/type.tsx +0 -7
- package/src/database/server/schemas/lobechat/chat.ts +0 -331
- package/src/features/ChatInput/ActionBar/FileUpload.tsx +0 -69
- package/src/features/ChatInput/useChatInput.ts +0 -45
- package/src/features/FileList/EditableFileList.tsx +0 -31
- package/src/features/FileList/FileListPreviewer.tsx +0 -17
- package/src/features/FileList/index.tsx +0 -2
- package/src/types/files.ts +0 -42
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createStyles } from 'antd-style';
|
|
2
|
+
import Link from 'next/link';
|
|
3
|
+
import { memo, useState } from 'react';
|
|
4
|
+
import { Flexbox } from 'react-layout-kit';
|
|
5
|
+
|
|
6
|
+
import Content, { knowledgeItemClass } from './Content';
|
|
7
|
+
|
|
8
|
+
const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
|
9
|
+
active: css`
|
|
10
|
+
background: ${isDarkMode ? token.colorFillSecondary : token.colorFillTertiary};
|
|
11
|
+
transition: background 200ms ${token.motionEaseOut};
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
background: ${token.colorFill};
|
|
15
|
+
}
|
|
16
|
+
`,
|
|
17
|
+
container: css`
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
|
|
20
|
+
margin-inline: 8px;
|
|
21
|
+
padding-block: 4px;
|
|
22
|
+
padding-inline: 8px;
|
|
23
|
+
|
|
24
|
+
border-radius: ${token.borderRadius}px;
|
|
25
|
+
|
|
26
|
+
&.${knowledgeItemClass} {
|
|
27
|
+
width: calc(100% - 16px);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
background: ${token.colorFillSecondary};
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
34
|
+
split: css`
|
|
35
|
+
border-block-end: 1px solid ${token.colorSplit};
|
|
36
|
+
`,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
export interface KnowledgeBaseItemProps {
|
|
40
|
+
active?: boolean;
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const KnowledgeBaseItem = memo<KnowledgeBaseItemProps>(({ name, active, id }) => {
|
|
46
|
+
const { styles, cx } = useStyles();
|
|
47
|
+
const [isHover, setHovering] = useState(false);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Link href={`/repos/${id}`}>
|
|
51
|
+
<Flexbox
|
|
52
|
+
align={'center'}
|
|
53
|
+
className={cx(styles.container, knowledgeItemClass, active && styles.active)}
|
|
54
|
+
distribution={'space-between'}
|
|
55
|
+
horizontal
|
|
56
|
+
onMouseEnter={() => {
|
|
57
|
+
setHovering(true);
|
|
58
|
+
}}
|
|
59
|
+
onMouseLeave={() => {
|
|
60
|
+
setHovering(false);
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<Content id={id} name={name} showMore={isHover} />
|
|
64
|
+
</Flexbox>
|
|
65
|
+
</Link>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export default KnowledgeBaseItem;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Flexbox } from 'react-layout-kit';
|
|
3
|
+
import { Virtuoso } from 'react-virtuoso';
|
|
4
|
+
|
|
5
|
+
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
|
6
|
+
|
|
7
|
+
import EmptyStatus from './EmptyStatus';
|
|
8
|
+
import Item from './Item';
|
|
9
|
+
import { SkeletonList } from './SkeletonList';
|
|
10
|
+
|
|
11
|
+
const KnowledgeBaseList = () => {
|
|
12
|
+
const useFetchKnowledgeBaseList = useKnowledgeBaseStore((s) => s.useFetchKnowledgeBaseList);
|
|
13
|
+
const { data, isLoading } = useFetchKnowledgeBaseList();
|
|
14
|
+
|
|
15
|
+
if (isLoading) return <SkeletonList />;
|
|
16
|
+
|
|
17
|
+
if (data?.length === 0) return <EmptyStatus />;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Flexbox height={'100%'}>
|
|
21
|
+
<Virtuoso
|
|
22
|
+
data={data}
|
|
23
|
+
fixedItemHeight={36}
|
|
24
|
+
itemContent={(index, data) => <Item id={data.id} key={data.id} name={data.name} />}
|
|
25
|
+
/>
|
|
26
|
+
</Flexbox>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default KnowledgeBaseList;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
container: css`
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
|
|
14
|
+
height: 36px;
|
|
15
|
+
padding: 8px;
|
|
16
|
+
|
|
17
|
+
.${prefixCls}-skeleton-content {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
|
|
23
|
+
paragraph: css`
|
|
24
|
+
> li {
|
|
25
|
+
height: 20px !important;
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export const Placeholder = memo(() => {
|
|
31
|
+
const { styles } = useStyles();
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Skeleton
|
|
35
|
+
active
|
|
36
|
+
avatar={false}
|
|
37
|
+
className={styles.container}
|
|
38
|
+
paragraph={{
|
|
39
|
+
className: styles.paragraph,
|
|
40
|
+
rows: 1,
|
|
41
|
+
style: { marginBottom: 0 },
|
|
42
|
+
width: '100%',
|
|
43
|
+
}}
|
|
44
|
+
title={false}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const SkeletonList = memo(() => (
|
|
50
|
+
<Flexbox paddingInline={24}>
|
|
51
|
+
{Array.from({ length: 3 }).map((_, i) => (
|
|
52
|
+
<Placeholder key={i} />
|
|
53
|
+
))}
|
|
54
|
+
</Flexbox>
|
|
55
|
+
));
|
|
56
|
+
|
|
57
|
+
export default SkeletonList;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CaretDownFilled, CaretRightOutlined } from '@ant-design/icons';
|
|
2
|
+
import { ActionIcon } from '@lobehub/ui';
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
import { PlusIcon } from 'lucide-react';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { Flexbox } from 'react-layout-kit';
|
|
8
|
+
|
|
9
|
+
import { useCreateNewModal } from '@/features/KnowledgeBaseModal';
|
|
10
|
+
|
|
11
|
+
import KnowledgeBaseList from './KnowledgeBaseList';
|
|
12
|
+
|
|
13
|
+
const useStyles = createStyles(({ css, token }) => ({
|
|
14
|
+
header: css`
|
|
15
|
+
color: ${token.colorTextDescription};
|
|
16
|
+
`,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const KnowledgeBase = () => {
|
|
20
|
+
const { t } = useTranslation('file');
|
|
21
|
+
const { styles } = useStyles();
|
|
22
|
+
|
|
23
|
+
const [showList, setShowList] = useState(true);
|
|
24
|
+
|
|
25
|
+
const { open } = useCreateNewModal();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Flexbox flex={1} gap={8}>
|
|
29
|
+
<Flexbox
|
|
30
|
+
align={'center'}
|
|
31
|
+
className={styles.header}
|
|
32
|
+
horizontal
|
|
33
|
+
justify={'space-between'}
|
|
34
|
+
paddingInline={'16px 12px'}
|
|
35
|
+
>
|
|
36
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
|
37
|
+
<ActionIcon
|
|
38
|
+
icon={(showList ? CaretDownFilled : CaretRightOutlined) as any}
|
|
39
|
+
onClick={() => {
|
|
40
|
+
setShowList(!showList);
|
|
41
|
+
}}
|
|
42
|
+
size={'small'}
|
|
43
|
+
/>
|
|
44
|
+
<div style={{ lineHeight: '14px' }}>{t('knowledgeBase.title')}</div>
|
|
45
|
+
</Flexbox>
|
|
46
|
+
<ActionIcon icon={PlusIcon} onClick={open} size={'small'} title={t('knowledgeBase.new')} />
|
|
47
|
+
</Flexbox>
|
|
48
|
+
|
|
49
|
+
{showList && <KnowledgeBaseList />}
|
|
50
|
+
</Flexbox>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default KnowledgeBase;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
|
|
5
|
+
import { fileManagerSelectors, useFileStore } from '@/store/file';
|
|
6
|
+
|
|
7
|
+
import Detail from '../../../features/FileDetail';
|
|
8
|
+
|
|
9
|
+
const FileDetail = memo<{ id: string }>(({ id }) => {
|
|
10
|
+
const file = useFileStore(fileManagerSelectors.getFileById(id));
|
|
11
|
+
|
|
12
|
+
if (!file) return;
|
|
13
|
+
|
|
14
|
+
return <Detail {...file} />;
|
|
15
|
+
});
|
|
16
|
+
export default FileDetail;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
|
|
5
|
+
import FileViewer from '@/features/FileViewer';
|
|
6
|
+
import { fileManagerSelectors, useFileStore } from '@/store/file';
|
|
7
|
+
|
|
8
|
+
const FilePreview = memo<{ id: string }>(({ id }) => {
|
|
9
|
+
const file = useFileStore(fileManagerSelectors.getFileById(id));
|
|
10
|
+
|
|
11
|
+
if (!file) return;
|
|
12
|
+
|
|
13
|
+
return <FileViewer {...file} />;
|
|
14
|
+
});
|
|
15
|
+
export default FilePreview;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Modal } from '@lobehub/ui';
|
|
4
|
+
import { ConfigProvider } from 'antd';
|
|
5
|
+
import { createStyles } from 'antd-style';
|
|
6
|
+
import { useRouter } from 'next/navigation';
|
|
7
|
+
import { ReactNode, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { DETAIL_PANEL_WIDTH } from '@/app/(main)/files/features/FileDetail';
|
|
10
|
+
|
|
11
|
+
const useStyles = createStyles(({ css, token }, showDetail: boolean) => {
|
|
12
|
+
return {
|
|
13
|
+
body: css`
|
|
14
|
+
height: 100%;
|
|
15
|
+
max-height: calc(100dvh - 56px) !important;
|
|
16
|
+
`,
|
|
17
|
+
content: css`
|
|
18
|
+
height: 100%;
|
|
19
|
+
background: transparent !important;
|
|
20
|
+
border: none !important;
|
|
21
|
+
`,
|
|
22
|
+
extra: css`
|
|
23
|
+
position: fixed;
|
|
24
|
+
z-index: ${token.zIndexPopupBase + 10};
|
|
25
|
+
inset-block: 0 0;
|
|
26
|
+
inset-inline-end: 0;
|
|
27
|
+
|
|
28
|
+
width: ${DETAIL_PANEL_WIDTH}px;
|
|
29
|
+
|
|
30
|
+
background: ${token.colorBgLayout};
|
|
31
|
+
border-inline-start: 1px solid ${token.colorSplit};
|
|
32
|
+
`,
|
|
33
|
+
header: css`
|
|
34
|
+
background: transparent !important;
|
|
35
|
+
`,
|
|
36
|
+
modal: css`
|
|
37
|
+
position: relative;
|
|
38
|
+
inset-block-start: 0;
|
|
39
|
+
|
|
40
|
+
width: ${showDetail ? `calc(100vw - ${DETAIL_PANEL_WIDTH}px) ` : '100vw'} !important;
|
|
41
|
+
max-width: none;
|
|
42
|
+
height: 100%;
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding-block-end: 0;
|
|
45
|
+
|
|
46
|
+
> div {
|
|
47
|
+
height: 100%;
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
interface FullscreenModalProps {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
detail?: ReactNode;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const FullscreenModal = ({ children, detail }: FullscreenModalProps) => {
|
|
59
|
+
const router = useRouter();
|
|
60
|
+
const [open, setOpen] = useState(true);
|
|
61
|
+
|
|
62
|
+
const { styles } = useStyles(!!detail);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<ConfigProvider theme={{ token: { motion: false } }}>
|
|
67
|
+
<Modal
|
|
68
|
+
className={styles.modal}
|
|
69
|
+
classNames={{ body: styles.body, content: styles.content, header: styles.header }}
|
|
70
|
+
footer={false}
|
|
71
|
+
onCancel={() => {
|
|
72
|
+
router.back();
|
|
73
|
+
setOpen(false);
|
|
74
|
+
}}
|
|
75
|
+
open={open}
|
|
76
|
+
width={'auto'}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</Modal>
|
|
80
|
+
</ConfigProvider>
|
|
81
|
+
{!!detail && <div className={styles.extra}>{detail}</div>}
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
export default FullscreenModal;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import FileDetail from './FileDetail';
|
|
2
|
+
import FilePreview from './FilePreview';
|
|
3
|
+
import FullscreenModal from './FullscreenModal';
|
|
4
|
+
|
|
5
|
+
interface Params {
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Props = { params: Params };
|
|
10
|
+
|
|
11
|
+
const Page = ({ params }: Props) => {
|
|
12
|
+
return (
|
|
13
|
+
<FullscreenModal detail={<FileDetail id={params.id} />}>
|
|
14
|
+
<FilePreview id={params.id} />
|
|
15
|
+
</FullscreenModal>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Page;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Icon } from '@lobehub/ui';
|
|
4
|
+
import { Typography } from 'antd';
|
|
5
|
+
import { createStyles, useTheme } from 'antd-style';
|
|
6
|
+
import { Database, FileImage, FileText, FileUpIcon, LibraryBig, SearchCheck } from 'lucide-react';
|
|
7
|
+
import Link from 'next/link';
|
|
8
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
9
|
+
import { Center, Flexbox } from 'react-layout-kit';
|
|
10
|
+
|
|
11
|
+
import FeatureList from '@/components/FeatureList';
|
|
12
|
+
import { DATABASE_SELF_HOSTING_URL, OFFICIAL_URL, UTM_SOURCE } from '@/const/url';
|
|
13
|
+
|
|
14
|
+
const BLOCK_SIZE = 100;
|
|
15
|
+
const ICON_SIZE = 72;
|
|
16
|
+
|
|
17
|
+
const useStyles = createStyles(({ css, token }) => ({
|
|
18
|
+
actionTitle: css`
|
|
19
|
+
margin-block-start: 12px;
|
|
20
|
+
font-size: 16px;
|
|
21
|
+
color: ${token.colorTextSecondary};
|
|
22
|
+
`,
|
|
23
|
+
card: css`
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
|
|
26
|
+
position: relative;
|
|
27
|
+
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
|
|
30
|
+
width: 200px;
|
|
31
|
+
height: 140px;
|
|
32
|
+
|
|
33
|
+
font-weight: 500;
|
|
34
|
+
text-align: center;
|
|
35
|
+
|
|
36
|
+
background: ${token.colorFillTertiary};
|
|
37
|
+
border-radius: ${token.borderRadiusLG}px;
|
|
38
|
+
box-shadow: 0 0 0 1px ${token.colorFillTertiary} inset;
|
|
39
|
+
|
|
40
|
+
transition: background 0.3s ease-in-out;
|
|
41
|
+
|
|
42
|
+
&:hover {
|
|
43
|
+
background: ${token.colorFillSecondary};
|
|
44
|
+
}
|
|
45
|
+
`,
|
|
46
|
+
glow: css`
|
|
47
|
+
position: absolute;
|
|
48
|
+
inset-block-end: -12px;
|
|
49
|
+
inset-inline-end: 0;
|
|
50
|
+
|
|
51
|
+
width: 48px;
|
|
52
|
+
height: 48px;
|
|
53
|
+
|
|
54
|
+
opacity: 0.5;
|
|
55
|
+
filter: blur(24px);
|
|
56
|
+
`,
|
|
57
|
+
|
|
58
|
+
icon: css`
|
|
59
|
+
color: ${token.colorTextLightSolid};
|
|
60
|
+
border-radius: ${token.borderRadiusLG}px;
|
|
61
|
+
`,
|
|
62
|
+
iconGroup: css`
|
|
63
|
+
margin-block-start: -44px;
|
|
64
|
+
`,
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
const NotSupportClient = () => {
|
|
68
|
+
const { t } = useTranslation('file');
|
|
69
|
+
const theme = useTheme();
|
|
70
|
+
const { styles } = useStyles();
|
|
71
|
+
|
|
72
|
+
const features = [
|
|
73
|
+
{
|
|
74
|
+
avatar: Database,
|
|
75
|
+
desc: t('notSupportGuide.features.allKind.desc'),
|
|
76
|
+
title: t('notSupportGuide.features.allKind.title'),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
avatar: SearchCheck,
|
|
80
|
+
desc: t('notSupportGuide.features.embeddings.desc'),
|
|
81
|
+
title: t('notSupportGuide.features.embeddings.title'),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
avatar: LibraryBig,
|
|
85
|
+
desc: t('notSupportGuide.features.repos.desc'),
|
|
86
|
+
title: t('notSupportGuide.features.repos.title'),
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Center gap={40} height={'100%'} width={'100%'}>
|
|
92
|
+
<Flexbox className={styles.iconGroup} gap={12} horizontal>
|
|
93
|
+
<Center
|
|
94
|
+
className={styles.icon}
|
|
95
|
+
height={BLOCK_SIZE * 1.25}
|
|
96
|
+
style={{
|
|
97
|
+
background: theme.purple,
|
|
98
|
+
transform: 'rotateZ(-20deg) translateX(10px)',
|
|
99
|
+
}}
|
|
100
|
+
width={BLOCK_SIZE}
|
|
101
|
+
>
|
|
102
|
+
<Icon icon={FileImage} size={{ fontSize: ICON_SIZE, strokeWidth: 1.5 }} />
|
|
103
|
+
</Center>
|
|
104
|
+
<Center
|
|
105
|
+
className={styles.icon}
|
|
106
|
+
height={BLOCK_SIZE * 1.25}
|
|
107
|
+
style={{
|
|
108
|
+
background: theme.gold,
|
|
109
|
+
transform: 'translateY(-22px)',
|
|
110
|
+
zIndex: 1,
|
|
111
|
+
}}
|
|
112
|
+
width={BLOCK_SIZE}
|
|
113
|
+
>
|
|
114
|
+
<Icon icon={FileUpIcon} size={{ fontSize: ICON_SIZE, strokeWidth: 1.5 }} />
|
|
115
|
+
</Center>
|
|
116
|
+
<Center
|
|
117
|
+
className={styles.icon}
|
|
118
|
+
height={BLOCK_SIZE * 1.25}
|
|
119
|
+
style={{
|
|
120
|
+
background: theme.geekblue,
|
|
121
|
+
transform: 'rotateZ(20deg) translateX(-10px)',
|
|
122
|
+
}}
|
|
123
|
+
width={BLOCK_SIZE}
|
|
124
|
+
>
|
|
125
|
+
<Icon icon={FileText} size={{ fontSize: ICON_SIZE, strokeWidth: 1.5 }} />
|
|
126
|
+
</Center>
|
|
127
|
+
</Flexbox>
|
|
128
|
+
|
|
129
|
+
<Flexbox justify={'center'} style={{ textAlign: 'center' }}>
|
|
130
|
+
<Typography.Title>{t('notSupportGuide.title')}</Typography.Title>
|
|
131
|
+
<Typography.Text type={'secondary'}>
|
|
132
|
+
<Trans i18nKey={'notSupportGuide.desc'} ns={'file'}>
|
|
133
|
+
当前部署实例为客户端数据库模式,无法使用文件管理功能。请切换到
|
|
134
|
+
<Link href={DATABASE_SELF_HOSTING_URL}>服务端数据库部署模式</Link>
|
|
135
|
+
,或直接使用官方的
|
|
136
|
+
<Link
|
|
137
|
+
href={`${OFFICIAL_URL}?utm_source=${UTM_SOURCE}&utm_medium=client_not_support_file`}
|
|
138
|
+
>
|
|
139
|
+
LobeChat Cloud
|
|
140
|
+
</Link>
|
|
141
|
+
</Trans>
|
|
142
|
+
</Typography.Text>
|
|
143
|
+
</Flexbox>
|
|
144
|
+
|
|
145
|
+
<Flexbox style={{ marginTop: 40 }}>
|
|
146
|
+
<FeatureList data={features} />
|
|
147
|
+
</Flexbox>
|
|
148
|
+
</Center>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export default NotSupportClient;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Flexbox } from 'react-layout-kit';
|
|
2
|
+
|
|
3
|
+
import FilePanel from '@/features/FileSidePanel';
|
|
4
|
+
|
|
5
|
+
import { LayoutProps } from '../type';
|
|
6
|
+
|
|
7
|
+
const Layout = ({ children, menu, modal }: LayoutProps) => {
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Flexbox
|
|
11
|
+
height={'100%'}
|
|
12
|
+
horizontal
|
|
13
|
+
style={{ maxWidth: 'calc(100vw - 64px)', overflow: 'hidden', position: 'relative' }}
|
|
14
|
+
width={'100%'}
|
|
15
|
+
>
|
|
16
|
+
<FilePanel>{menu}</FilePanel>
|
|
17
|
+
<Flexbox flex={1} style={{ overflow: 'hidden', position: 'relative' }}>
|
|
18
|
+
{children}
|
|
19
|
+
</Flexbox>
|
|
20
|
+
</Flexbox>
|
|
21
|
+
{modal}
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Layout.displayName = 'DesktopFileLayout';
|
|
27
|
+
|
|
28
|
+
export default Layout;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
import { Flexbox } from 'react-layout-kit';
|
|
6
|
+
|
|
7
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
8
|
+
|
|
9
|
+
import { LayoutProps } from './type';
|
|
10
|
+
|
|
11
|
+
const useStyles = createStyles(({ css, token }) => ({
|
|
12
|
+
main: css`
|
|
13
|
+
position: relative;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
background: ${token.colorBgLayout};
|
|
16
|
+
`,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const Layout = memo<LayoutProps>(({ children, menu }) => {
|
|
20
|
+
const { showMobileWorkspace } = useQuery();
|
|
21
|
+
const { styles } = useStyles();
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<Flexbox
|
|
26
|
+
className={styles.main}
|
|
27
|
+
height="100%"
|
|
28
|
+
style={showMobileWorkspace ? { display: 'none' } : undefined}
|
|
29
|
+
width="100%"
|
|
30
|
+
>
|
|
31
|
+
{menu}
|
|
32
|
+
</Flexbox>
|
|
33
|
+
<Flexbox
|
|
34
|
+
className={styles.main}
|
|
35
|
+
height="100%"
|
|
36
|
+
style={showMobileWorkspace ? undefined : { display: 'none' }}
|
|
37
|
+
width="100%"
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</Flexbox>
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
Layout.displayName = 'MobileChatLayout';
|
|
46
|
+
|
|
47
|
+
export default Layout;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ServerLayout from '@/components/server/ServerLayout';
|
|
2
|
+
import { isServerMode } from '@/const/version';
|
|
3
|
+
|
|
4
|
+
import NotSupportClient from './NotSupportClient';
|
|
5
|
+
import Desktop from './_layout/Desktop';
|
|
6
|
+
import Mobile from './_layout/Mobile';
|
|
7
|
+
import { LayoutProps } from './_layout/type';
|
|
8
|
+
|
|
9
|
+
const Layout = ServerLayout<LayoutProps>({ Desktop, Mobile });
|
|
10
|
+
|
|
11
|
+
Layout.displayName = 'FileLayout';
|
|
12
|
+
|
|
13
|
+
export default (props: LayoutProps) => {
|
|
14
|
+
// if there is client db mode , tell user to switch to server mode
|
|
15
|
+
if (!isServerMode) return <NotSupportClient />;
|
|
16
|
+
|
|
17
|
+
return <Layout {...props} />;
|
|
18
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
|
|
5
|
+
import { useFileCategory } from '@/app/(main)/files/hooks/useFileCategory';
|
|
6
|
+
import FileManager from '@/features/FileManager';
|
|
7
|
+
import { FilesTabs } from '@/types/files';
|
|
8
|
+
|
|
9
|
+
export default () => {
|
|
10
|
+
const { t } = useTranslation('file');
|
|
11
|
+
const [category] = useFileCategory();
|
|
12
|
+
|
|
13
|
+
return <FileManager category={category} title={t(`tab.${category as FilesTabs}`)} />;
|
|
14
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ActionIcon, Icon } from '@lobehub/ui';
|
|
4
|
+
import { Button, Divider, Typography } from 'antd';
|
|
5
|
+
import { useTheme } from 'antd-style';
|
|
6
|
+
import { ArrowLeftIcon, DownloadIcon } from 'lucide-react';
|
|
7
|
+
import { useRouter } from 'next/navigation';
|
|
8
|
+
import { memo } from 'react';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { Flexbox } from 'react-layout-kit';
|
|
11
|
+
|
|
12
|
+
import { downloadFile } from '@/utils/downloadFile';
|
|
13
|
+
|
|
14
|
+
interface HeaderProps {
|
|
15
|
+
filename: string;
|
|
16
|
+
id: string;
|
|
17
|
+
url: string;
|
|
18
|
+
}
|
|
19
|
+
const Header = memo<HeaderProps>(({ filename, url }) => {
|
|
20
|
+
const { t } = useTranslation('common');
|
|
21
|
+
const router = useRouter();
|
|
22
|
+
|
|
23
|
+
const theme = useTheme();
|
|
24
|
+
return (
|
|
25
|
+
<Flexbox
|
|
26
|
+
align={'center'}
|
|
27
|
+
horizontal
|
|
28
|
+
justify={'space-between'}
|
|
29
|
+
paddingBlock={12}
|
|
30
|
+
paddingInline={12}
|
|
31
|
+
style={{ borderBottom: `1px solid ${theme.colorSplit}` }}
|
|
32
|
+
>
|
|
33
|
+
<Flexbox align={'baseline'} horizontal>
|
|
34
|
+
<Button
|
|
35
|
+
icon={<Icon icon={ArrowLeftIcon}></Icon>}
|
|
36
|
+
onClick={() => {
|
|
37
|
+
router.push('/files');
|
|
38
|
+
}}
|
|
39
|
+
size={'small'}
|
|
40
|
+
type={'text'}
|
|
41
|
+
>
|
|
42
|
+
{t('back')}
|
|
43
|
+
</Button>
|
|
44
|
+
<Divider type={'vertical'} />
|
|
45
|
+
<Typography.Title
|
|
46
|
+
level={1}
|
|
47
|
+
style={{ fontSize: 16, lineHeight: 1.5, marginBottom: 0, paddingInlineStart: 8 }}
|
|
48
|
+
>
|
|
49
|
+
{filename}
|
|
50
|
+
</Typography.Title>
|
|
51
|
+
</Flexbox>
|
|
52
|
+
<Flexbox>
|
|
53
|
+
<ActionIcon
|
|
54
|
+
icon={DownloadIcon}
|
|
55
|
+
onClick={() => {
|
|
56
|
+
downloadFile(url, filename);
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
</Flexbox>
|
|
60
|
+
</Flexbox>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
export default Header;
|