@gientech/modual 2.2.3-fix.5 → 2.2.3-fix.6
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/.editorconfig +38 -0
- package/.prettierignore +16 -0
- package/.prettierrc +17 -0
- package/CHANGELOG.md +162 -0
- package/Dockerfile +15 -0
- package/README.md +761 -761
- package/USAGE.md +247 -0
- package/bash.exe.stackdump +40 -0
- package/components.json +21 -0
- package/default.conf +19 -0
- package/dist/README.md +761 -0
- package/{assets/GientechStreamReader-r5ZTSZk2.js → dist/assets/GientechStreamReader-Bae2-4f7.js} +1 -1
- package/{assets/LeftOutlined-DZMeGbKk.js → dist/assets/LeftOutlined-COk0w5nY.js} +1 -1
- package/{assets/circle-plus-B73z_SUN.js → dist/assets/circle-plus-DOKqXUMk.js} +1 -1
- package/{assets → dist/assets}/database.svg +11 -11
- package/{assets → dist/assets}/database_add.svg +53 -53
- package/{assets → dist/assets}/database_connect.svg +66 -66
- package/{assets → dist/assets}/database_upload.svg +29 -29
- package/{assets → dist/assets}/databse.svg +6 -6
- package/{assets → dist/assets}/defaultWeLogo.svg +14 -14
- package/{assets → dist/assets}/graph.svg +4 -4
- package/{assets → dist/assets}/iconAi.svg +9 -9
- package/dist/assets/index-1PwCuRjv.js +1061 -0
- package/dist/assets/index-7QvYA6eT.js +1 -0
- package/{assets/index-97Oe7YBe.js → dist/assets/index-BKbpfN9S.js} +1 -1
- package/{assets/index-B4k3tK0f.js → dist/assets/index-BXdyn2W3.js} +1 -1
- package/dist/assets/index-BhUNGJOe.js +27 -0
- package/{assets/index-BDc2zBbG.js → dist/assets/index-Bin0NZwF.js} +3 -7
- package/{assets/index-DHK_n74G.js → dist/assets/index-CpSzj-Sx.js} +73 -58
- package/{assets/index-usBlUHOb.js → dist/assets/index-Ct_k24Ar.js} +1 -1
- package/dist/assets/index-DT3qkjJ3.js +750 -0
- package/dist/assets/index-lFBFf_0k.js +1890 -0
- package/{assets/index-iOuQJ8vu.js → dist/assets/index-vfI1_Qg0.js} +1 -1
- package/{assets → dist/assets}/knowledge.svg +4 -4
- package/{assets → dist/assets}/mysql.svg +14 -14
- package/{assets → dist/assets}/sensitive.svg +5 -5
- package/{assets/style-6bvhg-jh.js → dist/assets/style-CfNUqKAA.js} +7 -7
- package/dist/assets/style2.css +1 -0
- package/dist/assets/style5.css +1 -0
- package/{assets/triangle-alert-C4Z1AkGW.js → dist/assets/triangle-alert-CaJaaCaZ.js} +1 -1
- package/{assets/x-DWGzNb9c.js → dist/assets/x-B65AntWN.js} +1 -1
- package/{assistantConfig.js → dist/assistantConfig.js} +9 -14
- package/dist/chat.js +1 -0
- package/dist/chatCompare.js +1 -0
- package/dist/database.js +20 -0
- package/{databaseId.js → dist/databaseId.js} +1 -1
- package/{databaseTable.js → dist/databaseTable.js} +1 -1
- package/dist/index.js +1 -0
- package/dist/modelManage.js +1 -0
- package/dist/package.json +73 -0
- package/{sensitive.js → dist/sensitive.js} +6 -6
- package/dist/streamFilesReader.js +1 -0
- package/{worker → dist/worker}/pdf.worker.min.js +21 -21
- package/doc_assets/images/1.png +0 -0
- package/doc_assets/images/3.png +0 -0
- package/doc_assets/images/component-screenshot.png +1 -0
- package/doc_assets//346/226/271/346/241/210/v2.0.7/345/217/230/346/233/264/346/200/273/347/273/223.md +115 -0
- package/doc_assets//346/226/271/346/241/210//344/274/230/345/214/226/346/226/271/346/241/210-/345/244/232/344/274/232/350/257/235SSE/350/277/236/346/216/245/347/256/241/347/220/206.md +504 -0
- package/doc_assets//346/226/271/346/241/210//346/215/242/350/241/214/346/240/274/345/274/217/344/277/235/346/214/201/344/274/230/345/214/226/346/226/271/346/241/210.md +359 -0
- package/eslint.config.js +92 -0
- package/index.html +13 -0
- package/package.json +125 -44
- package/package.json.demo-backup +109 -0
- package/postcss.config.cjs +19 -0
- package/public/icons/answerAwartar.png +0 -0
- package/public/icons/docx-file.png +0 -0
- package/public/icons/folder.png +0 -0
- package/public/icons/html.png +0 -0
- package/public/icons/image.png +0 -0
- package/public/icons/jpg-file.png +0 -0
- package/public/icons/json.png +0 -0
- package/public/icons/md.png +0 -0
- package/public/icons/pdf.png +0 -0
- package/public/icons/pptx.png +0 -0
- package/public/icons/questionAwartar.png +0 -0
- package/public/icons/sheets.png +0 -0
- package/public/icons/txt.png +0 -0
- package/public/icons/xlsx.png +0 -0
- package/public/vite.svg +1 -0
- package/public/worker/pdf.worker.min.js +22 -0
- package/rag/assets/index.Bd0tNzw0.js +2797 -0
- package/rag/assets/index.D6t67hlu.css +1 -0
- package/rag/assets/left.KBHV5h7q.jpg +0 -0
- package/rag/assets/worker-BbpylX7l.DptbXke_.js +13 -0
- package/release-it.json +21 -0
- package/scripts/README.md +133 -0
- package/scripts/build-demo.js +88 -0
- package/scripts/check-changelog.cjs +124 -0
- package/scripts/check-version.cjs +49 -0
- package/scripts/decrypt-api-key.js +95 -0
- package/scripts/demo-selector.js +216 -0
- package/scripts/dev-demo.js +85 -0
- package/scripts/open-file.cjs +61 -0
- package/scripts/preview-demo.js +130 -0
- package/scripts/run-demo.bat +34 -0
- package/src/assets/img/close.png +0 -0
- package/src/assets/img/database.png +0 -0
- package/src/assets/img/downArrow.png +0 -0
- package/src/assets/img/downLoad.png +0 -0
- package/src/assets/img/excel.png +0 -0
- package/src/assets/img/graphIcon.png +0 -0
- package/src/assets/img/iconAi.svg +9 -0
- package/src/assets/img/img.png +0 -0
- package/src/assets/img/pdf.png +0 -0
- package/src/assets/img/ppt.png +0 -0
- package/src/assets/img/search.svg +3 -0
- package/src/assets/img/selected.svg +4 -0
- package/src/assets/img/singleQa.png +0 -0
- package/src/assets/img/txt.png +0 -0
- package/src/assets/img/webSearch.png +0 -0
- package/src/assets/img/word.png +0 -0
- package/src/assets/login/homeBg.png +0 -0
- package/src/assets/login/left.jpg +0 -0
- package/src/assets/login/logoImg.png +0 -0
- package/src/examples/ConversationAssistantPage/index.tsx +42 -0
- package/src/examples/LoginPage/index.tsx +20 -0
- package/src/examples/chat/components/DrawerGraphPreview.tsx +78 -0
- package/src/examples/chat/index.tsx +171 -0
- package/src/examples/chat/logo03.png +0 -0
- package/src/examples/chatCompare/icons/rag_think.svg +8 -0
- package/src/examples/chatCompare/icons/wenda_lianwangsousuo.svg +9 -0
- package/src/examples/chatCompare/index.tsx +154 -0
- package/src/examples/gientechStreamFilesReader/index.tsx +979 -0
- package/src/examples/headlessChat/assets/mind.svg +6 -0
- package/src/examples/headlessChat/assets/net.svg +7 -0
- package/src/examples/headlessChat/index.tsx +298 -0
- package/src/examples/knowledgebaseDetails/index.tsx +119 -0
- package/src/examples/ragDatabaseDataPage/index.tsx +40 -0
- package/src/examples/ragDatabaseIdPage/index.tsx +126 -0
- package/src/examples/ragDatabasePage/index.tsx +36 -0
- package/src/examples/ragModelManagePage/index.tsx +107 -0
- package/src/examples/ragModelManagePage/style.css +7 -0
- package/src/examples/ragSearchPage/index.tsx +0 -0
- package/src/examples/ragSensitiveWordsPage/index.tsx +117 -0
- package/src/examples/ragSensitiveWordsPage/style.css +16 -0
- package/src/examples/sensitiveId/index.tsx +41 -0
- package/src/examples/streamFiles/index.tsx +417 -0
- package/src/examples/utils/demo_setting_pannel.ts +0 -0
- package/src/lib_enter.ts +44 -0
- package/src/main.tsx +5 -0
- package/src/main.tsx.backup +5 -0
- package/src/modules/CHAT_UNIFICATION_PLAN.md +324 -0
- package/src/modules/assistantConfig/assets/databse.svg +6 -0
- package/src/modules/assistantConfig/assets/empty.png +0 -0
- package/src/modules/assistantConfig/assets/graph.svg +4 -0
- package/src/modules/assistantConfig/assets/knowledge.svg +4 -0
- package/src/modules/assistantConfig/assets/sensitive.svg +5 -0
- package/src/modules/assistantConfig/components/Database.tsx +171 -0
- package/src/modules/assistantConfig/components/Graph.tsx +177 -0
- package/src/modules/assistantConfig/components/Knowledge.tsx +276 -0
- package/src/modules/assistantConfig/components/NotFoundContent.tsx +21 -0
- package/src/modules/assistantConfig/components/Paragraph.tsx +51 -0
- package/src/modules/assistantConfig/components/ParamsItem.tsx +40 -0
- package/src/modules/assistantConfig/components/ResourceBinderItem.tsx +133 -0
- package/src/modules/assistantConfig/components/SearchableSelector.tsx +500 -0
- package/src/modules/assistantConfig/components/Sensitive.tsx +221 -0
- package/src/modules/assistantConfig/components/SliderInput.tsx +66 -0
- package/src/modules/assistantConfig/constants.tsx +75 -0
- package/src/modules/assistantConfig/index.tsx +785 -0
- package/src/modules/assistantConfig/server.ts +262 -0
- package/src/modules/chat/AllFiles.tsx +158 -0
- package/src/modules/chat/Conversations/Item.tsx +169 -0
- package/src/modules/chat/Conversations/List.tsx +210 -0
- package/src/modules/chat/Conversations/groupByTime.ts +39 -0
- package/src/modules/chat/Conversations/index.tsx +255 -0
- package/src/modules/chat/ReferenceBar.tsx +659 -0
- package/src/modules/chat/constants.tsx +66 -0
- package/src/modules/chat/i18n.ts +151 -0
- package/src/modules/chat/i18n.tsx +151 -0
- package/src/modules/chat/icons/rag_think.svg +8 -0
- package/src/modules/chat/icons/wenda_lianwangsousuo.svg +9 -0
- package/src/modules/chat/index.tsx +2400 -0
- package/src/modules/chat/referenceCom/DeleteModal.tsx +75 -0
- package/src/modules/chat/referenceCom/DrawerContent.tsx +136 -0
- package/src/modules/chat/referenceCom/DrawerDatabase.tsx +102 -0
- package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +86 -0
- package/src/modules/chat/referenceCom/DrawerPreview.tsx +73 -0
- package/src/modules/chat/referenceCom/DrawerTitle.tsx +26 -0
- package/src/modules/chat/referenceCom/RenameModal.tsx +86 -0
- package/src/modules/chat/referenceCom/TagCom.tsx +30 -0
- package/src/modules/chat/style.css +6 -0
- package/src/modules/chat/style.less +7 -0
- package/src/modules/chat/types.ts +17 -0
- package/src/modules/chat/utils/index.ts +348 -0
- package/src/modules/chatCompare/UseChatCompareHooks.ts +103 -0
- package/src/modules/chatCompare/components/AichatCompareUseController.tsx +754 -0
- package/src/modules/chatCompare/components/AssistantSelector.tsx +127 -0
- package/src/modules/chatCompare/components/ChatInputer.tsx +67 -0
- package/src/modules/chatCompare/components/ChatInstance.tsx +426 -0
- package/src/modules/chatCompare/components/ChatItem.tsx +556 -0
- package/src/modules/chatCompare/components/Sender/FileCardCommon.tsx +97 -0
- package/src/modules/chatCompare/components/Sender/FileUpload.tsx +89 -0
- package/src/modules/chatCompare/components/Sender/FilesDisplay.tsx +309 -0
- package/src/modules/chatCompare/components/Sender/VoiceInput.tsx +80 -0
- package/src/modules/chatCompare/components/Sender/contexts/BadgeContext.tsx +36 -0
- package/src/modules/chatCompare/components/Sender/fileIcon.tsx +100 -0
- package/src/modules/chatCompare/components/Sender/index.tsx +850 -0
- package/src/modules/chatCompare/components/UseChatInstanceHooks.ts +406 -0
- package/src/modules/chatCompare/components/UseScrollHooks.ts +36 -0
- package/src/modules/chatCompare/components/components/AllFiles.tsx +156 -0
- package/src/modules/chatCompare/components/components/DeleteModal.tsx +75 -0
- package/src/modules/chatCompare/components/components/DrawerContent.tsx +138 -0
- package/src/modules/chatCompare/components/components/DrawerDatabase.tsx +110 -0
- package/src/modules/chatCompare/components/components/DrawerGraphPreview.tsx +95 -0
- package/src/modules/chatCompare/components/components/DrawerPreview.tsx +75 -0
- package/src/modules/chatCompare/components/components/DrawerTitle.tsx +26 -0
- package/src/modules/chatCompare/components/components/DrawerVideo.tsx +85 -0
- package/src/modules/chatCompare/components/components/ReferenceBar.tsx +659 -0
- package/src/modules/chatCompare/components/components/RenameModal.tsx +86 -0
- package/src/modules/chatCompare/components/components/TagCom.tsx +30 -0
- package/src/modules/chatCompare/components/defaultStyleSet.tsx +148 -0
- package/src/modules/chatCompare/components/server.ts +208 -0
- package/src/modules/chatCompare/components/serverFn.ts +172 -0
- package/src/modules/chatCompare/components/style.less +97 -0
- package/src/modules/chatCompare/components/useFileManager.ts +173 -0
- package/src/modules/chatCompare/components/utils.ts +31 -0
- package/src/modules/chatCompare/data.ts +842 -0
- package/src/modules/chatCompare/index.tsx +537 -0
- package/src/modules/chatCompare/utils/AiChat.types.tsx +110 -0
- package/src/modules/chatCompare/utils/constants.tsx +70 -0
- package/src/modules/chatCompare/utils/fileUploadValidator.ts +183 -0
- package/src/modules/chatCompare/utils/icons/rag_think.svg +8 -0
- package/src/modules/chatCompare/utils/icons/wenda_lianwangsousuo.svg +9 -0
- package/src/modules/chatCompare/utils/index.ts +46 -0
- package/src/modules/database/CreateModal.tsx +402 -0
- package/src/modules/database/assets/Doris.png +0 -0
- package/src/modules/database/assets/PostgreSQL.png +0 -0
- package/src/modules/database/assets/SQLServer.png +0 -0
- package/src/modules/database/assets/database.svg +11 -0
- package/src/modules/database/assets/database_add.svg +53 -0
- package/src/modules/database/assets/database_connect.svg +66 -0
- package/src/modules/database/assets/database_upload.svg +29 -0
- package/src/modules/database/assets/empty.png +0 -0
- package/src/modules/database/assets/mysql.svg +14 -0
- package/src/modules/database/index.tsx +477 -0
- package/src/modules/database/server.ts +196 -0
- package/src/modules/databaseId/CustomCom.tsx +156 -0
- package/src/modules/databaseId/EditConfig.tsx +280 -0
- package/src/modules/databaseId/UploadDrawer.tsx +535 -0
- package/src/modules/databaseId/assets/aiOptimize.svg +10 -0
- package/src/modules/databaseId/assets/empty.png +0 -0
- package/src/modules/databaseId/assets/template.svg +6 -0
- package/src/modules/databaseId/assets/upload.svg +9 -0
- package/src/modules/databaseId/assets/useTemp.svg +6 -0
- package/src/modules/databaseId/i18n.ts +360 -0
- package/src/modules/databaseId/index.tsx +855 -0
- package/src/modules/databaseId/server.ts +286 -0
- package/src/modules/databaseId/style.css +5 -0
- package/src/modules/databaseTable/EditRowDrawer.tsx +124 -0
- package/src/modules/databaseTable/index.tsx +359 -0
- package/src/modules/databaseTable/server.ts +180 -0
- package/src/modules/headlessChat/ReferenceBar.tsx +783 -0
- package/src/modules/headlessChat/constants.tsx +54 -0
- package/src/modules/headlessChat/index.tsx +1903 -0
- package/src/modules/headlessChat/referenceCom/DeleteModal.tsx +75 -0
- package/src/modules/headlessChat/referenceCom/DrawerContent.tsx +136 -0
- package/src/modules/headlessChat/referenceCom/DrawerDatabase.tsx +102 -0
- package/src/modules/headlessChat/referenceCom/DrawerGraphPreview.tsx +86 -0
- package/src/modules/headlessChat/referenceCom/DrawerPreview.tsx +73 -0
- package/src/modules/headlessChat/referenceCom/DrawerTitle.tsx +26 -0
- package/src/modules/headlessChat/referenceCom/RenameModal.tsx +86 -0
- package/src/modules/headlessChat/referenceCom/TagCom.tsx +30 -0
- package/src/modules/headlessChat/style.less +3 -0
- package/src/modules/headlessChat/types.ts +23 -0
- package/src/modules/headlessChat/utils/index.ts +348 -0
- package/src/modules/knowledgeBase/index.tsx +58 -0
- package/src/modules/knowledgeBase/server.ts +196 -0
- package/src/modules/knowledgebaseDetails/KnowledgeBaseDetails.tsx +169 -0
- package/src/modules/knowledgebaseDetails/components/KnowledgeBaseSummaryCard.tsx +193 -0
- package/src/modules/knowledgebaseDetails/components/fileManagementParts.tsx +534 -0
- package/src/modules/knowledgebaseDetails/components/index.ts +3 -0
- package/src/modules/knowledgebaseDetails/index.ts +3 -0
- package/src/modules/knowledgebaseDetails/modules/ConfigModule.tsx +49 -0
- package/src/modules/knowledgebaseDetails/modules/FaqModule.tsx +47 -0
- package/src/modules/knowledgebaseDetails/modules/KnowledgeParseModule.tsx +771 -0
- package/src/modules/knowledgebaseDetails/modules/RetrievalTestModule.tsx +49 -0
- package/src/modules/knowledgebaseDetails/modules/UploadManagementModule.tsx +49 -0
- package/src/modules/knowledgebaseDetails/modules/types.ts +44 -0
- package/src/modules/knowledgebaseDetails/modules-shim.d.ts +14 -0
- package/src/modules/knowledgebaseDetails/servers/analysis.ts +5 -0
- package/src/modules/knowledgebaseDetails/servers/index.ts +318 -0
- package/src/modules/login/components/Login/LoginBox/index.tsx +105 -0
- package/src/modules/login/components/Login/RegisterBox/index.tsx +181 -0
- package/src/modules/login/components/Login/index.tsx +100 -0
- package/src/modules/login/i18n.ts +217 -0
- package/src/modules/login/index.tsx +113 -0
- package/src/modules/login/style.css +3 -0
- package/src/modules/login/useServices.ts +53 -0
- package/src/modules/login/utils.ts +42 -0
- package/src/modules/modelManage/ConfigDrawer.tsx +267 -0
- package/src/modules/modelManage/ReplaceModal.tsx +113 -0
- package/src/modules/modelManage/assets/empty.png +0 -0
- package/src/modules/modelManage/const.ts +51 -0
- package/src/modules/modelManage/i18n.ts +407 -0
- package/src/modules/modelManage/index.tsx +668 -0
- package/src/modules/modelManage/server.ts +231 -0
- package/src/modules/nodegraph/index.tsx +1 -0
- package/src/modules/search/assets/Icon-history.svg +8 -0
- package/src/modules/search/assets/answerAwartar.png +0 -0
- package/src/modules/search/assets/doc.png +0 -0
- package/src/modules/search/assets/genera.gif +0 -0
- package/src/modules/search/assets/icon-robot.svg +9 -0
- package/src/modules/search/assets/icon-search-bar.svg +14 -0
- package/src/modules/search/assets/icon-sub-title.svg +3 -0
- package/src/modules/search/assets/icon-title.svg +9 -0
- package/src/modules/search/assets/icon-zoomOut.svg +9 -0
- package/src/modules/search/assets/iconAi.svg +9 -0
- package/src/modules/search/assets/pdf.png +0 -0
- package/src/modules/search/assets/ppt.png +0 -0
- package/src/modules/search/assets/search.svg +3 -0
- package/src/modules/search/assets/selected.svg +4 -0
- package/src/modules/search/assets/txt.png +0 -0
- package/src/modules/search/assets/xls.png +0 -0
- package/src/modules/search/components/AssisSelect.tsx +137 -0
- package/src/modules/search/components/Editor/ChatViewEditor.tsx +261 -0
- package/src/modules/search/components/Editor/aichat.css +1 -0
- package/src/modules/search/components/Editor/constant.ts +13 -0
- package/src/modules/search/components/Editor/index.tsx +113 -0
- package/src/modules/search/components/Editor/plugins/autofomatRules.ts +332 -0
- package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +20 -0
- package/src/modules/search/components/Editor/plugins/createIndexes.tsx +38 -0
- package/src/modules/search/components/Editor/plugins/displayer.ts +298 -0
- package/src/modules/search/components/Editor/plugins/imageClick.tsx +32 -0
- package/src/modules/search/components/Editor/plugins/myplugin.tsx +98 -0
- package/src/modules/search/components/Editor/ui/avatar.tsx +19 -0
- package/src/modules/search/components/Editor/ui/blockquote-element.tsx +21 -0
- package/src/modules/search/components/Editor/ui/button.tsx +58 -0
- package/src/modules/search/components/Editor/ui/calendar.tsx +68 -0
- package/src/modules/search/components/Editor/ui/caption.tsx +46 -0
- package/src/modules/search/components/Editor/ui/checkbox.tsx +27 -0
- package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +188 -0
- package/src/modules/search/components/Editor/ui/code-block-element.css +434 -0
- package/src/modules/search/components/Editor/ui/code-block-element.tsx +39 -0
- package/src/modules/search/components/Editor/ui/code-leaf.tsx +24 -0
- package/src/modules/search/components/Editor/ui/code-line-element.tsx +10 -0
- package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +21 -0
- package/src/modules/search/components/Editor/ui/column-element.tsx +30 -0
- package/src/modules/search/components/Editor/ui/column-group-element.tsx +94 -0
- package/src/modules/search/components/Editor/ui/command.tsx +75 -0
- package/src/modules/search/components/Editor/ui/comment-avatar.tsx +22 -0
- package/src/modules/search/components/Editor/ui/comment-create-form.tsx +37 -0
- package/src/modules/search/components/Editor/ui/comment-item.tsx +74 -0
- package/src/modules/search/components/Editor/ui/comment-leaf.tsx +49 -0
- package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +42 -0
- package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +22 -0
- package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +32 -0
- package/src/modules/search/components/Editor/ui/comment-value.tsx +34 -0
- package/src/modules/search/components/Editor/ui/comments-popover.tsx +63 -0
- package/src/modules/search/components/Editor/ui/date-element.tsx +83 -0
- package/src/modules/search/components/Editor/ui/dialog.tsx +63 -0
- package/src/modules/search/components/Editor/ui/draggable.tsx +177 -0
- package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +180 -0
- package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +85 -0
- package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +28 -0
- package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +76 -0
- package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +8 -0
- package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +51 -0
- package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +77 -0
- package/src/modules/search/components/Editor/ui/heading-element.tsx +48 -0
- package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +17 -0
- package/src/modules/search/components/Editor/ui/hr-element.tsx +30 -0
- package/src/modules/search/components/Editor/ui/icons.tsx +267 -0
- package/src/modules/search/components/Editor/ui/image-element.tsx +74 -0
- package/src/modules/search/components/Editor/ui/inline-combobox.tsx +368 -0
- package/src/modules/search/components/Editor/ui/input.tsx +25 -0
- package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +218 -0
- package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +20 -0
- package/src/modules/search/components/Editor/ui/link-element.tsx +29 -0
- package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +161 -0
- package/src/modules/search/components/Editor/ui/list-element.tsx +30 -0
- package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +24 -0
- package/src/modules/search/components/Editor/ui/media-embed-element.tsx +133 -0
- package/src/modules/search/components/Editor/ui/media-popover.tsx +97 -0
- package/src/modules/search/components/Editor/ui/mention-element.tsx +43 -0
- package/src/modules/search/components/Editor/ui/mention-input-element.tsx +141 -0
- package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +93 -0
- package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +67 -0
- package/src/modules/search/components/Editor/ui/paragraph-element.tsx +4 -0
- package/src/modules/search/components/Editor/ui/placeholder.tsx +52 -0
- package/src/modules/search/components/Editor/ui/popover.tsx +32 -0
- package/src/modules/search/components/Editor/ui/resizable.tsx +66 -0
- package/src/modules/search/components/Editor/ui/separator.tsx +25 -0
- package/src/modules/search/components/Editor/ui/style.less +12 -0
- package/src/modules/search/components/Editor/ui/table-cell-element.tsx +143 -0
- package/src/modules/search/components/Editor/ui/table-element.tsx +243 -0
- package/src/modules/search/components/Editor/ui/table-row-element.tsx +22 -0
- package/src/modules/search/components/Editor/ui/tableValue.tsx +135 -0
- package/src/modules/search/components/Editor/ui/todo-list-element.tsx +43 -0
- package/src/modules/search/components/Editor/ui/toggle-element.tsx +31 -0
- package/src/modules/search/components/Editor/ui/toolbar.tsx +157 -0
- package/src/modules/search/components/Editor/ui/tooltip.tsx +65 -0
- package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +160 -0
- package/src/modules/search/components/Editor/ui/with-draggables.tsx +175 -0
- package/src/modules/search/components/FileList.tsx +287 -0
- package/src/modules/search/components/ImageGroupView/index.tsx +85 -0
- package/src/modules/search/components/ResultContent.tsx +232 -0
- package/src/modules/search/components/SearchInput.tsx +232 -0
- package/src/modules/search/components/SearchLanding.tsx +74 -0
- package/src/modules/search/components/SearchView.tsx +563 -0
- package/src/modules/search/components/SimpleEditor.tsx +158 -0
- package/src/modules/search/components/SimpleFileList.tsx +215 -0
- package/src/modules/search/index.tsx +10 -0
- package/src/modules/search/reademe.md +1 -0
- package/src/modules/search/servers/apis.tsx +19 -0
- package/src/modules/search/servers/index.ts +184 -0
- package/src/modules/search/style.less +503 -0
- package/src/modules/search/type.ts +22 -0
- package/src/modules/search/utils.ts +34 -0
- package/src/modules/sensitive/i18n.ts +391 -0
- package/src/modules/sensitive/index.tsx +604 -0
- package/src/modules/sensitive/sensitiveEditor.tsx +543 -0
- package/src/modules/sensitive/server.ts +197 -0
- package/src/modules/sensitiveId/AutoTag.tsx +311 -0
- package/src/modules/sensitiveId/UploadModal.tsx +181 -0
- package/src/modules/sensitiveId/VirtualWrap.tsx +125 -0
- package/src/modules/sensitiveId/index.tsx +253 -0
- package/src/modules/sensitiveId/server.ts +142 -0
- package/src/modules/streamFilesReader/GientechStreamReader.tsx +1658 -0
- package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
- package/src/modules/streamFilesReader/components/Header/index.tsx +297 -0
- package/src/modules/streamFilesReader/index.tsx +3 -0
- package/src/style.css +6 -0
- package/src/type.d.ts +0 -0
- package/src/utils/commonFn.tsx +153 -0
- package/src/utils/decryptApiKey.ts +40 -0
- package/src/utils/gientechCommon/components/AppError.tsx +32 -0
- package/src/utils/gientechCommon/components/AppLoading.tsx +75 -0
- package/src/utils/gientechCommon/components/DeleteModal.tsx +75 -0
- package/src/utils/gientechCommon/components/DisplayError.tsx +33 -0
- package/src/utils/gientechCommon/components/DisplayLoading.tsx +38 -0
- package/src/utils/gientechCommon/components/FeedBackModal.tsx +319 -0
- package/src/utils/gientechCommon/components/FileCardCommon.tsx +82 -0
- package/src/utils/gientechCommon/components/FileManager/index.tsx +418 -0
- package/src/utils/gientechCommon/components/FileManager/style.css +5 -0
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +583 -0
- package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +359 -0
- package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +245 -0
- package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +209 -0
- package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
- package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +148 -0
- package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +14 -0
- package/src/utils/gientechCommon/components/RenameModal.tsx +86 -0
- package/src/utils/gientechCommon/components/style.less +11 -0
- package/src/utils/gientechCommon/configs/commonConfig.ts +2 -0
- package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
- package/src/utils/gientechCommon/configs/stylesConfig.ts +142 -0
- package/src/utils/gientechCommon/hooks/AichatUseController.tsx +761 -0
- package/src/utils/gientechCommon/hooks/style.less +8 -0
- package/src/utils/gientechCommon/hooks/useFileDisplayTools.tsx +352 -0
- package/src/utils/gientechCommon/hooks/useFileManager.ts +169 -0
- package/src/utils/gientechCommon/slate/converters/deserializers.ts +763 -0
- package/src/utils/gientechCommon/slate/converters/mockData.ts +232 -0
- package/src/utils/gientechCommon/slate/converters/slateConverters.ts +258 -0
- package/src/utils/gientechCommon/slate/richElements/index.tsx +499 -0
- package/src/utils/gientechCommon/utils/fileUtils.ts +86 -0
- package/src/utils/gientechCommon/utils/index.ts +386 -0
- package/src/utils/gientechCommon/utils/request.ts +37 -0
- package/src/utils/gientechCommon/utils/serverFn.ts +172 -0
- package/src/utils/index.tsx +186 -0
- package/src/utils/testconfigs/demologin/index.tsx +32 -0
- package/src/utils/testconfigs/index.ts +66 -0
- package/src/vite-env.d.ts +49 -0
- package/stats.html +4949 -0
- package/tailwind.config.js +170 -0
- package/tsconfig.app.json +31 -0
- package/tsconfig.app.tsbuildinfo +11 -0
- package/tsconfig.json +17 -0
- package/tsconfig.node.json +23 -0
- package/tsconfig.node.tsbuildinfo +1 -0
- package/vite.config.app.ts +91 -0
- package/vite.config.ts +238 -0
- package/assets/index-BIEKgWu0.js +0 -27
- package/assets/index-C1tyXsqQ.js +0 -943
- package/assets/index-CzZQWA2P.js +0 -1
- package/assets/index-DPA1HCWQ.js +0 -1372
- package/assets/index-DPyRygOA.js +0 -745
- package/assets/plus-BICgMvz9.js +0 -6
- package/assets/search-CD5YKija.js +0 -6
- package/assets/style2.css +0 -1
- package/assets/style5.css +0 -1
- package/chat.js +0 -1
- package/chatCompare.js +0 -1
- package/database.js +0 -20
- package/index.js +0 -1
- package/modelManage.js +0 -1
- package/streamFilesReader.js +0 -1
- /package/{assets → dist/assets}/Doris.png +0 -0
- /package/{assets → dist/assets}/PostgreSQL.png +0 -0
- /package/{assets → dist/assets}/SQLServer.png +0 -0
- /package/{assets → dist/assets}/empty.png +0 -0
- /package/{assets → dist/assets}/homeBg.png +0 -0
- /package/{assets → dist/assets}/index-CpW6Dhpp.js +0 -0
- /package/{assets → dist/assets}/left.jpg +0 -0
- /package/{assets → dist/assets}/logoImg.png +0 -0
- /package/{assets → dist/assets}/style.css +0 -0
- /package/{assets → dist/assets}/style3.css +0 -0
- /package/{assets → dist/assets}/style4.css +0 -0
- /package/{assets → dist/assets}/worker-BbpylX7l.js +0 -0
- /package/{assistantConfig.d.ts → dist/assistantConfig.d.ts} +0 -0
- /package/{chat.d.ts → dist/chat.d.ts} +0 -0
- /package/{chatCompare.d.ts → dist/chatCompare.d.ts} +0 -0
- /package/{database.d.ts → dist/database.d.ts} +0 -0
- /package/{databaseId.d.ts → dist/databaseId.d.ts} +0 -0
- /package/{databaseTable.d.ts → dist/databaseTable.d.ts} +0 -0
- /package/{icons → dist/icons}/answerAwartar.png +0 -0
- /package/{icons → dist/icons}/docx-file.png +0 -0
- /package/{icons → dist/icons}/folder.png +0 -0
- /package/{icons → dist/icons}/html.png +0 -0
- /package/{icons → dist/icons}/image.png +0 -0
- /package/{icons → dist/icons}/jpg-file.png +0 -0
- /package/{icons → dist/icons}/json.png +0 -0
- /package/{icons → dist/icons}/md.png +0 -0
- /package/{icons → dist/icons}/pdf.png +0 -0
- /package/{icons → dist/icons}/pptx.png +0 -0
- /package/{icons → dist/icons}/questionAwartar.png +0 -0
- /package/{icons → dist/icons}/sheets.png +0 -0
- /package/{icons → dist/icons}/txt.png +0 -0
- /package/{icons → dist/icons}/xlsx.png +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{modelManage.d.ts → dist/modelManage.d.ts} +0 -0
- /package/{sensitive.d.ts → dist/sensitive.d.ts} +0 -0
- /package/{streamFilesReader.d.ts → dist/streamFilesReader.d.ts} +0 -0
- /package/{vite.svg → dist/vite.svg} +0 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# Chat 和 HeadlessChat 统一方案分析
|
|
2
|
+
|
|
3
|
+
## 一、现状分析
|
|
4
|
+
|
|
5
|
+
### 1.1 共同部分(可统一)
|
|
6
|
+
|
|
7
|
+
#### 1.1.1 文件管理核心逻辑
|
|
8
|
+
- ✅ `normalizeFileItem` - 文件结构标准化函数
|
|
9
|
+
- ✅ `mergeFiles` - 文件合并去重函数
|
|
10
|
+
- ✅ `pollFileStatus` - 文件解析状态轮询逻辑
|
|
11
|
+
- ✅ `fileManagerData` 状态管理(uploadedFiles)
|
|
12
|
+
- ✅ `fileStatuses` 状态管理(上传/解析状态)
|
|
13
|
+
- ✅ `uploaded_file:removeFromTemp` 事件处理逻辑
|
|
14
|
+
- ✅ 文件上传、解析、删除的完整流程(handleSenderSend 中的文件处理部分)
|
|
15
|
+
|
|
16
|
+
#### 1.1.2 消息处理逻辑
|
|
17
|
+
- ✅ `handleSenderSend` - 核心消息发送逻辑(文件上传 + AI请求)
|
|
18
|
+
- ✅ `handleReSenderSend` - 消息重发逻辑
|
|
19
|
+
- ✅ `setFeed` - 反馈处理(赞/踩)
|
|
20
|
+
- ✅ `fetchRecommendQuestions` - 推荐问题获取
|
|
21
|
+
- ✅ `addEmptyMessage` - 添加空消息
|
|
22
|
+
- ✅ `setLastEmptyMessage` - 设置最后一条空消息
|
|
23
|
+
|
|
24
|
+
#### 1.1.3 事件处理
|
|
25
|
+
- ✅ `chatbox:copy` - 复制消息
|
|
26
|
+
- ✅ `chatbox:like/dislike` - 点赞/踩
|
|
27
|
+
- ✅ `chatbox:repeat` - 重发消息
|
|
28
|
+
- ✅ `chatbox:follow_up_question_click` - 追问点击
|
|
29
|
+
- ✅ `sender:stop` - 停止发送
|
|
30
|
+
- ✅ `sender:clear` - 清空输入
|
|
31
|
+
- ✅ `sender:configChange` - 配置变化
|
|
32
|
+
- ✅ `references:click` - 引用点击
|
|
33
|
+
|
|
34
|
+
#### 1.1.4 组件配置
|
|
35
|
+
- ✅ `businessCustomComponents.AiChatBox` - AI消息渲染逻辑
|
|
36
|
+
- ✅ `businessCustomComponents.UserChatBox` - 用户消息渲染逻辑
|
|
37
|
+
- ✅ `businessCustomComponents.DisplayLoading/DisplayError` - 加载/错误组件
|
|
38
|
+
- ✅ `businessCustomComponents.AppLoading/AppError` - 应用级加载/错误组件
|
|
39
|
+
|
|
40
|
+
#### 1.1.5 工具函数
|
|
41
|
+
- ✅ `utils/index.ts` - 完全相同的工具函数集合
|
|
42
|
+
|
|
43
|
+
### 1.2 差异部分(需要定制)
|
|
44
|
+
|
|
45
|
+
#### 1.2.1 初始化逻辑
|
|
46
|
+
- **chat**:
|
|
47
|
+
- 拉取助手列表(`/qa/search/config/helper/list`)
|
|
48
|
+
- 拉取会话列表第一页(`/qa/dialogue/list`)
|
|
49
|
+
- 支持会话列表分页
|
|
50
|
+
- **headlessChat**:
|
|
51
|
+
- 不需要助手列表(使用传入的 configId)
|
|
52
|
+
- 不需要会话列表(只创建新会话)
|
|
53
|
+
- 自动创建临时会话(`sysType: 'TEMPORARY'`)
|
|
54
|
+
|
|
55
|
+
#### 1.2.2 会话管理
|
|
56
|
+
- **chat**:
|
|
57
|
+
- 完整的会话列表管理(Conversations组件)
|
|
58
|
+
- 支持会话重命名、删除
|
|
59
|
+
- 支持会话分页加载
|
|
60
|
+
- 支持助手切换
|
|
61
|
+
- **headlessChat**:
|
|
62
|
+
- 无会话列表UI
|
|
63
|
+
- 无会话管理功能
|
|
64
|
+
- 固定使用传入的 configId
|
|
65
|
+
|
|
66
|
+
#### 1.2.3 文件上传方式
|
|
67
|
+
- **chat**:
|
|
68
|
+
- 使用隐藏的 `<input type="file">`
|
|
69
|
+
- 通过 `sender:action_upload` 事件触发
|
|
70
|
+
- 文件直接上传到发送器
|
|
71
|
+
- **headlessChat**:
|
|
72
|
+
- 使用独立的 `FileManager` 组件
|
|
73
|
+
- 通过 `sender:action_history` 打开文件管理器
|
|
74
|
+
- 文件先添加到 `pendingFiles`,再统一上传
|
|
75
|
+
|
|
76
|
+
#### 1.2.4 UI组件差异
|
|
77
|
+
- **chat**:
|
|
78
|
+
- 有侧边栏(sidebar)显示会话历史
|
|
79
|
+
- 有文件展示工具(FileDisplayTools)在 chatHeader
|
|
80
|
+
- 使用 RenameModal、DeleteModal
|
|
81
|
+
- **headlessChat**:
|
|
82
|
+
- 无侧边栏(sidebar = undefined)
|
|
83
|
+
- 使用独立的 FileManager Drawer
|
|
84
|
+
- 使用 DrawerPreview、DrawerContent 等预览组件
|
|
85
|
+
|
|
86
|
+
#### 1.2.5 配置参数
|
|
87
|
+
- **chat**:
|
|
88
|
+
- 支持 `senderConfig` 深度合并
|
|
89
|
+
- 支持 `CustomComponents` 完整覆盖
|
|
90
|
+
- 支持 `appLoadingConfig`
|
|
91
|
+
- 支持 `SidebarTabConfig`
|
|
92
|
+
- **headlessChat**:
|
|
93
|
+
- 简单的 `configId`、`welcomeContent`
|
|
94
|
+
- 简单的 `CustomComponents` 合并
|
|
95
|
+
- 无侧边栏配置
|
|
96
|
+
|
|
97
|
+
#### 1.2.6 ReferenceBar 差异
|
|
98
|
+
- **chat**:
|
|
99
|
+
- 通过 `eventsEmit` 透传事件到父组件
|
|
100
|
+
- 部分事件处理在父组件
|
|
101
|
+
- **headlessChat**:
|
|
102
|
+
- 内部处理所有事件
|
|
103
|
+
- 有独立的 `eventsEmit` 函数
|
|
104
|
+
|
|
105
|
+
## 二、统一方案设计
|
|
106
|
+
|
|
107
|
+
### 2.1 架构设计
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
gientech/src/modules/
|
|
111
|
+
├── chat/
|
|
112
|
+
│ ├── index.tsx (主入口,使用 shared hooks)
|
|
113
|
+
│ ├── Conversations/ (会话列表组件,chat 独有)
|
|
114
|
+
│ └── ...
|
|
115
|
+
├── headlessChat/
|
|
116
|
+
│ ├── index.tsx (主入口,使用 shared hooks)
|
|
117
|
+
│ └── ...
|
|
118
|
+
└── shared/ (新增)
|
|
119
|
+
├── hooks/
|
|
120
|
+
│ ├── useFileManager.ts (文件管理逻辑)
|
|
121
|
+
│ ├── useMessageHandler.ts (消息处理逻辑)
|
|
122
|
+
│ └── useChatEvents.ts (事件处理逻辑)
|
|
123
|
+
├── utils/
|
|
124
|
+
│ ├── fileUtils.ts (文件工具函数)
|
|
125
|
+
│ └── messageUtils.ts (消息工具函数)
|
|
126
|
+
└── types.ts (共享类型定义)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 2.2 核心 Hook 设计
|
|
130
|
+
|
|
131
|
+
#### 2.2.1 `useFileManager` - 文件管理 Hook
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
interface UseFileManagerOptions {
|
|
135
|
+
url: string;
|
|
136
|
+
token: string;
|
|
137
|
+
CSRFToken?: string;
|
|
138
|
+
activeSessionId?: string;
|
|
139
|
+
currentChatData: any;
|
|
140
|
+
onError?: (error: any) => void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface UseFileManagerReturn {
|
|
144
|
+
fileManagerData: { uploadedFiles: any[] };
|
|
145
|
+
fileStatuses: any[];
|
|
146
|
+
setFileManagerData: (data: { uploadedFiles: any[] }) => void;
|
|
147
|
+
setFileStatuses: (statuses: any[]) => void;
|
|
148
|
+
pollFileStatus: (uids: string[], callbacks: PollCallbacks) => void;
|
|
149
|
+
handleRemoveFromTemp: (uid: string, queryId?: string) => Promise<void>;
|
|
150
|
+
normalizeFileItem: (f: any) => any;
|
|
151
|
+
mergeFiles: (oldFiles: any[], newFiles: any[]) => any[];
|
|
152
|
+
// ... 其他文件相关方法
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**职责**:
|
|
157
|
+
- 文件状态管理(uploadedFiles、fileStatuses)
|
|
158
|
+
- 文件上传、解析、删除逻辑
|
|
159
|
+
- 文件结构标准化和合并
|
|
160
|
+
- 文件轮询状态检查
|
|
161
|
+
|
|
162
|
+
#### 2.2.2 `useMessageHandler` - 消息处理 Hook
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
interface UseMessageHandlerOptions {
|
|
166
|
+
url: string;
|
|
167
|
+
token: string;
|
|
168
|
+
CSRFToken?: string;
|
|
169
|
+
activeSessionId?: string;
|
|
170
|
+
currentChatData: any;
|
|
171
|
+
conversationList: any[];
|
|
172
|
+
setChatData: (updater: any) => void;
|
|
173
|
+
setConversationList: (updater: any) => void;
|
|
174
|
+
setAppStatus: (updater: any) => void;
|
|
175
|
+
api_startChat_re: (params: any, callback?: any) => void;
|
|
176
|
+
addEmptyMessage: (data: any) => void;
|
|
177
|
+
setLastEmptyMessage: (data: any) => void;
|
|
178
|
+
fileManager: UseFileManagerReturn;
|
|
179
|
+
senderSwitchValues: { [key: string]: boolean };
|
|
180
|
+
configId?: string;
|
|
181
|
+
sysType?: 'INT_SESSION' | 'TEMPORARY';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface UseMessageHandlerReturn {
|
|
185
|
+
handleSenderSend: (data: any, clearFn: () => void) => Promise<void>;
|
|
186
|
+
handleReSenderSend: (data: any) => void;
|
|
187
|
+
setFeed: (queryId: string, result: number | null) => void;
|
|
188
|
+
fetchRecommendQuestions: (queryId: string) => Promise<void>;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**职责**:
|
|
193
|
+
- 消息发送逻辑(包含文件上传流程)
|
|
194
|
+
- 消息重发逻辑
|
|
195
|
+
- 反馈处理
|
|
196
|
+
- 推荐问题获取
|
|
197
|
+
|
|
198
|
+
#### 2.2.3 `useChatEvents` - 事件处理 Hook
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
interface UseChatEventsOptions {
|
|
202
|
+
// 各种处理函数的引用
|
|
203
|
+
handleSenderSend: (data: any, clearFn: () => void) => Promise<void>;
|
|
204
|
+
handleReSenderSend: (data: any) => void;
|
|
205
|
+
handleThumbsup: (data: any) => void;
|
|
206
|
+
handleItemClick?: (data: any) => void;
|
|
207
|
+
handleConversationCreate?: (data: any) => void;
|
|
208
|
+
fileManager: UseFileManagerReturn;
|
|
209
|
+
// ... 其他依赖
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface UseChatEventsReturn {
|
|
213
|
+
mergedEventsEmit: (eventName: string, data: any) => void;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**职责**:
|
|
218
|
+
- 统一事件分发
|
|
219
|
+
- 事件处理逻辑聚合
|
|
220
|
+
- 支持扩展自定义事件处理
|
|
221
|
+
|
|
222
|
+
### 2.3 文件结构标准化
|
|
223
|
+
|
|
224
|
+
#### 2.3.1 共享工具函数提取
|
|
225
|
+
|
|
226
|
+
将以下函数提取到 `shared/utils/fileUtils.ts`:
|
|
227
|
+
- `normalizeFileItem`
|
|
228
|
+
- `mergeFiles`
|
|
229
|
+
- `pollFileStatus` (提取为独立函数,接受配置参数)
|
|
230
|
+
|
|
231
|
+
#### 2.3.2 共享类型定义
|
|
232
|
+
|
|
233
|
+
在 `shared/types.ts` 中定义:
|
|
234
|
+
- `FileManagerData`
|
|
235
|
+
- `FileStatus`
|
|
236
|
+
- `MessageHandlerOptions`
|
|
237
|
+
- `ChatEventsOptions`
|
|
238
|
+
- 等共享类型
|
|
239
|
+
|
|
240
|
+
### 2.4 实施步骤
|
|
241
|
+
|
|
242
|
+
#### 阶段一:提取文件管理逻辑
|
|
243
|
+
1. ✅ 创建 `shared/hooks/useFileManager.ts`
|
|
244
|
+
2. ✅ 提取 `normalizeFileItem`、`mergeFiles` 到 `shared/utils/fileUtils.ts`
|
|
245
|
+
3. ✅ 提取 `pollFileStatus` 逻辑到 hook
|
|
246
|
+
4. ✅ 提取 `uploaded_file:removeFromTemp` 处理逻辑
|
|
247
|
+
5. ✅ 在 chat 和 headlessChat 中替换为使用 hook
|
|
248
|
+
|
|
249
|
+
#### 阶段二:提取消息处理逻辑
|
|
250
|
+
1. ✅ 创建 `shared/hooks/useMessageHandler.ts`
|
|
251
|
+
2. ✅ 提取 `handleSenderSend` 核心逻辑(文件上传部分)
|
|
252
|
+
3. ✅ 提取 `handleReSenderSend` 逻辑
|
|
253
|
+
4. ✅ 提取 `setFeed`、`fetchRecommendQuestions` 逻辑
|
|
254
|
+
5. ✅ 在 chat 和 headlessChat 中替换为使用 hook
|
|
255
|
+
|
|
256
|
+
#### 阶段三:提取事件处理逻辑
|
|
257
|
+
1. ✅ 创建 `shared/hooks/useChatEvents.ts`
|
|
258
|
+
2. ✅ 提取通用事件处理逻辑
|
|
259
|
+
3. ✅ 支持自定义事件处理器注入
|
|
260
|
+
4. ✅ 在 chat 和 headlessChat 中替换为使用 hook
|
|
261
|
+
|
|
262
|
+
#### 阶段四:统一 ReferenceBar
|
|
263
|
+
1. ✅ 分析两个 ReferenceBar 的差异
|
|
264
|
+
2. ✅ 提取共同逻辑到共享组件
|
|
265
|
+
3. ✅ 通过 props 控制差异行为
|
|
266
|
+
4. ✅ 统一两个模块使用同一个 ReferenceBar
|
|
267
|
+
|
|
268
|
+
#### 阶段五:测试和优化
|
|
269
|
+
1. ✅ 确保 chat 功能正常
|
|
270
|
+
2. ✅ 确保 headlessChat 功能正常
|
|
271
|
+
3. ✅ 确保文件管理逻辑一致
|
|
272
|
+
4. ✅ 性能优化和代码清理
|
|
273
|
+
|
|
274
|
+
## 三、关键注意事项
|
|
275
|
+
|
|
276
|
+
### 3.1 保持向后兼容
|
|
277
|
+
- 两个模块的对外接口(props)保持不变
|
|
278
|
+
- 只重构内部实现,不改变外部 API
|
|
279
|
+
|
|
280
|
+
### 3.2 差异化处理
|
|
281
|
+
- 通过 hook 的 options 参数传递差异配置
|
|
282
|
+
- 通过条件判断处理不同场景
|
|
283
|
+
- 保持代码清晰,避免过度抽象
|
|
284
|
+
|
|
285
|
+
### 3.3 文件管理器逻辑统一
|
|
286
|
+
- **重点**: chat 已经更新了 filemanager 逻辑,需要确保 headlessChat 使用相同的逻辑
|
|
287
|
+
- 统一 `uploaded_file:removeFromTemp` 事件处理
|
|
288
|
+
- 统一文件状态同步逻辑(从 reference 字段同步到 fileManagerData)
|
|
289
|
+
- 统一文件上传、解析、删除流程
|
|
290
|
+
|
|
291
|
+
### 3.4 测试重点
|
|
292
|
+
- 文件上传流程
|
|
293
|
+
- 文件解析状态轮询
|
|
294
|
+
- 文件删除(removeFromTemp)
|
|
295
|
+
- 文件状态同步(从 AI 消息的 reference 字段)
|
|
296
|
+
- 消息发送(有文件/无文件)
|
|
297
|
+
- 消息重发
|
|
298
|
+
|
|
299
|
+
## 四、预期收益
|
|
300
|
+
|
|
301
|
+
1. **代码复用**: 减少 ~40% 的重复代码
|
|
302
|
+
2. **维护性**: 文件管理逻辑统一维护,一处修改两处生效
|
|
303
|
+
3. **一致性**: 确保两个模块的文件管理行为完全一致
|
|
304
|
+
4. **可扩展性**: 新增功能只需在 shared hooks 中添加,自动应用到两个模块
|
|
305
|
+
5. **可测试性**: 共享逻辑可以独立测试
|
|
306
|
+
|
|
307
|
+
## 五、风险评估
|
|
308
|
+
|
|
309
|
+
1. **重构风险**: 大规模重构可能引入 bug
|
|
310
|
+
- **缓解**: 分阶段实施,每个阶段充分测试
|
|
311
|
+
|
|
312
|
+
2. **性能影响**: Hook 抽象可能带来性能开销
|
|
313
|
+
- **缓解**: 使用 useMemo、useCallback 优化
|
|
314
|
+
|
|
315
|
+
3. **复杂度增加**: 抽象层可能增加理解成本
|
|
316
|
+
- **缓解**: 完善的文档和注释
|
|
317
|
+
|
|
318
|
+
## 六、下一步行动
|
|
319
|
+
|
|
320
|
+
1. 创建 shared 目录结构
|
|
321
|
+
2. 开始阶段一:提取文件管理逻辑
|
|
322
|
+
3. 同步更新 chat 和 headlessChat 使用新的 hook
|
|
323
|
+
4. 测试验证功能正常
|
|
324
|
+
5. 继续后续阶段
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="24" height="24" rx="3.55556" fill="#925BFF"/>
|
|
3
|
+
<path d="M11.9971 11.265C15.249 11.265 17.8891 10.443 17.8891 9.423V7.95288C17.8891 6.93291 15.2492 6.11084 11.9971 6.11084C8.74513 6.11084 6.10504 6.93276 6.10504 7.95288V9.42285C6.10504 10.437 8.73898 11.265 11.9971 11.265Z" fill="white"/>
|
|
4
|
+
<path d="M11.9971 14.577C15.249 14.577 17.8891 13.7551 17.8891 12.7349V10.527C17.8891 11.5469 15.2492 12.369 11.9971 12.369C8.74513 12.369 6.10504 11.5471 6.10504 10.527V12.7349C6.10504 13.749 8.73898 14.577 11.9971 14.577Z" fill="white"/>
|
|
5
|
+
<path d="M11.9971 15.681C8.7451 15.681 6.11102 14.859 6.11102 13.839V16.0469C6.11102 17.0609 8.74496 17.889 12.0031 17.889C15.255 17.889 17.8951 17.0671 17.8951 16.0469V13.8391C17.889 14.859 15.249 15.681 11.9971 15.681Z" fill="white"/>
|
|
6
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="24" height="24" rx="3.55556" fill="#00C1B8"/>
|
|
3
|
+
<path d="M17.9887 12.582C18.1207 13.6621 17.2267 14.5801 16.1526 14.4901C15.3306 14.4181 14.6645 13.7521 14.6045 12.924C14.5745 12.558 14.6645 12.21 14.8445 11.9159C14.9285 11.7779 14.9045 11.6039 14.8025 11.4899L14.3885 11.0339C14.2805 10.9139 14.1005 10.8839 13.9565 10.9559C13.6144 11.1239 13.2304 11.2199 12.8224 11.2199C12.6244 11.2199 12.4324 11.1959 12.2464 11.1539C12.0963 11.1179 11.9463 11.1779 11.8563 11.3039L11.2803 12.1259C11.1783 12.276 11.1963 12.474 11.3223 12.606C11.8983 13.188 12.2464 13.9921 12.2284 14.8741C12.1924 16.4702 10.9203 17.7963 9.32417 17.9043C7.45804 18.0243 5.90994 16.4942 6.00595 14.6281C6.08995 13.038 7.38604 11.7599 8.97614 11.6879C9.42017 11.6699 9.8402 11.7419 10.2302 11.8919C10.3922 11.9519 10.5722 11.8979 10.6743 11.7599L11.1663 11.0579C11.2743 10.9019 11.2503 10.6919 11.1123 10.5658C10.5302 10.0498 10.1882 9.26976 10.2662 8.4177C10.3742 7.18162 11.3823 6.18556 12.6244 6.09555C14.1245 5.98154 15.3846 7.17562 15.3846 8.65172C15.3846 9.20376 15.2106 9.70779 14.9105 10.1278C14.8085 10.2658 14.8205 10.4578 14.9345 10.5898L15.3786 11.0819C15.4746 11.1899 15.6306 11.2259 15.7626 11.1779C16.0086 11.0939 16.2786 11.0639 16.5606 11.1119C17.3047 11.2259 17.8987 11.8319 17.9887 12.582Z" fill="white"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="20" height="20" rx="2.22222" fill="#00B2F9"/>
|
|
3
|
+
<path d="M5.3125 13.9672V13.975C5.32812 14.6938 5.89922 15.2734 6.61875 15.2734H13.9062C14.3375 15.2734 14.6875 14.9289 14.6875 14.4977V5.50703C14.6875 5.40447 14.6673 5.30292 14.628 5.20818C14.5887 5.11344 14.5312 5.02736 14.4586 4.95488C14.3861 4.8824 14.2999 4.82492 14.2052 4.78575C14.1104 4.74657 14.0088 4.72646 13.9062 4.72656H6.875C6.01172 4.72656 5.3125 5.42031 5.3125 6.28359V13.9672ZM7.5 9.24531V6.25C7.5 6.07813 7.64062 5.9375 7.8125 5.9375H9.6875C9.86016 5.9375 10 6.07813 10 6.25V9.24531C10 9.30716 9.98175 9.36762 9.94741 9.41906C9.91308 9.47049 9.86425 9.51058 9.80712 9.53426C9.74999 9.55793 9.68712 9.56412 9.62647 9.55204C9.56581 9.53996 9.51011 9.51016 9.46641 9.46641L8.97109 8.97109C8.94207 8.94204 8.90761 8.91899 8.86967 8.90326C8.83173 8.88754 8.79107 8.87944 8.75 8.87944C8.70893 8.87944 8.66827 8.88754 8.63033 8.90326C8.59239 8.91899 8.55793 8.94204 8.52891 8.97109L8.03359 9.46641C7.98989 9.51016 7.93418 9.53996 7.87353 9.55204C7.81288 9.56412 7.75001 9.55793 7.69288 9.53426C7.63575 9.51058 7.58692 9.47049 7.55259 9.41906C7.51825 9.36762 7.49995 9.30716 7.5 9.24531ZM6.54375 14.2063C6.45208 14.1156 6.40625 14.0052 6.40625 13.875C6.40625 13.7458 6.45208 13.6354 6.54375 13.5438C6.6349 13.4521 6.74531 13.4062 6.875 13.4062H13.5938V14.3438H6.875C6.74531 14.3438 6.6349 14.2979 6.54375 14.2063Z" fill="white"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="20" height="20" rx="2.22222" fill="#FFCC3C"/>
|
|
3
|
+
<path d="M13.3263 12.7917H7.53763C7.33426 12.8116 7.17923 12.9825 7.17923 13.1867C7.17923 13.3909 7.33426 13.5618 7.53763 13.5817H13.3277C13.3828 13.5871 13.4384 13.5809 13.4909 13.5634C13.5435 13.546 13.5918 13.5178 13.6328 13.4806C13.6738 13.4434 13.7066 13.3981 13.729 13.3474C13.7514 13.2968 13.763 13.2421 13.763 13.1867C13.763 13.1313 13.7514 13.0766 13.729 13.026C13.7066 12.9753 13.6738 12.93 13.6328 12.8928C13.5918 12.8556 13.5435 12.8274 13.4909 12.8099C13.4384 12.7925 13.3828 12.7863 13.3277 12.7917H13.3263ZM9.19742 7.60418L8.84232 8.55193H9.57339L9.19742 7.60418Z" fill="white"/>
|
|
4
|
+
<path d="M15.3211 14.7707V6.9692H14.4704V14.3543H6.70511C6.06668 14.3392 5.55704 13.8173 5.55704 13.1788C5.55704 12.5402 6.06668 12.0184 6.70511 12.0033H13.352C13.4644 12.0075 13.5735 11.9648 13.653 11.8852C13.6923 11.8459 13.7231 11.7988 13.7434 11.747C13.7638 11.6952 13.7731 11.6398 13.771 11.5842V5.20102C13.7736 5.14526 13.7646 5.08958 13.7445 5.03752C13.7244 4.98546 13.6936 4.93816 13.6542 4.89865C13.6148 4.85915 13.5675 4.82832 13.5155 4.80812C13.4634 4.78792 13.4077 4.7788 13.352 4.78134H6.70511C5.60281 4.80136 4.71609 5.69369 4.70291 6.79599V13.1759C4.71609 14.283 5.61038 15.1773 6.71756 15.1905H14.8893C15.0042 15.1994 15.1173 15.1585 15.1999 15.0782C15.2407 15.0385 15.2727 14.9905 15.2936 14.9375C15.3145 14.8845 15.3239 14.8276 15.3211 14.7707ZM8.98782 6.78585H9.44888L10.7213 9.92562H10.2475L9.9075 9.06759H8.51871L8.19742 9.92562H7.72354L8.98782 6.78585Z" fill="white"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import ResourceBinderItem from './ResourceBinderItem';
|
|
3
|
+
import SearchableSelector, { type SearchableSelectorRef } from './SearchableSelector';
|
|
4
|
+
import { Button, Modal } from 'antd';
|
|
5
|
+
import { Plus } from 'lucide-react';
|
|
6
|
+
import Icon from '../assets/databse.svg';
|
|
7
|
+
import AxiosInstance from '../server';
|
|
8
|
+
|
|
9
|
+
const maxCount = 10;
|
|
10
|
+
|
|
11
|
+
const DatabaseSection = ({ url, token, role, eventsEmit, sectionData, disabled }: any) => {
|
|
12
|
+
const [options, setOptions]: any = useState([]);
|
|
13
|
+
const [data, setData]: any = useState([]);
|
|
14
|
+
const [isModalShow, setIsModalShow] = useState(false);
|
|
15
|
+
const selectorRef = useRef<SearchableSelectorRef>(null);
|
|
16
|
+
|
|
17
|
+
const { fetchDatabases } = AxiosInstance({
|
|
18
|
+
url,
|
|
19
|
+
token,
|
|
20
|
+
role,
|
|
21
|
+
eventsEmit,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
getList();
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (sectionData) {
|
|
30
|
+
let _data = [] as any;
|
|
31
|
+
(sectionData || []).map((db: any) => {
|
|
32
|
+
const _targetDb = (options || []).find((i: any) => i.key === db.key);
|
|
33
|
+
if (_targetDb) {
|
|
34
|
+
const { key, label } = _targetDb;
|
|
35
|
+
_data.push({
|
|
36
|
+
key,
|
|
37
|
+
label,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
setData(_data);
|
|
42
|
+
}
|
|
43
|
+
}, [sectionData, options]);
|
|
44
|
+
|
|
45
|
+
const getList = async () => {
|
|
46
|
+
try {
|
|
47
|
+
const res = await fetchDatabases();
|
|
48
|
+
if (res) {
|
|
49
|
+
const options = (res || []).map((item: any) => {
|
|
50
|
+
return {
|
|
51
|
+
key: item.primitiveName,
|
|
52
|
+
label: item.name,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
setOptions(options);
|
|
56
|
+
}
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const handleEventsEmit = (name: string, eventsData?: any) => {
|
|
63
|
+
switch (name) {
|
|
64
|
+
case 'removeItem':
|
|
65
|
+
const _data = data.filter((p: any) => p.key !== eventsData.key);
|
|
66
|
+
setData([..._data]);
|
|
67
|
+
eventsEmit && eventsEmit('database_selected', _data);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const handleOk = () => {
|
|
73
|
+
// 通过 ref 获取选中的项
|
|
74
|
+
const selectedItems = selectorRef.current?.getSelectedItems() || [];
|
|
75
|
+
setData(selectedItems);
|
|
76
|
+
setIsModalShow(false);
|
|
77
|
+
eventsEmit && eventsEmit('database_selected', selectedItems);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div style={{ borderBottom: '1px solid #E5E6EB', padding: '12px 0 ' }}>
|
|
82
|
+
<div className="flex items-center justify-between">
|
|
83
|
+
<div className="flex items-center">
|
|
84
|
+
<img src={Icon} />
|
|
85
|
+
<span
|
|
86
|
+
className="font-medium "
|
|
87
|
+
style={{
|
|
88
|
+
marginLeft: '10px',
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
数据库
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div className="flex items-center gap-2">
|
|
96
|
+
<Button
|
|
97
|
+
color="primary"
|
|
98
|
+
variant="outlined"
|
|
99
|
+
size="small"
|
|
100
|
+
icon={<Plus size={14} />}
|
|
101
|
+
onClick={() => setIsModalShow(true)}
|
|
102
|
+
disabled={data.length >= maxCount || disabled}
|
|
103
|
+
>
|
|
104
|
+
添加
|
|
105
|
+
</Button>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
{data?.length > 0 && (
|
|
109
|
+
<ResourceBinderItem
|
|
110
|
+
countText={data?.length > 0 ? `已选:${data?.length}个数据库` : undefined}
|
|
111
|
+
eventsEmit={handleEventsEmit}
|
|
112
|
+
data={data}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
<Modal
|
|
117
|
+
width={740}
|
|
118
|
+
title="选择数据库"
|
|
119
|
+
className="assistant-config-resource-bind-modal"
|
|
120
|
+
okText="确定"
|
|
121
|
+
cancelText="取消"
|
|
122
|
+
open={isModalShow}
|
|
123
|
+
onOk={handleOk}
|
|
124
|
+
onCancel={() => setIsModalShow(false)}
|
|
125
|
+
destroyOnHidden
|
|
126
|
+
>
|
|
127
|
+
<SearchableSelector
|
|
128
|
+
ref={selectorRef}
|
|
129
|
+
dataSource={options}
|
|
130
|
+
value={data}
|
|
131
|
+
searchPlaceholder="搜索名称..."
|
|
132
|
+
width="700px"
|
|
133
|
+
height="500px"
|
|
134
|
+
title="数据库"
|
|
135
|
+
maxCount={maxCount}
|
|
136
|
+
renderItem={item => {
|
|
137
|
+
return (
|
|
138
|
+
<div className="flex ">
|
|
139
|
+
<img src={Icon} alt="add" />
|
|
140
|
+
<span
|
|
141
|
+
style={{
|
|
142
|
+
marginLeft: 8,
|
|
143
|
+
marginRight: 8,
|
|
144
|
+
overflow: 'hidden',
|
|
145
|
+
textOverflow: 'ellipsis',
|
|
146
|
+
whiteSpace: 'nowrap',
|
|
147
|
+
}}
|
|
148
|
+
title={item.label}
|
|
149
|
+
>
|
|
150
|
+
{item.label}
|
|
151
|
+
</span>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}}
|
|
155
|
+
renderSelectedItem={(item, updateItemData) => {
|
|
156
|
+
return (
|
|
157
|
+
<div className="flex items-center">
|
|
158
|
+
<img src={Icon} alt="add" />
|
|
159
|
+
<div style={{ marginLeft: '12px' }}>
|
|
160
|
+
<div style={{ fontWeight: 500 }}>{item.label}</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
</Modal>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default DatabaseSection;
|