@gientech/modual 1.9.4-fix.1 → 1.9.4-fix.3
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/{dist/assets/GientechStreamReader-DydY9Vu3.js → assets/GientechStreamReader-9YdiPc7N.js} +1 -1
- package/{dist/assets/index-7FYeBShT.js → assets/index-BKe5FgcC.js} +1 -1
- package/{dist/assets/index-rkRJ-e_U.js → assets/index-CF21Mbsz.js} +1 -1
- package/{dist/assets/index-4Ac00q5P.js → assets/index-D72cKELw.js} +1 -1
- package/{dist/assets/index-q0nZjKAG.js → assets/index-DdVFXD_y.js} +1 -1
- package/{dist/assets/index-DBPtDW8Y.js → assets/index-DwoTKC3G.js} +1 -1
- package/{dist/assets/index-CwGOSlVC.js → assets/index-R8HnY_Ab.js} +1 -1
- package/{dist/assets/index-antI2hFx.js → assets/index-g-SUxfJH.js} +45 -45
- package/{dist/assets/index-B2rczyCX.js → assets/index-h59-yboB.js} +1 -1
- package/{dist/assets/index-CQMGllKT.js → assets/index-j0kQJd0a.js} +1 -1
- package/{dist/assets/index-DJPAws60.js → assets/index-x8IlxRuv.js} +72 -72
- package/{dist/assets/plus-qlmqrjBc.js → assets/plus-V9zUoSq6.js} +1 -1
- package/{dist/assets/style-BeYL_E4J.js → assets/style-CGmZ5osp.js} +1 -1
- package/assets/style4.css +1 -0
- package/{dist/assets/x-DxuhxSb6.js → assets/x-CnaaLGJF.js} +1 -1
- package/assistantConfig.js +1 -0
- package/chat.js +829 -0
- package/{dist/database.js → database.js} +1 -1
- package/databaseId.js +1 -0
- package/{dist/databaseTable.js → databaseTable.js} +1 -1
- package/index.js +1 -0
- package/{dist/modelManage.js → modelManage.js} +1 -1
- package/package.json +43 -106
- package/{dist/sensitive.js → sensitive.js} +1 -1
- package/streamFilesReader.js +1 -0
- package/.editorconfig +0 -38
- package/.prettierignore +0 -16
- package/.prettierrc +0 -17
- package/USAGE.md +0 -247
- package/bash.exe.stackdump +0 -40
- package/components.json +0 -21
- package/dist/README.md +0 -643
- package/dist/assets/style4.css +0 -1
- package/dist/assistantConfig.js +0 -1
- package/dist/chat.js +0 -815
- package/dist/databaseId.js +0 -1
- package/dist/index.js +0 -1
- package/dist/package.json +0 -68
- package/dist/streamFilesReader.js +0 -1
- package/doc_assets/2.png +0 -0
- package/doc_assets/demo.md +0 -27
- package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +0 -2
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +0 -23699
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +0 -1
- package/doc_assets/demos/dist-app/index.html +0 -14
- package/doc_assets/demos/dist-app/vite.svg +0 -1
- package/doc_assets/images/1.png +0 -0
- package/doc_assets/images/3.png +0 -0
- package/doc_assets/images/component-screenshot.png +0 -1
- package/doc_assets/install.md +0 -5
- 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 +0 -504
- package/eslint.config.js +0 -92
- package/index.html +0 -13
- package/package.json.demo-backup +0 -109
- package/postcss.config.cjs +0 -19
- 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 +0 -1
- package/public/worker/pdf.worker.min.js +0 -22
- package/rag/assets/Doris.3ZRHc3Fu.png +0 -0
- package/rag/assets/PostgreSQL.DuLqLAFX.png +0 -0
- package/rag/assets/SQLServer.CWyNu24v.png +0 -0
- package/rag/assets/empty.BfkDKJsb.png +0 -0
- package/rag/assets/homeBg.Mr_kGuA9.png +0 -0
- package/rag/assets/index.Bd0tNzw0.js +0 -2797
- package/rag/assets/index.D6t67hlu.css +0 -1
- package/rag/assets/left.KBHV5h7q.jpg +0 -0
- package/rag/assets/logoImg.Gmp_tdkD.png +0 -0
- package/rag/assets/worker-BbpylX7l.DptbXke_.js +0 -13
- package/rag/icons/answerAwartar.png +0 -0
- package/rag/icons/docx-file.png +0 -0
- package/rag/icons/folder.png +0 -0
- package/rag/icons/html.png +0 -0
- package/rag/icons/image.png +0 -0
- package/rag/icons/jpg-file.png +0 -0
- package/rag/icons/json.png +0 -0
- package/rag/icons/md.png +0 -0
- package/rag/icons/pdf.png +0 -0
- package/rag/icons/pptx.png +0 -0
- package/rag/icons/questionAwartar.png +0 -0
- package/rag/icons/sheets.png +0 -0
- package/rag/icons/txt.png +0 -0
- package/rag/icons/xlsx.png +0 -0
- package/scripts/README.md +0 -133
- package/scripts/build-demo.js +0 -88
- package/scripts/decrypt-api-key.js +0 -95
- package/scripts/demo-selector.js +0 -216
- package/scripts/dev-demo.js +0 -76
- package/scripts/preview-demo.js +0 -130
- package/scripts/run-demo.bat +0 -34
- 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/img.png +0 -0
- package/src/assets/img/pdf.png +0 -0
- package/src/assets/img/ppt.png +0 -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 +0 -41
- package/src/examples/Demo/index.tsx +0 -12
- package/src/examples/LoginPage/index.tsx +0 -18
- package/src/examples/chat/components/DrawerGraphPreview.tsx +0 -78
- package/src/examples/chat/index.tsx +0 -162
- package/src/examples/chat/logo03.png +0 -0
- package/src/examples/gientechStreamFilesReader/index.tsx +0 -951
- package/src/examples/headlessChat/index.tsx +0 -218
- package/src/examples/ragDatabaseDataPage/index.tsx +0 -40
- package/src/examples/ragDatabaseIdPage/index.tsx +0 -47
- package/src/examples/ragDatabasePage/index.tsx +0 -36
- package/src/examples/ragModelManagePage/index.tsx +0 -37
- package/src/examples/ragSearchPage/index.tsx +0 -0
- package/src/examples/ragSensitiveWordsPage/index.tsx +0 -32
- package/src/examples/streamFiles/index.tsx +0 -417
- package/src/lib_enter.ts +0 -43
- package/src/main.tsx +0 -5
- package/src/main.tsx.backup +0 -5
- package/src/modules/assistantConfig/assets/databse.svg +0 -6
- package/src/modules/assistantConfig/assets/empty.png +0 -0
- package/src/modules/assistantConfig/assets/graph.svg +0 -4
- package/src/modules/assistantConfig/assets/knowledge.svg +0 -4
- package/src/modules/assistantConfig/assets/sensitive.svg +0 -5
- package/src/modules/assistantConfig/components/Database.tsx +0 -171
- package/src/modules/assistantConfig/components/Graph.tsx +0 -177
- package/src/modules/assistantConfig/components/Knowledge.tsx +0 -276
- package/src/modules/assistantConfig/components/NotFoundContent.tsx +0 -21
- package/src/modules/assistantConfig/components/Paragraph.tsx +0 -51
- package/src/modules/assistantConfig/components/ParamsItem.tsx +0 -39
- package/src/modules/assistantConfig/components/ResourceBinderItem.tsx +0 -133
- package/src/modules/assistantConfig/components/SearchableSelector.tsx +0 -500
- package/src/modules/assistantConfig/components/Sensitive.tsx +0 -221
- package/src/modules/assistantConfig/components/SliderInput.tsx +0 -65
- package/src/modules/assistantConfig/constants.tsx +0 -75
- package/src/modules/assistantConfig/index.tsx +0 -706
- package/src/modules/assistantConfig/server.ts +0 -262
- package/src/modules/chat/Conversations/Item.tsx +0 -167
- package/src/modules/chat/Conversations/List.tsx +0 -210
- package/src/modules/chat/Conversations/groupByTime.ts +0 -39
- package/src/modules/chat/Conversations/index.tsx +0 -252
- package/src/modules/chat/ReferenceBar.tsx +0 -622
- package/src/modules/chat/constants.tsx +0 -56
- package/src/modules/chat/data.txt +0 -82
- package/src/modules/chat/index.tsx +0 -2087
- package/src/modules/chat/referenceCom/DeleteModal.tsx +0 -75
- package/src/modules/chat/referenceCom/DrawerContent.tsx +0 -136
- package/src/modules/chat/referenceCom/DrawerDatabase.tsx +0 -102
- package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +0 -86
- package/src/modules/chat/referenceCom/DrawerPreview.tsx +0 -73
- package/src/modules/chat/referenceCom/DrawerTitle.tsx +0 -26
- package/src/modules/chat/referenceCom/RenameModal.tsx +0 -86
- package/src/modules/chat/referenceCom/TagCom.tsx +0 -30
- package/src/modules/chat/style.less +0 -3
- package/src/modules/chat/types.ts +0 -17
- package/src/modules/chat/utils/index.ts +0 -348
- package/src/modules/database/CreateModal.tsx +0 -403
- 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 +0 -11
- package/src/modules/database/assets/database_add.svg +0 -53
- package/src/modules/database/assets/database_connect.svg +0 -66
- package/src/modules/database/assets/database_upload.svg +0 -29
- package/src/modules/database/assets/empty.png +0 -0
- package/src/modules/database/assets/mysql.svg +0 -14
- package/src/modules/database/index.tsx +0 -477
- package/src/modules/database/server.ts +0 -196
- package/src/modules/databaseId/CustomCom.tsx +0 -156
- package/src/modules/databaseId/EditConfig.tsx +0 -280
- package/src/modules/databaseId/UploadDrawer.tsx +0 -535
- package/src/modules/databaseId/assets/aiOptimize.svg +0 -10
- package/src/modules/databaseId/assets/empty.png +0 -0
- package/src/modules/databaseId/assets/template.svg +0 -6
- package/src/modules/databaseId/assets/upload.svg +0 -9
- package/src/modules/databaseId/assets/useTemp.svg +0 -6
- package/src/modules/databaseId/index.tsx +0 -769
- package/src/modules/databaseId/server.ts +0 -286
- package/src/modules/databaseId/style.css +0 -5
- package/src/modules/databaseTable/EditRowDrawer.tsx +0 -124
- package/src/modules/databaseTable/index.tsx +0 -359
- package/src/modules/databaseTable/server.ts +0 -180
- package/src/modules/headlessChat/ReferenceBar.tsx +0 -783
- package/src/modules/headlessChat/constants.tsx +0 -32
- package/src/modules/headlessChat/index.tsx +0 -1411
- package/src/modules/headlessChat/referenceCom/DeleteModal.tsx +0 -75
- package/src/modules/headlessChat/referenceCom/DrawerContent.tsx +0 -136
- package/src/modules/headlessChat/referenceCom/DrawerDatabase.tsx +0 -102
- package/src/modules/headlessChat/referenceCom/DrawerGraphPreview.tsx +0 -86
- package/src/modules/headlessChat/referenceCom/DrawerPreview.tsx +0 -73
- package/src/modules/headlessChat/referenceCom/DrawerTitle.tsx +0 -26
- package/src/modules/headlessChat/referenceCom/RenameModal.tsx +0 -86
- package/src/modules/headlessChat/referenceCom/TagCom.tsx +0 -30
- package/src/modules/headlessChat/style.less +0 -3
- package/src/modules/headlessChat/types.ts +0 -23
- package/src/modules/headlessChat/utils/index.ts +0 -348
- package/src/modules/login/components/Login/LoginBox/index.tsx +0 -102
- package/src/modules/login/components/Login/RegisterBox/index.tsx +0 -180
- package/src/modules/login/components/Login/index.tsx +0 -100
- package/src/modules/login/index.tsx +0 -106
- package/src/modules/login/style.css +0 -3
- package/src/modules/login/useServices.ts +0 -53
- package/src/modules/login/utils.ts +0 -42
- package/src/modules/modelManage/ConfigDrawer.tsx +0 -249
- package/src/modules/modelManage/ReplaceModal.tsx +0 -124
- package/src/modules/modelManage/assets/empty.png +0 -0
- package/src/modules/modelManage/const.ts +0 -51
- package/src/modules/modelManage/index.tsx +0 -599
- package/src/modules/modelManage/server.ts +0 -223
- package/src/modules/nodegraph/index.tsx +0 -1
- package/src/modules/search/assets/Icon-history.svg +0 -8
- 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 +0 -9
- package/src/modules/search/assets/icon-search-bar.svg +0 -14
- package/src/modules/search/assets/icon-sub-title.svg +0 -3
- package/src/modules/search/assets/icon-title.svg +0 -9
- package/src/modules/search/assets/icon-zoomOut.svg +0 -9
- package/src/modules/search/assets/iconAi.svg +0 -9
- 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 +0 -3
- package/src/modules/search/assets/selected.svg +0 -4
- 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 +0 -137
- package/src/modules/search/components/Editor/ChatViewEditor.tsx +0 -261
- package/src/modules/search/components/Editor/aichat.css +0 -1
- package/src/modules/search/components/Editor/constant.ts +0 -13
- package/src/modules/search/components/Editor/index.tsx +0 -113
- package/src/modules/search/components/Editor/plugins/autofomatRules.ts +0 -332
- package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +0 -20
- package/src/modules/search/components/Editor/plugins/createIndexes.tsx +0 -38
- package/src/modules/search/components/Editor/plugins/displayer.ts +0 -298
- package/src/modules/search/components/Editor/plugins/imageClick.tsx +0 -32
- package/src/modules/search/components/Editor/plugins/myplugin.tsx +0 -98
- package/src/modules/search/components/Editor/ui/avatar.tsx +0 -19
- package/src/modules/search/components/Editor/ui/blockquote-element.tsx +0 -21
- package/src/modules/search/components/Editor/ui/button.tsx +0 -58
- package/src/modules/search/components/Editor/ui/calendar.tsx +0 -68
- package/src/modules/search/components/Editor/ui/caption.tsx +0 -46
- package/src/modules/search/components/Editor/ui/checkbox.tsx +0 -27
- package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +0 -188
- package/src/modules/search/components/Editor/ui/code-block-element.css +0 -434
- package/src/modules/search/components/Editor/ui/code-block-element.tsx +0 -39
- package/src/modules/search/components/Editor/ui/code-leaf.tsx +0 -24
- package/src/modules/search/components/Editor/ui/code-line-element.tsx +0 -10
- package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +0 -21
- package/src/modules/search/components/Editor/ui/column-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/column-group-element.tsx +0 -94
- package/src/modules/search/components/Editor/ui/command.tsx +0 -75
- package/src/modules/search/components/Editor/ui/comment-avatar.tsx +0 -22
- package/src/modules/search/components/Editor/ui/comment-create-form.tsx +0 -37
- package/src/modules/search/components/Editor/ui/comment-item.tsx +0 -74
- package/src/modules/search/components/Editor/ui/comment-leaf.tsx +0 -49
- package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +0 -42
- package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +0 -22
- package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +0 -32
- package/src/modules/search/components/Editor/ui/comment-value.tsx +0 -34
- package/src/modules/search/components/Editor/ui/comments-popover.tsx +0 -63
- package/src/modules/search/components/Editor/ui/date-element.tsx +0 -83
- package/src/modules/search/components/Editor/ui/dialog.tsx +0 -63
- package/src/modules/search/components/Editor/ui/draggable.tsx +0 -177
- package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +0 -180
- package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +0 -85
- package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +0 -28
- package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +0 -76
- package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +0 -8
- package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +0 -51
- package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +0 -77
- package/src/modules/search/components/Editor/ui/heading-element.tsx +0 -48
- package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +0 -17
- package/src/modules/search/components/Editor/ui/hr-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/icons.tsx +0 -267
- package/src/modules/search/components/Editor/ui/image-element.tsx +0 -74
- package/src/modules/search/components/Editor/ui/inline-combobox.tsx +0 -368
- package/src/modules/search/components/Editor/ui/input.tsx +0 -25
- package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +0 -218
- package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +0 -20
- package/src/modules/search/components/Editor/ui/link-element.tsx +0 -29
- package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +0 -161
- package/src/modules/search/components/Editor/ui/list-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +0 -24
- package/src/modules/search/components/Editor/ui/media-embed-element.tsx +0 -133
- package/src/modules/search/components/Editor/ui/media-popover.tsx +0 -97
- package/src/modules/search/components/Editor/ui/mention-element.tsx +0 -43
- package/src/modules/search/components/Editor/ui/mention-input-element.tsx +0 -141
- package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +0 -93
- package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +0 -67
- package/src/modules/search/components/Editor/ui/paragraph-element.tsx +0 -4
- package/src/modules/search/components/Editor/ui/placeholder.tsx +0 -52
- package/src/modules/search/components/Editor/ui/popover.tsx +0 -32
- package/src/modules/search/components/Editor/ui/resizable.tsx +0 -66
- package/src/modules/search/components/Editor/ui/separator.tsx +0 -25
- package/src/modules/search/components/Editor/ui/style.less +0 -12
- package/src/modules/search/components/Editor/ui/table-cell-element.tsx +0 -143
- package/src/modules/search/components/Editor/ui/table-element.tsx +0 -243
- package/src/modules/search/components/Editor/ui/table-row-element.tsx +0 -22
- package/src/modules/search/components/Editor/ui/tableValue.tsx +0 -135
- package/src/modules/search/components/Editor/ui/todo-list-element.tsx +0 -43
- package/src/modules/search/components/Editor/ui/toggle-element.tsx +0 -31
- package/src/modules/search/components/Editor/ui/toolbar.tsx +0 -157
- package/src/modules/search/components/Editor/ui/tooltip.tsx +0 -65
- package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +0 -160
- package/src/modules/search/components/Editor/ui/with-draggables.tsx +0 -175
- package/src/modules/search/components/FileList.tsx +0 -287
- package/src/modules/search/components/ImageGroupView/index.tsx +0 -85
- package/src/modules/search/components/ResultContent.tsx +0 -232
- package/src/modules/search/components/SearchInput.tsx +0 -232
- package/src/modules/search/components/SearchLanding.tsx +0 -74
- package/src/modules/search/components/SearchView.tsx +0 -563
- package/src/modules/search/components/SimpleEditor.tsx +0 -158
- package/src/modules/search/components/SimpleFileList.tsx +0 -215
- package/src/modules/search/index.tsx +0 -10
- package/src/modules/search/reademe.md +0 -1
- package/src/modules/search/servers/apis.tsx +0 -19
- package/src/modules/search/servers/index.ts +0 -184
- package/src/modules/search/style.less +0 -503
- package/src/modules/search/type.ts +0 -22
- package/src/modules/search/utils.ts +0 -34
- package/src/modules/sensitive/index.tsx +0 -313
- package/src/modules/sensitive/server.ts +0 -122
- package/src/modules/streamFilesReader/GientechStreamReader.tsx +0 -1625
- package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
- package/src/modules/streamFilesReader/components/Header/index.tsx +0 -297
- package/src/modules/streamFilesReader/index.tsx +0 -3
- package/src/style.css +0 -6
- package/src/type.d.ts +0 -0
- package/src/utils/commonFn.tsx +0 -111
- package/src/utils/decryptApiKey.ts +0 -40
- package/src/utils/gientechCommon/components/AppError.tsx +0 -32
- package/src/utils/gientechCommon/components/AppLoading.tsx +0 -75
- package/src/utils/gientechCommon/components/DeleteModal.tsx +0 -75
- package/src/utils/gientechCommon/components/DisplayError.tsx +0 -33
- package/src/utils/gientechCommon/components/DisplayLoading.tsx +0 -38
- package/src/utils/gientechCommon/components/FeedBackModal.tsx +0 -318
- package/src/utils/gientechCommon/components/FileCardCommon.tsx +0 -82
- package/src/utils/gientechCommon/components/FileManager/index.tsx +0 -390
- package/src/utils/gientechCommon/components/FileManager/style.css +0 -5
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +0 -581
- package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +0 -339
- package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +0 -245
- package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +0 -209
- package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
- package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +0 -148
- package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +0 -14
- package/src/utils/gientechCommon/components/RenameModal.tsx +0 -86
- package/src/utils/gientechCommon/components/style.less +0 -11
- package/src/utils/gientechCommon/configs/commonConfig.ts +0 -2
- package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
- package/src/utils/gientechCommon/configs/stylesConfig.ts +0 -142
- package/src/utils/gientechCommon/hooks/AichatUseController.tsx +0 -417
- package/src/utils/gientechCommon/slate/converters/deserializers.ts +0 -763
- package/src/utils/gientechCommon/slate/converters/mockData.ts +0 -232
- package/src/utils/gientechCommon/slate/converters/slateConverters.ts +0 -258
- package/src/utils/gientechCommon/slate/richElements/index.tsx +0 -499
- package/src/utils/gientechCommon/utils/request.ts +0 -37
- package/src/utils/gientechCommon/utils/serverFn.ts +0 -172
- package/src/utils/index.tsx +0 -132
- package/src/utils/testconfigs/demologin/index.tsx +0 -32
- package/src/utils/testconfigs/index.ts +0 -59
- package/src/vite-env.d.ts +0 -11
- package/stats.html +0 -4949
- package/tailwind.config.js +0 -170
- package/tsconfig.app.json +0 -30
- package/tsconfig.app.tsbuildinfo +0 -11
- package/tsconfig.json +0 -13
- package/tsconfig.node.json +0 -22
- package/tsconfig.node.tsbuildinfo +0 -1
- package/vite.config.app.ts +0 -93
- package/vite.config.ts +0 -231
- package/workflows/release.yml +0 -60
- package//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 +0 -359
- /package/{dist/assets → assets}/Doris.png +0 -0
- /package/{dist/assets → assets}/PostgreSQL.png +0 -0
- /package/{dist/assets → assets}/SQLServer.png +0 -0
- /package/{dist/assets → assets}/database.svg +0 -0
- /package/{dist/assets → assets}/database_add.svg +0 -0
- /package/{dist/assets → assets}/database_connect.svg +0 -0
- /package/{dist/assets → assets}/database_upload.svg +0 -0
- /package/{dist/assets → assets}/databse.svg +0 -0
- /package/{dist/assets → assets}/defaultWeLogo.svg +0 -0
- /package/{dist/assets → assets}/empty.png +0 -0
- /package/{dist/assets → assets}/graph.svg +0 -0
- /package/{dist/assets → assets}/homeBg.png +0 -0
- /package/{dist/assets → assets}/index-CpW6Dhpp.js +0 -0
- /package/{dist/assets → assets}/knowledge.svg +0 -0
- /package/{dist/assets → assets}/left.jpg +0 -0
- /package/{dist/assets → assets}/logoImg.png +0 -0
- /package/{dist/assets → assets}/mysql.svg +0 -0
- /package/{dist/assets → assets}/sensitive.svg +0 -0
- /package/{dist/assets → assets}/style.css +0 -0
- /package/{dist/assets → assets}/style2.css +0 -0
- /package/{dist/assets → assets}/style3.css +0 -0
- /package/{dist/assets → assets}/worker-BbpylX7l.js +0 -0
- /package/{dist/assistantConfig.d.ts → assistantConfig.d.ts} +0 -0
- /package/{dist/chat.d.ts → chat.d.ts} +0 -0
- /package/{dist/database.d.ts → database.d.ts} +0 -0
- /package/{dist/databaseId.d.ts → databaseId.d.ts} +0 -0
- /package/{dist/databaseTable.d.ts → databaseTable.d.ts} +0 -0
- /package/{dist/icons → icons}/answerAwartar.png +0 -0
- /package/{dist/icons → icons}/docx-file.png +0 -0
- /package/{dist/icons → icons}/folder.png +0 -0
- /package/{dist/icons → icons}/html.png +0 -0
- /package/{dist/icons → icons}/image.png +0 -0
- /package/{dist/icons → icons}/jpg-file.png +0 -0
- /package/{dist/icons → icons}/json.png +0 -0
- /package/{dist/icons → icons}/md.png +0 -0
- /package/{dist/icons → icons}/pdf.png +0 -0
- /package/{dist/icons → icons}/pptx.png +0 -0
- /package/{dist/icons → icons}/questionAwartar.png +0 -0
- /package/{dist/icons → icons}/sheets.png +0 -0
- /package/{dist/icons → icons}/txt.png +0 -0
- /package/{dist/icons → icons}/xlsx.png +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/modelManage.d.ts → modelManage.d.ts} +0 -0
- /package/{dist/sensitive.d.ts → sensitive.d.ts} +0 -0
- /package/{dist/streamFilesReader.d.ts → streamFilesReader.d.ts} +0 -0
- /package/{dist/vite.svg → vite.svg} +0 -0
- /package/{dist/worker → worker}/pdf.worker.min.js +0 -0
|
@@ -1,1411 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState, useMemo, useRef } from 'react';
|
|
2
|
-
import { AiChat, AppStatusManager } from '@mxmweb/aichat';
|
|
3
|
-
import { ChatMessageAdapter } from '@mxmweb/rtext';
|
|
4
|
-
import request from '../../utils/gientechCommon/utils/request';
|
|
5
|
-
import { registerPDFWorker } from '../streamFilesReader';
|
|
6
|
-
registerPDFWorker('/worker/pdf.worker.min.js');
|
|
7
|
-
import {
|
|
8
|
-
getFeedbackList,
|
|
9
|
-
handleCancelFeedBack,
|
|
10
|
-
handleFeedBack,
|
|
11
|
-
removeFilefromTempUpload,
|
|
12
|
-
} from '../../utils/gientechCommon/utils/serverFn';
|
|
13
|
-
import { getFileTypeByName, toCopy } from '../../utils/commonFn';
|
|
14
|
-
import { uid } from 'uid';
|
|
15
|
-
import GientechNewChatWelcome from '../../utils/gientechCommon/components/Messages/GientechNewChatWelcome';
|
|
16
|
-
import AichatUseController from '../../utils/gientechCommon/hooks/AichatUseController';
|
|
17
|
-
import FeedBackModal from '../../utils/gientechCommon/components/FeedBackModal';
|
|
18
|
-
import { ConfigProvider, Drawer, message } from 'antd';
|
|
19
|
-
import FileManager from '../../utils/gientechCommon/components/FileManager';
|
|
20
|
-
import AppLoading from '../../utils/gientechCommon/components/AppLoading';
|
|
21
|
-
import DisplayLoading from '../../utils/gientechCommon/components/DisplayLoading';
|
|
22
|
-
import AppError from '../../utils/gientechCommon/components/AppError';
|
|
23
|
-
import DisplayError from '../../utils/gientechCommon/components/DisplayError';
|
|
24
|
-
import { DefaultSenderConfig } from './constants';
|
|
25
|
-
import { maxPollCount, maxPollInterval } from '../../utils/gientechCommon/configs/commonConfig';
|
|
26
|
-
import '@mxmweb/rtext/style.css';
|
|
27
|
-
import '@mxmweb/aichat/style.css';
|
|
28
|
-
import '@mxmweb/zui/style.css';
|
|
29
|
-
import { ReferenceBar } from './ReferenceBar';
|
|
30
|
-
import { DrawerType } from '../chat';
|
|
31
|
-
import { getMarkExcludeType, TempBaseUrl } from './utils';
|
|
32
|
-
import { DrawerContent } from './referenceCom/DrawerContent';
|
|
33
|
-
|
|
34
|
-
interface HeadlessChatAdopterProps {
|
|
35
|
-
token: string;
|
|
36
|
-
url?: string;
|
|
37
|
-
configId?: string;
|
|
38
|
-
useLogin?: boolean;
|
|
39
|
-
styles?: any;
|
|
40
|
-
welcomeContent?: string;
|
|
41
|
-
onError?: (ems: any) => void;
|
|
42
|
-
eventsEmit?: (eventName: string, data: any) => void;
|
|
43
|
-
[key: string]: any;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default function withHeadLessChatAdopter(
|
|
47
|
-
WrappedComponent: React.ComponentType<any> = AiChat as any
|
|
48
|
-
) {
|
|
49
|
-
/**
|
|
50
|
-
* GientechChatAdopter 高阶组件
|
|
51
|
-
* 封装了与Gientech后端服务的接口对接、状态管理、事件处理等核心业务逻辑
|
|
52
|
-
* @param {React.ComponentType} WrappedComponent - 需要包裹的基础聊天组件,默认为 AiChat
|
|
53
|
-
*/
|
|
54
|
-
return function GientechChatAdopter({
|
|
55
|
-
token,
|
|
56
|
-
url = 'http://localhost:8888',
|
|
57
|
-
welcomeContent = '欢迎来到小鲸智能助手,有什么能帮你的么?',
|
|
58
|
-
styles,
|
|
59
|
-
eventsEmit,
|
|
60
|
-
onError,
|
|
61
|
-
configId,
|
|
62
|
-
...rest
|
|
63
|
-
}: HeadlessChatAdopterProps) {
|
|
64
|
-
const [open, setOpen] = useState(false);
|
|
65
|
-
const [content, setContent] = useState<
|
|
66
|
-
| {
|
|
67
|
-
title: '';
|
|
68
|
-
file_type: '';
|
|
69
|
-
metadata: { offset: [] };
|
|
70
|
-
}
|
|
71
|
-
| any
|
|
72
|
-
>(null);
|
|
73
|
-
const [drawerType, setDrawerType] = useState<string>('mark');
|
|
74
|
-
const [curFileInfo, setCurFileInfo] = useState({
|
|
75
|
-
url: '',
|
|
76
|
-
parse_url: '',
|
|
77
|
-
file_type: '',
|
|
78
|
-
file_name: '',
|
|
79
|
-
});
|
|
80
|
-
// =================================================================
|
|
81
|
-
// State Management - 状态管理
|
|
82
|
-
// =================================================================
|
|
83
|
-
const [conversationList, setConversationList] = useState<any[]>([]); // 对话列表
|
|
84
|
-
const [chatData, setChatData] = useState<any[]>([]); // 所有对话的聊天记录
|
|
85
|
-
const [activeSessionId, setActiveSessionId] = useState<string | undefined>(undefined); // 当前激活的对话ID
|
|
86
|
-
const [recommandQuestions, setRecommandQuestions] = useState<any[]>([]); // 推荐问题列表
|
|
87
|
-
const [assistantList] = useState<any[]>([]); // 智能体(助手)列表
|
|
88
|
-
const [fileManagerOpen, setFileManagerOpen] = useState<boolean>(false); // 文件管理器抽屉的开关状态
|
|
89
|
-
const [appStatus, setAppStatus] = useState<AppStatusManager>({
|
|
90
|
-
display: 'ready', // 主聊天区域状态: ready, loading, processing, error, uploading
|
|
91
|
-
sender: 'ready', // 发送器状态: ready, processing, error, uploading
|
|
92
|
-
app: 'initializing', // 应用整体状态: initializing, ready, error
|
|
93
|
-
});
|
|
94
|
-
const [pendingFiles, setPendingFiles] = useState<any[]>([]); // 准备上传的文件列表
|
|
95
|
-
const [dynamicSenderConfig, setDynamicSenderConfig] = useState(DefaultSenderConfig); // 动态的发送器配置
|
|
96
|
-
const [fileStatuses, setFileStatuses] = useState<any[]>([]); // 用于跟踪每个上传文件的状态
|
|
97
|
-
const [fileManagerData, setFileManagerData] = useState<{ uploadedFiles: any[] }>({
|
|
98
|
-
uploadedFiles: [],
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// 新增:记录 sender switchs 的选中状态
|
|
102
|
-
const [senderSwitchValues, setSenderSwitchValues] = useState<{ [key: string]: boolean }>({});
|
|
103
|
-
|
|
104
|
-
// =================================================================
|
|
105
|
-
// Refs - 引用
|
|
106
|
-
// =================================================================
|
|
107
|
-
const prevActiveSessionId = useRef<string | undefined>(undefined); // 记录上一个激活的对话ID,用于对比变化
|
|
108
|
-
const setUploadedFilesRef = useRef<(files: any[]) => void>(undefined); // 引用核心组件的文件上传方法
|
|
109
|
-
const removeFileRef = useRef<(fileObj: any, idx: number, _type: string) => void>(undefined); // 引用核心组件的文件移除方法
|
|
110
|
-
|
|
111
|
-
const [feedParam, setFeedParam] = useState<{
|
|
112
|
-
queryId?: number | string | undefined;
|
|
113
|
-
restult?: number;
|
|
114
|
-
}>({});
|
|
115
|
-
const [openFeed, setOpenFeed] = useState(false);
|
|
116
|
-
const [feedBackList, setFeedBackList] = useState<any>([]);
|
|
117
|
-
const stoppedRef = useRef(false);
|
|
118
|
-
|
|
119
|
-
// =================================================================
|
|
120
|
-
// Custom Hooks - 自定义钩子
|
|
121
|
-
// =================================================================
|
|
122
|
-
// 引入SSE控制器,封装了流式请求、消息管理等复杂逻辑
|
|
123
|
-
const { api_startChat_re, addEmptyMessage, setLastEmptyMessage, stopStream } =
|
|
124
|
-
AichatUseController({
|
|
125
|
-
baseUrl: url,
|
|
126
|
-
token,
|
|
127
|
-
setChatData,
|
|
128
|
-
activeSessionId,
|
|
129
|
-
setAppStatus,
|
|
130
|
-
setConversationList,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// =================================================================
|
|
134
|
-
// Memoized Values - 缓存计算值
|
|
135
|
-
// =================================================================
|
|
136
|
-
|
|
137
|
-
// welcomeContent 伪消息唯一 id/time/queryId
|
|
138
|
-
const welcomeMsgId = useRef(uid(32));
|
|
139
|
-
const welcomeMsgQueryId = useRef(uid(32));
|
|
140
|
-
const welcomeMsgTime = useRef(Date.now());
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* 将智能体列表转换为以ID为键的Map,便于快速查找
|
|
144
|
-
*/
|
|
145
|
-
const assistantMap = useMemo(() => {
|
|
146
|
-
const map: Record<string, any> = {};
|
|
147
|
-
(assistantList || []).forEach(item => {
|
|
148
|
-
map[item.id] = item;
|
|
149
|
-
});
|
|
150
|
-
return map;
|
|
151
|
-
}, [assistantList]);
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 根据 activeSessionId 从 chatData 中筛选出当前对话的数据, 并合并智能体信息
|
|
155
|
-
*/
|
|
156
|
-
const currentChatData = useMemo(() => {
|
|
157
|
-
let data = chatData.find((c: any) => c.id === activeSessionId) || {
|
|
158
|
-
id: activeSessionId,
|
|
159
|
-
messages: [],
|
|
160
|
-
};
|
|
161
|
-
let messages = data.messages || [];
|
|
162
|
-
// 检查第一条是否已经是 welcome 消息,如果不是则插入
|
|
163
|
-
if (welcomeContent && (messages.length === 0 || !messages[0]?.isDefault)) {
|
|
164
|
-
messages = [
|
|
165
|
-
{
|
|
166
|
-
istype: 'ai',
|
|
167
|
-
content: welcomeContent,
|
|
168
|
-
time: welcomeMsgTime.current,
|
|
169
|
-
clientSideId: welcomeMsgId.current,
|
|
170
|
-
isWelcome: true,
|
|
171
|
-
isDefault: true,
|
|
172
|
-
queryId: welcomeMsgQueryId.current,
|
|
173
|
-
},
|
|
174
|
-
...messages,
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
// 如果第一条已经是 isDefault: true 的欢迎消息,确保它的 isWelcome 字段存在
|
|
178
|
-
if (messages[0]?.isDefault && !messages[0]?.isWelcome) {
|
|
179
|
-
messages[0].isWelcome = true;
|
|
180
|
-
}
|
|
181
|
-
const assistantInfo = data.configId ? assistantMap[data.configId] : null;
|
|
182
|
-
return {
|
|
183
|
-
...data,
|
|
184
|
-
messages,
|
|
185
|
-
assistantInfo,
|
|
186
|
-
};
|
|
187
|
-
}, [chatData, activeSessionId, assistantMap, welcomeContent]);
|
|
188
|
-
|
|
189
|
-
// 合并文件工具,避免重复,且保证每个文件有 file 字段
|
|
190
|
-
function mergeFiles(oldFiles: any[], newFiles: any[]) {
|
|
191
|
-
const map = new Map();
|
|
192
|
-
oldFiles.forEach(f => map.set(f.uid, normalizeFileItem(f)));
|
|
193
|
-
newFiles.forEach(f => map.set(f.uid, normalizeFileItem(f)));
|
|
194
|
-
return Array.from(map.values());
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// 文件结构标准化,保证有 file 字段
|
|
198
|
-
function normalizeFileItem(f: any) {
|
|
199
|
-
if (!f) return f;
|
|
200
|
-
if (f.file && f.file.name) return f;
|
|
201
|
-
// 兼容后端返回的扁平对象,优先 name,其次 fileName
|
|
202
|
-
const name = f.name || f.fileName || '';
|
|
203
|
-
return {
|
|
204
|
-
...f,
|
|
205
|
-
url: f.filePath || '',
|
|
206
|
-
uid: f.uid || '',
|
|
207
|
-
file: {
|
|
208
|
-
name,
|
|
209
|
-
size:
|
|
210
|
-
typeof f.size === 'string' && f.size.endsWith('MB')
|
|
211
|
-
? Number(f.size.replace('MB', '')) * 1024 * 1024
|
|
212
|
-
: f.size || 0,
|
|
213
|
-
type: f.type || '',
|
|
214
|
-
},
|
|
215
|
-
name, // 兜底 name 字段,供 UI 使用
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* 用 useEffect 监听 currentChatData 自动同步
|
|
221
|
-
*/
|
|
222
|
-
useEffect(() => {
|
|
223
|
-
if (!activeSessionId) return;
|
|
224
|
-
const conv = chatData.find((c: any) => c.id === activeSessionId);
|
|
225
|
-
let uploaded: any[] = [];
|
|
226
|
-
let hasReference = false;
|
|
227
|
-
if (conv && conv.messages) {
|
|
228
|
-
const lastAiMsg = [...(conv.messages || [])]
|
|
229
|
-
.reverse()
|
|
230
|
-
.find((msg: any) => msg.istype === 'ai');
|
|
231
|
-
if (lastAiMsg?.reference && lastAiMsg.resultType === 5) {
|
|
232
|
-
hasReference = true;
|
|
233
|
-
try {
|
|
234
|
-
const fileList = JSON.parse(lastAiMsg.reference);
|
|
235
|
-
uploaded = fileList.map((f: any) => normalizeFileItem(f));
|
|
236
|
-
} catch (e) {}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (hasReference) {
|
|
240
|
-
setFileManagerData({ uploadedFiles: uploaded });
|
|
241
|
-
}
|
|
242
|
-
// 否则不动,保持原有 uploadedFiles
|
|
243
|
-
}, [chatData]);
|
|
244
|
-
|
|
245
|
-
useEffect(() => {
|
|
246
|
-
setFileManagerData({ uploadedFiles: [] });
|
|
247
|
-
}, [activeSessionId]);
|
|
248
|
-
|
|
249
|
-
// =================================================================
|
|
250
|
-
// Side Effects (useEffect) - 副作用钩子
|
|
251
|
-
// =================================================================
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* 跟踪 activeSessionId 的变化:
|
|
255
|
-
* 1. 清理上一个无消息的临时会话
|
|
256
|
-
* 2. 更新推荐问题
|
|
257
|
-
*/
|
|
258
|
-
useEffect(() => {
|
|
259
|
-
// 切换会话时,检查上一个会话是否为临时且无消息
|
|
260
|
-
if (prevActiveSessionId.current && prevActiveSessionId.current !== activeSessionId) {
|
|
261
|
-
const prevId = prevActiveSessionId.current;
|
|
262
|
-
const prevConv = conversationList.find(c => c.sessionId === prevId && c.isNew);
|
|
263
|
-
const prevChat = chatData.find(c => c.id === prevId && c.isNew);
|
|
264
|
-
const prevHasMsg = prevChat && prevChat.messages && prevChat.messages.length > 0;
|
|
265
|
-
// 如果是临时的且没有消息,则自动删除
|
|
266
|
-
if (prevConv && !prevHasMsg) {
|
|
267
|
-
setConversationList(list => list.filter(c => c.sessionId !== prevId));
|
|
268
|
-
setChatData(list => list.filter(c => c.id !== prevId));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
prevActiveSessionId.current = activeSessionId;
|
|
272
|
-
|
|
273
|
-
// 更新推荐问题为当前对话的最后一个推荐问题
|
|
274
|
-
const historyRQ =
|
|
275
|
-
currentChatData.messages && currentChatData.messages.length > 0
|
|
276
|
-
? currentChatData.messages[currentChatData.messages.length - 1].recommendQuestion
|
|
277
|
-
: [];
|
|
278
|
-
setRecommandQuestions(historyRQ);
|
|
279
|
-
}, [activeSessionId, conversationList, chatData, currentChatData.messages]);
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* 1. useEffect 只拉助手列表,自动新建会话
|
|
283
|
-
*/
|
|
284
|
-
useEffect(() => {
|
|
285
|
-
setAppStatus(prev => ({ ...prev, app: 'initializing' }));
|
|
286
|
-
|
|
287
|
-
if (token) {
|
|
288
|
-
handleConversationCreate({ configId });
|
|
289
|
-
}
|
|
290
|
-
setAppStatus(prev => ({ ...prev, app: 'ready' }));
|
|
291
|
-
}, [url, token, configId]);
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* 当 activeSessionId 变化时,获取对应的聊天记录
|
|
295
|
-
*/
|
|
296
|
-
useEffect(() => {
|
|
297
|
-
if (!activeSessionId) return;
|
|
298
|
-
setAppStatus(prev => ({ ...prev, display: 'loading' }));
|
|
299
|
-
|
|
300
|
-
setAppStatus(prev => ({ ...prev, display: 'ready' }));
|
|
301
|
-
}, [activeSessionId, url, token]);
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* 监听文件数据变化,更新Sender上的角标
|
|
305
|
-
*/
|
|
306
|
-
useEffect(() => {
|
|
307
|
-
const totalFiles = fileManagerData.uploadedFiles.length;
|
|
308
|
-
setDynamicSenderConfig(prev => {
|
|
309
|
-
const newConfig = {
|
|
310
|
-
...prev,
|
|
311
|
-
actions: prev.actions.map(action =>
|
|
312
|
-
action.name === 'history' ? { ...action, badgeCount: totalFiles } : action
|
|
313
|
-
),
|
|
314
|
-
};
|
|
315
|
-
return newConfig;
|
|
316
|
-
});
|
|
317
|
-
}, [fileManagerData.uploadedFiles]);
|
|
318
|
-
useEffect(() => {
|
|
319
|
-
getFeedbackList({ url, token }, data => {
|
|
320
|
-
setFeedBackList(data);
|
|
321
|
-
});
|
|
322
|
-
}, []);
|
|
323
|
-
// =================================================================
|
|
324
|
-
// Core Functions - 核心功能函数
|
|
325
|
-
// =================================================================
|
|
326
|
-
|
|
327
|
-
// 1. 在组件作用域定义控制器和轮询停止标志
|
|
328
|
-
let uploadController: AbortController | null = null;
|
|
329
|
-
let stopPoll: (() => void) | null = null;
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* 轮询文件解析状态
|
|
333
|
-
* @param {string[]} uids - 文件UID列表
|
|
334
|
-
* @param {(serverStatuses: any[]) => void} onStatusUpdate - 每次获取到新状态后的回调
|
|
335
|
-
* @param {() => void} onComplete - 所有文件解析完成后的回调
|
|
336
|
-
* @param {(errorMsg: string) => void} onFail - 轮询失败或超时的回调
|
|
337
|
-
*/
|
|
338
|
-
const pollFileStatus = (
|
|
339
|
-
uids: string[],
|
|
340
|
-
onStatusUpdate: (serverStatuses: any[]) => void,
|
|
341
|
-
onComplete: () => void,
|
|
342
|
-
onFail: (errorMsg: string) => void
|
|
343
|
-
) => {
|
|
344
|
-
const uidsString = uids.join(',');
|
|
345
|
-
let pollCount = 0;
|
|
346
|
-
//const maxPollCount = maxPollCount;
|
|
347
|
-
stopPoll = () => {
|
|
348
|
-
stoppedRef.current = true;
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
const checkStatus = async () => {
|
|
352
|
-
if (stoppedRef.current) return;
|
|
353
|
-
if (pollCount >= maxPollCount) {
|
|
354
|
-
if (!stoppedRef.current) onFail('文件解析超时,请稍后重试');
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
pollCount++;
|
|
358
|
-
try {
|
|
359
|
-
const res = await request.get(
|
|
360
|
-
`${url}/index/knowledgeBase/file/getFileStatusByUids?uids=${uidsString}`,
|
|
361
|
-
{
|
|
362
|
-
headers: { Authorization: token },
|
|
363
|
-
}
|
|
364
|
-
);
|
|
365
|
-
if (stoppedRef.current) return;
|
|
366
|
-
if (res.data.success) {
|
|
367
|
-
const statuses = res.data.data;
|
|
368
|
-
if (!stoppedRef.current) onStatusUpdate(statuses);
|
|
369
|
-
const allDone = statuses.every((file: any) => file.status === 3);
|
|
370
|
-
if (allDone) {
|
|
371
|
-
if (!stoppedRef.current) onComplete();
|
|
372
|
-
} else {
|
|
373
|
-
if (!stoppedRef.current) setTimeout(checkStatus, maxPollInterval);
|
|
374
|
-
}
|
|
375
|
-
} else {
|
|
376
|
-
if (!stoppedRef.current) onFail(res.data.errorMsg || '查询文件状态失败');
|
|
377
|
-
}
|
|
378
|
-
} catch (error) {
|
|
379
|
-
onError?.(error);
|
|
380
|
-
if (stoppedRef.current) return;
|
|
381
|
-
onFail('查询文件状态时发生网络错误');
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
checkStatus();
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* 设置消息的反馈结果(赞/踩)
|
|
389
|
-
* @param {string} queryId - 消息ID
|
|
390
|
-
* @param {number} result - 反馈结果 (1: 赞, -1: 踩)
|
|
391
|
-
*/
|
|
392
|
-
const setFeed = (queryId: any, restult: any) => {
|
|
393
|
-
setChatData(chatList => {
|
|
394
|
-
const newList = [...chatList];
|
|
395
|
-
if (!newList[0]) return newList;
|
|
396
|
-
newList[0] = {
|
|
397
|
-
...newList[0],
|
|
398
|
-
messages: newList[0].messages.map((item: any) => {
|
|
399
|
-
if (item.queryId === queryId) {
|
|
400
|
-
return {
|
|
401
|
-
...item,
|
|
402
|
-
feedbackResult: restult,
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
return item;
|
|
406
|
-
}),
|
|
407
|
-
};
|
|
408
|
-
return newList;
|
|
409
|
-
});
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* 获取指定queryId的推荐问题
|
|
414
|
-
* @param {string} queryId - 消息ID
|
|
415
|
-
*/
|
|
416
|
-
const fetchRecommendQuestions = async (queryId: string) => {
|
|
417
|
-
if (!queryId) return;
|
|
418
|
-
try {
|
|
419
|
-
const res = await request.get(`${url}/qa/ai/recommendQuestion?queryId=${queryId}`, {
|
|
420
|
-
headers: { Authorization: token },
|
|
421
|
-
});
|
|
422
|
-
setRecommandQuestions(res.data?.data || []);
|
|
423
|
-
} catch (e) {
|
|
424
|
-
onError?.(e);
|
|
425
|
-
setRecommandQuestions([]);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* 处理重新发送消息逻辑
|
|
431
|
-
*/
|
|
432
|
-
function handleReSenderSend(data: any) {
|
|
433
|
-
const { content, audioUrl, filePaths, queryId } = data;
|
|
434
|
-
if (!content) return;
|
|
435
|
-
const _fileUids = (
|
|
436
|
-
typeof filePaths === 'string' && filePaths ? JSON.parse(filePaths) : filePaths || []
|
|
437
|
-
).map((item: any) => item.uid);
|
|
438
|
-
const now = Date.now();
|
|
439
|
-
setLastEmptyMessage({ now });
|
|
440
|
-
if (!activeSessionId) return;
|
|
441
|
-
setAppStatus(pre => {
|
|
442
|
-
return {
|
|
443
|
-
...pre,
|
|
444
|
-
display: 'processing',
|
|
445
|
-
sender: 'processing',
|
|
446
|
-
};
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
data.clearFn && data.clearFn();
|
|
450
|
-
setConversationList(list =>
|
|
451
|
-
list.map(c => (c.sessionId === activeSessionId ? { ...c, gmtModified: now } : c))
|
|
452
|
-
);
|
|
453
|
-
api_startChat_re(
|
|
454
|
-
{
|
|
455
|
-
configId: configId || currentChatData.configId,
|
|
456
|
-
content,
|
|
457
|
-
fileUids: _fileUids,
|
|
458
|
-
lastDate: now,
|
|
459
|
-
name: currentChatData.label || '',
|
|
460
|
-
queryId: queryId,
|
|
461
|
-
sessionId: activeSessionId,
|
|
462
|
-
type: audioUrl ? 'audioUrl' : 'text',
|
|
463
|
-
audioUrl,
|
|
464
|
-
sysType: 'TEMPORARY',
|
|
465
|
-
enableThinking: !!senderSwitchValues.reasoning,
|
|
466
|
-
enableWebsearch: !!senderSwitchValues.netSearch,
|
|
467
|
-
qaChannel: senderSwitchValues.qaChannel,
|
|
468
|
-
} as any,
|
|
469
|
-
() => {
|
|
470
|
-
fetchRecommendQuestions(queryId);
|
|
471
|
-
}
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* 处理消息发送(核心逻辑)
|
|
477
|
-
* 1. 包含文件:先上传文件,成功后再发消息
|
|
478
|
-
* 2. 新建会话:先调用创建会话接口,成功后再发消息
|
|
479
|
-
* 3. 普通消息:直接发送
|
|
480
|
-
* @param {object} data - 消息数据
|
|
481
|
-
*/
|
|
482
|
-
async function handleSenderSend(data: any, clearFn: () => void) {
|
|
483
|
-
const queryId = 'query-' + uid(32);
|
|
484
|
-
// 1. 立即插入空壳消息
|
|
485
|
-
let localCurrentFiles = undefined;
|
|
486
|
-
if (data.files && data.files.length > 0) {
|
|
487
|
-
localCurrentFiles = data.files.map((fileItem: any) => ({
|
|
488
|
-
name: fileItem.file.name,
|
|
489
|
-
size: fileItem.file.size,
|
|
490
|
-
type: fileItem.file.type,
|
|
491
|
-
filePath: fileItem.filePath || '',
|
|
492
|
-
convertedFilePath: fileItem.convertedFilePath || '',
|
|
493
|
-
uid: fileItem.uid || '',
|
|
494
|
-
}));
|
|
495
|
-
}
|
|
496
|
-
addEmptyMessage({
|
|
497
|
-
content: data.content || data.text || '',
|
|
498
|
-
queryId,
|
|
499
|
-
currentFiles: localCurrentFiles,
|
|
500
|
-
filePaths: localCurrentFiles ? JSON.stringify(localCurrentFiles) : undefined,
|
|
501
|
-
});
|
|
502
|
-
setConversationList(list => {
|
|
503
|
-
const newList = list
|
|
504
|
-
.map(c =>
|
|
505
|
-
c.sessionId === activeSessionId ? { ...c, isNew: false, gmtModified: Date.now() } : c
|
|
506
|
-
)
|
|
507
|
-
.sort((a, b) => b.gmtModified - a.gmtModified);
|
|
508
|
-
setTimeout(() => {
|
|
509
|
-
setActiveSessionId(activeSessionId);
|
|
510
|
-
}, 300);
|
|
511
|
-
return newList;
|
|
512
|
-
});
|
|
513
|
-
// 2. 有文件时,先上传并轮询,全部解析成功后再发起AI请求
|
|
514
|
-
if (data.files && data.files.length > 0) {
|
|
515
|
-
setAppStatus(pre => ({ ...pre, sender: 'uploading', display: 'uploading' }));
|
|
516
|
-
uploadController = new AbortController();
|
|
517
|
-
stoppedRef.current = false;
|
|
518
|
-
const clientFileUids = data.files.map(
|
|
519
|
-
() => `rc-upload-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
520
|
-
);
|
|
521
|
-
const initialFileStatuses = data.files.map((fileItem: any, index: number) => ({
|
|
522
|
-
...fileItem,
|
|
523
|
-
uid: clientFileUids[index],
|
|
524
|
-
status: 'uploading',
|
|
525
|
-
}));
|
|
526
|
-
setFileStatuses(initialFileStatuses);
|
|
527
|
-
const formData = new FormData();
|
|
528
|
-
data.files.forEach((fileItem: any) => {
|
|
529
|
-
formData.append('files', fileItem.file);
|
|
530
|
-
});
|
|
531
|
-
const sessionIdStr = activeSessionId ? String(activeSessionId) : '';
|
|
532
|
-
formData.append('sessionId', sessionIdStr);
|
|
533
|
-
formData.append('uids', clientFileUids.join(','));
|
|
534
|
-
try {
|
|
535
|
-
const response = await request.post(
|
|
536
|
-
`${url}/index/knowledgeBase/file/uploadFiles`,
|
|
537
|
-
formData,
|
|
538
|
-
{
|
|
539
|
-
headers: {
|
|
540
|
-
Authorization: token,
|
|
541
|
-
'Content-Type': 'multipart/form-data',
|
|
542
|
-
},
|
|
543
|
-
signal: uploadController.signal,
|
|
544
|
-
}
|
|
545
|
-
);
|
|
546
|
-
if (stoppedRef.current) return;
|
|
547
|
-
if (
|
|
548
|
-
response.data.success &&
|
|
549
|
-
Array.isArray(response.data.data) &&
|
|
550
|
-
response.data.data.length > 0
|
|
551
|
-
) {
|
|
552
|
-
// === 新增:合并后端返回字段到 fileStatuses ===
|
|
553
|
-
setFileStatuses(prev => {
|
|
554
|
-
return prev.map(localFile => {
|
|
555
|
-
const serverFile = response.data.data.find((f: any) => f.uid === localFile.uid);
|
|
556
|
-
return serverFile ? { ...localFile, ...serverFile } : localFile;
|
|
557
|
-
});
|
|
558
|
-
});
|
|
559
|
-
setAppStatus(pre => ({ ...pre, sender: 'processing', display: 'analyzing' }));
|
|
560
|
-
setFileStatuses(prev => prev.map(f => ({ ...f, status: 'parsing' })));
|
|
561
|
-
const uploadedFilesData = response.data.data;
|
|
562
|
-
const serverUids = uploadedFilesData.map((f: any) => f.uid);
|
|
563
|
-
pollFileStatus(
|
|
564
|
-
serverUids,
|
|
565
|
-
serverStatuses => {
|
|
566
|
-
setFileStatuses(currentLocalStatuses => {
|
|
567
|
-
return currentLocalStatuses.map(localFile => {
|
|
568
|
-
const correspondingServerFile = serverStatuses.find(
|
|
569
|
-
(sf: any) => sf.uid === localFile.uid
|
|
570
|
-
);
|
|
571
|
-
if (correspondingServerFile) {
|
|
572
|
-
switch (correspondingServerFile.status) {
|
|
573
|
-
case 3:
|
|
574
|
-
return { ...localFile, status: 'done' };
|
|
575
|
-
case 4:
|
|
576
|
-
return { ...localFile, status: 'error' };
|
|
577
|
-
case 1:
|
|
578
|
-
case 2:
|
|
579
|
-
default:
|
|
580
|
-
return { ...localFile, status: 'parsing' };
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
return localFile;
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
// === 新增:全部完成时清空 sender 区 ===
|
|
587
|
-
const allDone =
|
|
588
|
-
serverStatuses.length > 0 &&
|
|
589
|
-
serverStatuses.every((file: any) => file.status === 3);
|
|
590
|
-
if (allDone) {
|
|
591
|
-
setFileStatuses([]);
|
|
592
|
-
}
|
|
593
|
-
},
|
|
594
|
-
// onComplete: 全部解析成功后才发起AI请求
|
|
595
|
-
() => {
|
|
596
|
-
clearFn?.();
|
|
597
|
-
setAppStatus(pre => ({ ...pre, sender: 'processing', display: 'processing' }));
|
|
598
|
-
// === 新增:回填 filePath 到 fileStatuses ===
|
|
599
|
-
setFileStatuses(prev => {
|
|
600
|
-
return prev.map(localFile => {
|
|
601
|
-
const serverFile = uploadedFilesData.find((f: any) => f.uid === localFile.uid);
|
|
602
|
-
|
|
603
|
-
if (serverFile) {
|
|
604
|
-
return {
|
|
605
|
-
...localFile,
|
|
606
|
-
...serverFile, // 合并后端所有字段
|
|
607
|
-
url: serverFile.filePath, // 兼容 url 字段
|
|
608
|
-
filePath: serverFile.filePath,
|
|
609
|
-
name: serverFile.fileName || localFile.name,
|
|
610
|
-
convertedFilePath:
|
|
611
|
-
serverFile.convertedFilePath || localFile.convertedFilePath,
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
return localFile;
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
|
-
// === 同步 currentFiles 字段到 chatData ===
|
|
618
|
-
setChatData(chatList => {
|
|
619
|
-
if (!chatList[0]) return chatList;
|
|
620
|
-
const { messages } = chatList[0];
|
|
621
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
622
|
-
if (messages[i].istype === 'user') {
|
|
623
|
-
const oldFiles = messages[i].currentFiles || [];
|
|
624
|
-
messages[i].currentFiles = oldFiles.map((localFile: any) => {
|
|
625
|
-
const serverFile = uploadedFilesData.find(
|
|
626
|
-
(f: any) => f.uid === localFile.uid
|
|
627
|
-
);
|
|
628
|
-
return serverFile ? { ...localFile, ...serverFile } : localFile;
|
|
629
|
-
});
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return [...chatList];
|
|
634
|
-
});
|
|
635
|
-
// === 全部完成时清空 sender 区并合并文件 ===
|
|
636
|
-
setFileStatuses([]);
|
|
637
|
-
// 上传完成后合并新文件到 uploadedFiles,保证结构统一
|
|
638
|
-
const map = new Map();
|
|
639
|
-
(uploadedFilesData || []).forEach((item: any) => {
|
|
640
|
-
map.set(item.id, item);
|
|
641
|
-
});
|
|
642
|
-
setFileManagerData(prev => {
|
|
643
|
-
const r = mergeFiles(prev.uploadedFiles, uploadedFilesData);
|
|
644
|
-
|
|
645
|
-
return {
|
|
646
|
-
uploadedFiles: r.map(item => {
|
|
647
|
-
return {
|
|
648
|
-
...item,
|
|
649
|
-
pdfPages: map.get(item.id)?.pdfPages || 0, // 保留后端返回的 pdfPages 字段
|
|
650
|
-
};
|
|
651
|
-
}),
|
|
652
|
-
};
|
|
653
|
-
});
|
|
654
|
-
const now = Date.now();
|
|
655
|
-
api_startChat_re(
|
|
656
|
-
{
|
|
657
|
-
configId: configId || currentChatData.configId,
|
|
658
|
-
content: data.content || data.text || '',
|
|
659
|
-
fileUids: serverUids,
|
|
660
|
-
lastDate: now,
|
|
661
|
-
name: currentChatData.label || '',
|
|
662
|
-
queryId: queryId,
|
|
663
|
-
sessionId: String(activeSessionId || ''),
|
|
664
|
-
type: 'text',
|
|
665
|
-
audioUrl: '',
|
|
666
|
-
sysType: 'TEMPORARY',
|
|
667
|
-
enableThinking: !!senderSwitchValues.reasoning,
|
|
668
|
-
enableWebsearch: !!senderSwitchValues.netSearch,
|
|
669
|
-
qaChannel: senderSwitchValues.qaChannel,
|
|
670
|
-
} as any,
|
|
671
|
-
() => {
|
|
672
|
-
fetchRecommendQuestions(queryId);
|
|
673
|
-
}
|
|
674
|
-
);
|
|
675
|
-
},
|
|
676
|
-
(errorMsg: string) => {
|
|
677
|
-
setAppStatus(pre => ({ ...pre, display: 'ready', sender: 'ready' }));
|
|
678
|
-
setFileStatuses(prev =>
|
|
679
|
-
prev.map(f => ({ ...f, status: 'error', message: errorMsg }))
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
);
|
|
683
|
-
} else {
|
|
684
|
-
const errorMsg = response.data.errorMsg || '文件上传失败';
|
|
685
|
-
setAppStatus(pre => ({ ...pre, display: 'error', sender: 'ready' }));
|
|
686
|
-
setFileStatuses(prev => prev.map(f => ({ ...f, status: 'error', message: errorMsg })));
|
|
687
|
-
}
|
|
688
|
-
} catch (error) {
|
|
689
|
-
setAppStatus(pre => ({ ...pre, display: 'error', sender: 'ready' }));
|
|
690
|
-
setFileStatuses(prev => prev.map(f => ({ ...f, status: 'error', message: '网络错误' })));
|
|
691
|
-
}
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
// 3. 无文件,直接发起AI请求
|
|
695
|
-
if (!activeSessionId) return;
|
|
696
|
-
setAppStatus(pre => ({ ...pre, display: 'processing', sender: 'processing' }));
|
|
697
|
-
const now = Date.now();
|
|
698
|
-
setConversationList(list =>
|
|
699
|
-
list.map(c => (c.sessionId === activeSessionId ? { ...c, gmtModified: now } : c))
|
|
700
|
-
);
|
|
701
|
-
clearFn?.();
|
|
702
|
-
api_startChat_re(
|
|
703
|
-
{
|
|
704
|
-
configId: configId || currentChatData.configId,
|
|
705
|
-
content: data.content || data.text || '',
|
|
706
|
-
fileUids: [],
|
|
707
|
-
lastDate: now,
|
|
708
|
-
name: currentChatData.label || '',
|
|
709
|
-
queryId: queryId,
|
|
710
|
-
sessionId: activeSessionId,
|
|
711
|
-
type: 'text',
|
|
712
|
-
audioUrl: '',
|
|
713
|
-
sysType: 'TEMPORARY',
|
|
714
|
-
enableThinking: !!senderSwitchValues.reasoning,
|
|
715
|
-
enableWebsearch: !!senderSwitchValues.netSearch,
|
|
716
|
-
qaChannel: senderSwitchValues.qaChannel,
|
|
717
|
-
} as any,
|
|
718
|
-
() => {
|
|
719
|
-
fetchRecommendQuestions(queryId);
|
|
720
|
-
}
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// =================================================================
|
|
725
|
-
// Event Handlers - 事件处理器
|
|
726
|
-
// =================================================================
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* 处理点赞反馈
|
|
730
|
-
*/
|
|
731
|
-
function handleThumbsup(data: any) {
|
|
732
|
-
if (data.restult == 1) {
|
|
733
|
-
handleCancelFeedBack({ url, token }, { queryId: data.queryId }, () => {
|
|
734
|
-
setFeed(data.queryId, null);
|
|
735
|
-
});
|
|
736
|
-
} else {
|
|
737
|
-
handleFeedBack({ url, token }, { restult: 1, queryId: data.queryId }, () => {
|
|
738
|
-
setFeed(data.queryId, 1);
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* 处理新建一个临时会话
|
|
745
|
-
*/
|
|
746
|
-
function handleConversationCreate(data: any) {
|
|
747
|
-
const sessionId = uid(32);
|
|
748
|
-
// 优先用 props.configId
|
|
749
|
-
const effectiveConfigId = configId || data?.configId || '';
|
|
750
|
-
const newConversation = {
|
|
751
|
-
sessionId,
|
|
752
|
-
label: '未命名会话',
|
|
753
|
-
gmtModified: Date.now(),
|
|
754
|
-
searchConfigDTO: {},
|
|
755
|
-
filePath: '',
|
|
756
|
-
configId: effectiveConfigId,
|
|
757
|
-
isNew: true,
|
|
758
|
-
};
|
|
759
|
-
setConversationList(list => [{ ...newConversation, messages: [] }, ...list]);
|
|
760
|
-
setChatData(list => [{ id: sessionId, messages: [], ...newConversation }, ...list]);
|
|
761
|
-
setActiveSessionId(sessionId);
|
|
762
|
-
// 自动触发新建会话接口
|
|
763
|
-
|
|
764
|
-
if (token && url) {
|
|
765
|
-
request
|
|
766
|
-
.post(
|
|
767
|
-
`${url}/qa/dialogue/create`,
|
|
768
|
-
{
|
|
769
|
-
configId: effectiveConfigId,
|
|
770
|
-
label: `来自内嵌应用${uid(8)}`,
|
|
771
|
-
sessionId,
|
|
772
|
-
sysType: 'TEMPORARY',
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
headers: { Authorization: token },
|
|
776
|
-
}
|
|
777
|
-
)
|
|
778
|
-
.then(res => {
|
|
779
|
-
const newSession = res.data.data;
|
|
780
|
-
if (newSession?.sessionId) {
|
|
781
|
-
setConversationList(list => [
|
|
782
|
-
{ ...newSession, messages: [] },
|
|
783
|
-
...list.filter(c => c.sessionId !== sessionId),
|
|
784
|
-
]);
|
|
785
|
-
setChatData(list => [
|
|
786
|
-
{ id: newSession.sessionId, messages: [], ...newSession },
|
|
787
|
-
...list.filter(c => c.id !== sessionId),
|
|
788
|
-
]);
|
|
789
|
-
setActiveSessionId(newSession.sessionId);
|
|
790
|
-
}
|
|
791
|
-
})
|
|
792
|
-
.catch(err => {
|
|
793
|
-
onError?.(err);
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* 文件管理器:处理文件选择后的上传
|
|
800
|
-
*/
|
|
801
|
-
const handleFileManagerUpload = (fileList: FileList) => {
|
|
802
|
-
// 1. 收集所有已经存在的文件名
|
|
803
|
-
const existingFileNames = new Set<string>([
|
|
804
|
-
...fileManagerData.uploadedFiles.map((f: any) => f.file.name as string),
|
|
805
|
-
...pendingFiles.map((f: any) => f.file.name as string),
|
|
806
|
-
]);
|
|
807
|
-
|
|
808
|
-
const newFiles: { file: File; type: string; status: string; preview?: string }[] = [];
|
|
809
|
-
const duplicateFileNames = new Set<string>();
|
|
810
|
-
|
|
811
|
-
// 2. 遍历新选择的文件,筛选出重复项和有效项
|
|
812
|
-
Array.from(fileList).forEach(file => {
|
|
813
|
-
if (existingFileNames.has(file.name)) {
|
|
814
|
-
duplicateFileNames.add(file.name);
|
|
815
|
-
} else {
|
|
816
|
-
newFiles.push({
|
|
817
|
-
file,
|
|
818
|
-
type: getFileTypeByName(file.name),
|
|
819
|
-
status: 'pending',
|
|
820
|
-
preview: file.type.startsWith('image') ? URL.createObjectURL(file) : undefined,
|
|
821
|
-
});
|
|
822
|
-
existingFileNames.add(file.name); // 添加到Set中,以防本次上传的文件之间有重复
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
|
|
826
|
-
// 3. 如果有重复,发出警告
|
|
827
|
-
if (duplicateFileNames.size > 0) {
|
|
828
|
-
message.warning(`不能上传同名文件: ${Array.from(duplicateFileNames).join(', ')}`);
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
// 4. 将有效的文件添加到待上传列表
|
|
832
|
-
if (newFiles.length > 0) {
|
|
833
|
-
setPendingFiles(prev => [...prev, ...newFiles]);
|
|
834
|
-
// 直接同步到核心发送器组件
|
|
835
|
-
setUploadedFilesRef.current?.(newFiles);
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* 文件管理器:处理文件移除
|
|
841
|
-
*/
|
|
842
|
-
const handleFileManagerRemove = (fileObj: any, idx: number, _type: string) => {
|
|
843
|
-
removeFileRef.current?.(fileObj, idx, _type);
|
|
844
|
-
};
|
|
845
|
-
|
|
846
|
-
const is_download = useMemo(() => {
|
|
847
|
-
if (currentChatData.configId && assistantMap) {
|
|
848
|
-
const curAssist = assistantMap[currentChatData.configId];
|
|
849
|
-
if (curAssist?.configJson) {
|
|
850
|
-
const config = JSON.parse(curAssist.configJson);
|
|
851
|
-
return config.is_download;
|
|
852
|
-
}
|
|
853
|
-
return false;
|
|
854
|
-
} else {
|
|
855
|
-
return false;
|
|
856
|
-
}
|
|
857
|
-
}, [currentChatData.configId, assistantMap]);
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* 处理会话列表项点击
|
|
861
|
-
*/
|
|
862
|
-
function handleItemClick(data: any) {
|
|
863
|
-
if (data?.sessionId && data.sessionId !== activeSessionId) {
|
|
864
|
-
setActiveSessionId(data.sessionId);
|
|
865
|
-
setAppStatus(prev => ({ ...prev, sender: 'ready' }));
|
|
866
|
-
// 点击会话时,使用其最后一条AI消息的推荐问题
|
|
867
|
-
const conv = chatData.find(c => c.id === data.sessionId);
|
|
868
|
-
if (conv && conv.messages && conv.messages.length > 0) {
|
|
869
|
-
const lastAiMsg = [...conv.messages].reverse().find((m: any) => m.istype === 'ai');
|
|
870
|
-
if (lastAiMsg && lastAiMsg.recommendQuestion) {
|
|
871
|
-
setRecommandQuestions(lastAiMsg.recommendQuestion);
|
|
872
|
-
} else {
|
|
873
|
-
setRecommandQuestions([]);
|
|
874
|
-
}
|
|
875
|
-
} else {
|
|
876
|
-
setRecommandQuestions([]);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
// =================================================================
|
|
882
|
-
// Local State Updaters - 本地状态更新 (供事件发射器使用)
|
|
883
|
-
// =================================================================
|
|
884
|
-
|
|
885
|
-
const handleFeedDownConfirm = (data: any) => {
|
|
886
|
-
handleFeedBack({ url, token }, { ...data, ...feedParam, restult: 0 }, () => {
|
|
887
|
-
setFeed(feedParam.queryId, 0);
|
|
888
|
-
});
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
// =================================================================
|
|
892
|
-
// Event Emitter - 事件分发器
|
|
893
|
-
// =================================================================
|
|
894
|
-
/**
|
|
895
|
-
* 统一事件分发器,连接业务逻辑与所有子组件的事件
|
|
896
|
-
* @param {string} eventName - 事件名称
|
|
897
|
-
* @param {any} data - 事件数据
|
|
898
|
-
*/
|
|
899
|
-
const mergedEventsEmit = (eventName: string, data: any) => {
|
|
900
|
-
console.log(`[Event] ${eventName}`, data);
|
|
901
|
-
switch (eventName) {
|
|
902
|
-
case 'retrive_tag:click':
|
|
903
|
-
if (data?.graph?.id) {
|
|
904
|
-
//图谱溯源
|
|
905
|
-
setDrawerType('graphPreview');
|
|
906
|
-
setCurFileInfo({ ...data.graph, traceNode: data.traceNode });
|
|
907
|
-
setOpen(true);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
if (!data?.tagInfo && !data?.file && !data?.referenceDoc) return;
|
|
911
|
-
const curFile = data?.referenceDoc || data?.file || data?.tagInfo;
|
|
912
|
-
const { pdfPages, parsedFilePath, order_num, metadata, tags } = curFile;
|
|
913
|
-
if (curFile.type == 'video') {
|
|
914
|
-
setCurFileInfo({
|
|
915
|
-
...metadata,
|
|
916
|
-
displayType: 'retrive',
|
|
917
|
-
});
|
|
918
|
-
setDrawerType('video');
|
|
919
|
-
setOpen(true);
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
const id = curFile.id || order_num || 'Unknown ID';
|
|
924
|
-
// 解析 source 字段
|
|
925
|
-
const sourceParts = metadata.source.split('/');
|
|
926
|
-
const fileName = sourceParts[sourceParts.length - 1] || '';
|
|
927
|
-
const fileParts = fileName.split('.');
|
|
928
|
-
const label = fileParts.slice(0, -1).join('.') || 'Unknown Label';
|
|
929
|
-
const file_type = fileParts[fileParts.length - 1] || 'Unknown Type';
|
|
930
|
-
|
|
931
|
-
setContent({
|
|
932
|
-
id,
|
|
933
|
-
title: label,
|
|
934
|
-
file_name: fileName,
|
|
935
|
-
file_type: file_type,
|
|
936
|
-
file_source: getMarkExcludeType(file_type)
|
|
937
|
-
? `${TempBaseUrl}${metadata.source}`
|
|
938
|
-
: parsedFilePath,
|
|
939
|
-
metadata: metadata,
|
|
940
|
-
pdfPages: pdfPages,
|
|
941
|
-
});
|
|
942
|
-
setDrawerType('mark');
|
|
943
|
-
setOpen(true);
|
|
944
|
-
break;
|
|
945
|
-
// --- 对话列表事件 ---
|
|
946
|
-
case 'conversation:item_click':
|
|
947
|
-
handleItemClick(data);
|
|
948
|
-
break;
|
|
949
|
-
|
|
950
|
-
case 'files:finished_animation_complete':
|
|
951
|
-
setFileStatuses([]);
|
|
952
|
-
break;
|
|
953
|
-
|
|
954
|
-
case 'conversation:create':
|
|
955
|
-
handleConversationCreate(data);
|
|
956
|
-
break;
|
|
957
|
-
case 'conversation:new_assistant_change':
|
|
958
|
-
// headlessChat 不需要处理助手切换
|
|
959
|
-
break;
|
|
960
|
-
|
|
961
|
-
// --- 发送器事件 ---
|
|
962
|
-
case 'sender:send':
|
|
963
|
-
handleSenderSend(data, data.clearFn);
|
|
964
|
-
break;
|
|
965
|
-
case 'sender:send_recommandQuestion':
|
|
966
|
-
// 点击推荐问题,视作一次普通发送
|
|
967
|
-
handleSenderSend(data, data.clearFn);
|
|
968
|
-
break;
|
|
969
|
-
case 'sender:action_history':
|
|
970
|
-
setFileManagerOpen(true);
|
|
971
|
-
break;
|
|
972
|
-
case 'sender:stop':
|
|
973
|
-
stoppedRef.current = true;
|
|
974
|
-
if (uploadController) {
|
|
975
|
-
uploadController.abort();
|
|
976
|
-
uploadController = null;
|
|
977
|
-
}
|
|
978
|
-
if (stopPoll) {
|
|
979
|
-
stopPoll();
|
|
980
|
-
stopPoll = null;
|
|
981
|
-
}
|
|
982
|
-
setAppStatus(pre => ({ ...pre, display: 'ready', sender: 'ready' }));
|
|
983
|
-
setFileStatuses([]);
|
|
984
|
-
stopStream?.();
|
|
985
|
-
break;
|
|
986
|
-
case 'sender:clear':
|
|
987
|
-
data.clearFn?.();
|
|
988
|
-
break;
|
|
989
|
-
case 'sender:configChange':
|
|
990
|
-
// 配置项变化,记录最新 switch 状态
|
|
991
|
-
if (data && data.all) {
|
|
992
|
-
setSenderSwitchValues(data.all);
|
|
993
|
-
}
|
|
994
|
-
break;
|
|
995
|
-
case 'chatbox:follow_up_question_click': {
|
|
996
|
-
// 新链路:来自 ChatMessageAdapter 的追问点击
|
|
997
|
-
const content = (data?.question ?? data?.content ?? '').toString();
|
|
998
|
-
if (!content) break;
|
|
999
|
-
handleSenderSend({ content }, () => {});
|
|
1000
|
-
break;
|
|
1001
|
-
}
|
|
1002
|
-
case 'chatbox:copy': {
|
|
1003
|
-
const text = data?.content || '';
|
|
1004
|
-
if (!text) break;
|
|
1005
|
-
// 直接使用 Clipboard API,避免依赖 event.currentTarget
|
|
1006
|
-
const copyByClipboardApi = async (t: string) => {
|
|
1007
|
-
try {
|
|
1008
|
-
await navigator.clipboard.writeText(t);
|
|
1009
|
-
message.success('已复制到剪贴板');
|
|
1010
|
-
return true;
|
|
1011
|
-
} catch (_) {
|
|
1012
|
-
return false;
|
|
1013
|
-
}
|
|
1014
|
-
};
|
|
1015
|
-
const fallbackCopy = (t: string) => {
|
|
1016
|
-
const textarea = document.createElement('textarea');
|
|
1017
|
-
textarea.value = t;
|
|
1018
|
-
textarea.style.position = 'fixed';
|
|
1019
|
-
textarea.style.opacity = '0';
|
|
1020
|
-
document.body.appendChild(textarea);
|
|
1021
|
-
textarea.focus();
|
|
1022
|
-
textarea.select();
|
|
1023
|
-
try {
|
|
1024
|
-
document.execCommand('copy');
|
|
1025
|
-
message.success('已复制到剪贴板');
|
|
1026
|
-
} catch (_) {
|
|
1027
|
-
message.error('复制失败');
|
|
1028
|
-
}
|
|
1029
|
-
document.body.removeChild(textarea);
|
|
1030
|
-
};
|
|
1031
|
-
copyByClipboardApi(text).then(ok => {
|
|
1032
|
-
if (!ok) fallbackCopy(text);
|
|
1033
|
-
});
|
|
1034
|
-
break;
|
|
1035
|
-
}
|
|
1036
|
-
case 'chatbox:repeat':
|
|
1037
|
-
handleReSenderSend(data);
|
|
1038
|
-
break;
|
|
1039
|
-
case 'chatbox:like':
|
|
1040
|
-
handleThumbsup({ queryId: data?.queryId, restult: data?.result });
|
|
1041
|
-
break;
|
|
1042
|
-
case 'chatbox:dislike':
|
|
1043
|
-
if (data?.result === 0) {
|
|
1044
|
-
handleCancelFeedBack({ url, token }, { queryId: data.queryId }, () => {
|
|
1045
|
-
setFeed(data.queryId, null);
|
|
1046
|
-
});
|
|
1047
|
-
} else {
|
|
1048
|
-
setFeedParam({ queryId: data?.queryId });
|
|
1049
|
-
setOpenFeed(true);
|
|
1050
|
-
}
|
|
1051
|
-
break;
|
|
1052
|
-
|
|
1053
|
-
// --- 消息卡片事件 ---
|
|
1054
|
-
case 'action_copy:click':
|
|
1055
|
-
if (data) {
|
|
1056
|
-
toCopy(data.content, data.event);
|
|
1057
|
-
}
|
|
1058
|
-
break;
|
|
1059
|
-
case 'action_retry':
|
|
1060
|
-
handleReSenderSend(data);
|
|
1061
|
-
break;
|
|
1062
|
-
case 'action_thumbsup':
|
|
1063
|
-
handleThumbsup(data);
|
|
1064
|
-
break;
|
|
1065
|
-
case 'references:click': {
|
|
1066
|
-
// 使用 AiChat 内置的右侧栏事件
|
|
1067
|
-
const Content = () => {
|
|
1068
|
-
// const safe = (() => {
|
|
1069
|
-
// try {
|
|
1070
|
-
// return typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
1071
|
-
// } catch (e) {
|
|
1072
|
-
// return String(data);
|
|
1073
|
-
// }
|
|
1074
|
-
// })();
|
|
1075
|
-
return (
|
|
1076
|
-
<ReferenceBar
|
|
1077
|
-
type={DrawerType.REFERENCELIST}
|
|
1078
|
-
data={data}
|
|
1079
|
-
token={token}
|
|
1080
|
-
is_download={is_download}
|
|
1081
|
-
/>
|
|
1082
|
-
);
|
|
1083
|
-
};
|
|
1084
|
-
const setContentEvent = new CustomEvent('aichat:right_set_content', {
|
|
1085
|
-
detail: { content: <Content /> },
|
|
1086
|
-
});
|
|
1087
|
-
window.dispatchEvent(setContentEvent);
|
|
1088
|
-
const openEvent = new CustomEvent('aichat:right_set', {
|
|
1089
|
-
detail: { collapsed: false },
|
|
1090
|
-
});
|
|
1091
|
-
window.dispatchEvent(openEvent);
|
|
1092
|
-
break;
|
|
1093
|
-
}
|
|
1094
|
-
case 'action_thumbsdown':
|
|
1095
|
-
if (data.restult === 0) {
|
|
1096
|
-
handleCancelFeedBack({ url, token }, { queryId: data.queryId }, () => {
|
|
1097
|
-
setFeed(data.queryId, null);
|
|
1098
|
-
});
|
|
1099
|
-
} else {
|
|
1100
|
-
setFeedParam(data);
|
|
1101
|
-
setOpenFeed(true);
|
|
1102
|
-
}
|
|
1103
|
-
break;
|
|
1104
|
-
// --- 文件管理器上传文件删除事件,透传到业务层 ---
|
|
1105
|
-
case 'uploaded_file:removeFromTemp': {
|
|
1106
|
-
console.log('[DEBUG] mergedEventsEmit uploaded_file:removeFromTemp 事件', data);
|
|
1107
|
-
|
|
1108
|
-
const uid = data?.file?.uid;
|
|
1109
|
-
if (!uid) {
|
|
1110
|
-
console.warn('[DEBUG] 缺少uid,无法删除临时文件', data);
|
|
1111
|
-
break;
|
|
1112
|
-
}
|
|
1113
|
-
// 获取当前对话最后一条 AI 消息的 queryId
|
|
1114
|
-
const lastAiMsg = [...(currentChatData.messages || [])]
|
|
1115
|
-
.reverse()
|
|
1116
|
-
.find((msg: any) => msg.istype === 'user');
|
|
1117
|
-
const queryId = lastAiMsg?.queryId;
|
|
1118
|
-
console.log('[DEBUG] mergedEventsEmit 获取到 queryId', queryId, lastAiMsg);
|
|
1119
|
-
|
|
1120
|
-
removeFilefromTempUpload({ url, token }, { uid, queryId }, (success, res) => {
|
|
1121
|
-
console.log('[DEBUG] removeFilefromTempUpload 回调触发', { success, res });
|
|
1122
|
-
if (success) {
|
|
1123
|
-
message.success('文件已从临时知识库移除');
|
|
1124
|
-
// 用后端返回的新data数组(新文件列表)更新本地uploadedFiles
|
|
1125
|
-
//console.log('[DEBUG] removeFilefromTempUpload 回调 true,res:', res, Array.isArray(res.data && res.data.data));
|
|
1126
|
-
if (res && Array.isArray(res.data && res.data.data)) {
|
|
1127
|
-
const uploaded = res.data.data.map((f: any) => {
|
|
1128
|
-
const fileName = f.name || f.fileName || '';
|
|
1129
|
-
return {
|
|
1130
|
-
file: {
|
|
1131
|
-
name: fileName,
|
|
1132
|
-
size: Number(f.size?.replace('MB', '')) * 1024 * 1024 || 0,
|
|
1133
|
-
type: f.type,
|
|
1134
|
-
} as File,
|
|
1135
|
-
type: getFileTypeByName(fileName),
|
|
1136
|
-
status: 'uploaded' as const,
|
|
1137
|
-
url: f.filePath,
|
|
1138
|
-
convertedFilePath: f.convertedFilePath,
|
|
1139
|
-
uid: f.uid,
|
|
1140
|
-
preview: f.type === 'image' ? f.filePath : undefined,
|
|
1141
|
-
};
|
|
1142
|
-
});
|
|
1143
|
-
// console.log('[DEBUG] uploaded 构造完成:', uploaded, '当前 fileManagerData:', fileManagerData);
|
|
1144
|
-
setFileManagerData({ uploadedFiles: uploaded });
|
|
1145
|
-
} else {
|
|
1146
|
-
//console.log('[DEBUG] res.data.data 不是数组', res && res.data && res.data.data);
|
|
1147
|
-
}
|
|
1148
|
-
} else {
|
|
1149
|
-
console.log('[DEBUG] removeFilefromTempUpload 回调 false,res:', res);
|
|
1150
|
-
message.error('文件移除失败');
|
|
1151
|
-
}
|
|
1152
|
-
});
|
|
1153
|
-
break;
|
|
1154
|
-
}
|
|
1155
|
-
// --- 文件管理器事件 ---
|
|
1156
|
-
case 'fileManager:change': {
|
|
1157
|
-
const files = Array.isArray(data?.uploadedFiles) ? data.uploadedFiles : [];
|
|
1158
|
-
setPendingFiles(files);
|
|
1159
|
-
// 保存核心组件传递的文件处理函数引用
|
|
1160
|
-
if (typeof data?.setUploadedFiles === 'function') {
|
|
1161
|
-
setUploadedFilesRef.current = data.setUploadedFiles;
|
|
1162
|
-
removeFileRef.current = data.removeFile;
|
|
1163
|
-
}
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
default:
|
|
1168
|
-
// 其他未处理事件可继续向上层抛出
|
|
1169
|
-
eventsEmit?.(eventName, data);
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
// =================================================================
|
|
1174
|
-
// Component & UI Configuration - 组件及UI配置
|
|
1175
|
-
// =================================================================
|
|
1176
|
-
|
|
1177
|
-
/**
|
|
1178
|
-
* Sidebar 配置 - headlessChat 不需要左侧历史对话栏
|
|
1179
|
-
*/
|
|
1180
|
-
const sidebar = undefined;
|
|
1181
|
-
|
|
1182
|
-
/**
|
|
1183
|
-
* 业务层自定义组件
|
|
1184
|
-
*/
|
|
1185
|
-
const businessCustomComponents: { [key: string]: any } = {
|
|
1186
|
-
AiChatBox: (msg: any, idx: number) => {
|
|
1187
|
-
const isLastMessage = idx === (currentChatData?.messages?.length || 0) - 1;
|
|
1188
|
-
|
|
1189
|
-
// 根据消息的 status 和 appStatus 来确定 displayStatus
|
|
1190
|
-
let displayStatus = 'ready';
|
|
1191
|
-
if (isLastMessage) {
|
|
1192
|
-
// 优先使用消息的 status 字段
|
|
1193
|
-
if (msg.status !== undefined) {
|
|
1194
|
-
switch (msg.status) {
|
|
1195
|
-
case 0: // StatusType.Pending
|
|
1196
|
-
displayStatus = 'thinking';
|
|
1197
|
-
break;
|
|
1198
|
-
case 1: // StatusType.Process
|
|
1199
|
-
displayStatus = 'processing';
|
|
1200
|
-
break;
|
|
1201
|
-
case 2: // StatusType.Done
|
|
1202
|
-
displayStatus = 'ready';
|
|
1203
|
-
break;
|
|
1204
|
-
case 3: // StatusType.Error
|
|
1205
|
-
displayStatus = 'error';
|
|
1206
|
-
break;
|
|
1207
|
-
default:
|
|
1208
|
-
displayStatus = appStatus.display;
|
|
1209
|
-
}
|
|
1210
|
-
} else {
|
|
1211
|
-
// 如果没有 status 字段,使用 appStatus.display
|
|
1212
|
-
displayStatus = appStatus.display;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
// 将推荐问题强制转换为数组,避免切换会话时报 .map 错误
|
|
1216
|
-
let safeFollowUps: string[] = [];
|
|
1217
|
-
if (Array.isArray(recommandQuestions)) {
|
|
1218
|
-
safeFollowUps = recommandQuestions as string[];
|
|
1219
|
-
} else if (typeof recommandQuestions === 'string') {
|
|
1220
|
-
try {
|
|
1221
|
-
safeFollowUps = JSON.parse(recommandQuestions) || [];
|
|
1222
|
-
} catch {
|
|
1223
|
-
safeFollowUps = [];
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
// 保证传入 ChatMessageAdapter 的 reference/webReference/graphReference 始终是有效的 JSON 字符串
|
|
1227
|
-
const safeReference = (() => {
|
|
1228
|
-
const r = (msg as any)?.reference;
|
|
1229
|
-
if (!r) return '[]';
|
|
1230
|
-
if (typeof r === 'string') {
|
|
1231
|
-
try {
|
|
1232
|
-
JSON.parse(r);
|
|
1233
|
-
return r;
|
|
1234
|
-
} catch {
|
|
1235
|
-
return '[]';
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
try {
|
|
1239
|
-
return JSON.stringify(r);
|
|
1240
|
-
} catch {
|
|
1241
|
-
return '[]';
|
|
1242
|
-
}
|
|
1243
|
-
})();
|
|
1244
|
-
const safeWebReference = (() => {
|
|
1245
|
-
const r = (msg as any)?.webReference;
|
|
1246
|
-
if (!r) return '[]';
|
|
1247
|
-
if (typeof r === 'string') {
|
|
1248
|
-
try {
|
|
1249
|
-
JSON.parse(r);
|
|
1250
|
-
return r;
|
|
1251
|
-
} catch {
|
|
1252
|
-
return '[]';
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
try {
|
|
1256
|
-
return JSON.stringify(r);
|
|
1257
|
-
} catch {
|
|
1258
|
-
return '[]';
|
|
1259
|
-
}
|
|
1260
|
-
})();
|
|
1261
|
-
const safeGraphReference = (() => {
|
|
1262
|
-
const r = (msg as any)?.graphReference;
|
|
1263
|
-
if (!r) return '[]';
|
|
1264
|
-
if (typeof r === 'string') {
|
|
1265
|
-
try {
|
|
1266
|
-
JSON.parse(r);
|
|
1267
|
-
return r;
|
|
1268
|
-
} catch {
|
|
1269
|
-
return '[]';
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
try {
|
|
1273
|
-
return JSON.stringify(r);
|
|
1274
|
-
} catch {
|
|
1275
|
-
return '[]';
|
|
1276
|
-
}
|
|
1277
|
-
})();
|
|
1278
|
-
return (
|
|
1279
|
-
<ChatMessageAdapter
|
|
1280
|
-
key={`${msg?.queryId || msg?.id || idx}-${msg?.istype || 'unknown'}`}
|
|
1281
|
-
{...msg}
|
|
1282
|
-
referenceMode="button"
|
|
1283
|
-
reference={safeReference}
|
|
1284
|
-
webReference={safeWebReference}
|
|
1285
|
-
graphReference={safeGraphReference}
|
|
1286
|
-
contentType="stream"
|
|
1287
|
-
displayStatus={displayStatus}
|
|
1288
|
-
eventsEmit={mergedEventsEmit}
|
|
1289
|
-
// 仅最后一条 AI 消息展示追问
|
|
1290
|
-
isLast={isLastMessage && msg?.istype === 'ai'}
|
|
1291
|
-
followUpQuestions={isLastMessage && msg?.istype === 'ai' ? safeFollowUps : []}
|
|
1292
|
-
defaultAnswer={
|
|
1293
|
-
currentChatData?.searchConfigDTO?.defaultAnswer ||
|
|
1294
|
-
'不知道什么原因我们没能查到你要的问题*-*'
|
|
1295
|
-
}
|
|
1296
|
-
styles={styles}
|
|
1297
|
-
/>
|
|
1298
|
-
);
|
|
1299
|
-
},
|
|
1300
|
-
LogoBox: () => <div className="text-2xl w-full text-center font-bold">小鲸智能助手</div>,
|
|
1301
|
-
DisplayLoading: () => <DisplayLoading />,
|
|
1302
|
-
DisplayError: () => <DisplayError />,
|
|
1303
|
-
AppError: () => <AppError />,
|
|
1304
|
-
AppLoading: () => <AppLoading />,
|
|
1305
|
-
UserChatBox: (msg: any, idx: number) => {
|
|
1306
|
-
return (
|
|
1307
|
-
<ChatMessageAdapter
|
|
1308
|
-
key={`${msg?.queryId || msg?.id || idx}-user`}
|
|
1309
|
-
{...msg}
|
|
1310
|
-
referenceMode="button"
|
|
1311
|
-
contentType="plainText"
|
|
1312
|
-
isUser={true}
|
|
1313
|
-
displayStatus="ready"
|
|
1314
|
-
eventsEmit={mergedEventsEmit}
|
|
1315
|
-
styles={styles}
|
|
1316
|
-
fileManagerData={fileManagerData}
|
|
1317
|
-
/>
|
|
1318
|
-
);
|
|
1319
|
-
},
|
|
1320
|
-
WelcomeComponent: () => (
|
|
1321
|
-
<GientechNewChatWelcome
|
|
1322
|
-
eventsEmit={mergedEventsEmit}
|
|
1323
|
-
assistantList={assistantList}
|
|
1324
|
-
styles={styles}
|
|
1325
|
-
// defaultSelect={newAssistantId || assistantList[0]?.id}
|
|
1326
|
-
/>
|
|
1327
|
-
),
|
|
1328
|
-
};
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* 合并外部传入和业务默认的自定义组件,外部优先
|
|
1332
|
-
*/
|
|
1333
|
-
const mergedCustomComponents: { [key: string]: any } = { ...businessCustomComponents };
|
|
1334
|
-
if (rest.CustomComponents) {
|
|
1335
|
-
Object.keys(rest.CustomComponents).forEach(key => {
|
|
1336
|
-
const val = rest.CustomComponents?.[key];
|
|
1337
|
-
if (val !== undefined) {
|
|
1338
|
-
mergedCustomComponents[key] = val;
|
|
1339
|
-
}
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
// =================================================================
|
|
1344
|
-
// Render - 渲染
|
|
1345
|
-
// =================================================================
|
|
1346
|
-
return (
|
|
1347
|
-
<>
|
|
1348
|
-
<FileManager
|
|
1349
|
-
open={fileManagerOpen}
|
|
1350
|
-
onCancel={() => setFileManagerOpen(false)}
|
|
1351
|
-
files={fileManagerData.uploadedFiles}
|
|
1352
|
-
currentFiles={pendingFiles}
|
|
1353
|
-
onUpload={handleFileManagerUpload}
|
|
1354
|
-
onRemoveFile={handleFileManagerRemove}
|
|
1355
|
-
styles={styles}
|
|
1356
|
-
eventsEmit={mergedEventsEmit}
|
|
1357
|
-
/>
|
|
1358
|
-
|
|
1359
|
-
<WrappedComponent
|
|
1360
|
-
activeSessionId={activeSessionId}
|
|
1361
|
-
status={appStatus}
|
|
1362
|
-
chatData={currentChatData}
|
|
1363
|
-
sidebar={sidebar}
|
|
1364
|
-
recommandQuestions={[]}
|
|
1365
|
-
eventsEmit={mergedEventsEmit}
|
|
1366
|
-
styles={styles}
|
|
1367
|
-
senderConfig={dynamicSenderConfig}
|
|
1368
|
-
fileUploadStatus={fileStatuses}
|
|
1369
|
-
CustomComponents={mergedCustomComponents}
|
|
1370
|
-
rightbarWidth={'400px'}
|
|
1371
|
-
/>
|
|
1372
|
-
<FeedBackModal
|
|
1373
|
-
open={openFeed}
|
|
1374
|
-
feedBackList={feedBackList}
|
|
1375
|
-
setOpen={setOpenFeed}
|
|
1376
|
-
handleConfirm={handleFeedDownConfirm}
|
|
1377
|
-
/>
|
|
1378
|
-
<ConfigProvider
|
|
1379
|
-
drawer={{
|
|
1380
|
-
styles: {
|
|
1381
|
-
body: { padding: 0 },
|
|
1382
|
-
header: { display: 'none' },
|
|
1383
|
-
},
|
|
1384
|
-
}}
|
|
1385
|
-
>
|
|
1386
|
-
<Drawer
|
|
1387
|
-
autoFocus={false}
|
|
1388
|
-
onClose={() => setOpen(false)}
|
|
1389
|
-
open={open}
|
|
1390
|
-
width={drawerType === 'graphPreview' ? '100%' : 720}
|
|
1391
|
-
className="overflow-x-hidden"
|
|
1392
|
-
destroyOnClose
|
|
1393
|
-
afterOpenChange={open => {
|
|
1394
|
-
if (!open) {
|
|
1395
|
-
setContent(null);
|
|
1396
|
-
}
|
|
1397
|
-
}}
|
|
1398
|
-
>
|
|
1399
|
-
{drawerType === 'mark' && (
|
|
1400
|
-
<DrawerContent
|
|
1401
|
-
content={content as any}
|
|
1402
|
-
onClose={() => setOpen(false)}
|
|
1403
|
-
token={token}
|
|
1404
|
-
/>
|
|
1405
|
-
)}
|
|
1406
|
-
</Drawer>
|
|
1407
|
-
</ConfigProvider>
|
|
1408
|
-
</>
|
|
1409
|
-
);
|
|
1410
|
-
};
|
|
1411
|
-
}
|