@gientech/modual 1.3.2 → 1.3.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.
Files changed (309) hide show
  1. package/.editorconfig +38 -0
  2. package/.prettierignore +16 -0
  3. package/.prettierrc +17 -0
  4. package/README.md +129 -129
  5. package/USAGE.md +191 -0
  6. package/bash.exe.stackdump +40 -0
  7. package/components.json +21 -0
  8. package/dist/README.md +129 -0
  9. package/{assets → dist/assets}/database.svg +11 -11
  10. package/{assets → dist/assets}/database_add.svg +53 -53
  11. package/{assets → dist/assets}/database_connect.svg +66 -66
  12. package/{assets → dist/assets}/database_upload.svg +29 -29
  13. package/{assets → dist/assets}/defaultWeLogo.svg +14 -14
  14. package/{assets/index-ldqIbm0x.js → dist/assets/index-XvC_4jDB.js} +106 -101
  15. package/{assets/index-D-dGaGjW.js → dist/assets/index-mPgEc8KC.js} +288 -102
  16. package/{assets/MySQL.svg → dist/assets/mysql.svg} +14 -14
  17. package/dist/assets/style.css +1 -0
  18. package/dist/assets/style3.css +1 -0
  19. package/{chat.js → dist/chat.js} +78 -78
  20. package/dist/database.js +20 -0
  21. package/{databaseId.js → dist/databaseId.js} +1 -1
  22. package/{databaseTable.js → dist/databaseTable.js} +1 -1
  23. package/{modelManage.js → dist/modelManage.js} +1 -1
  24. package/dist/package.json +56 -0
  25. package/{sensitive.js → dist/sensitive.js} +1 -1
  26. package/{streamFilesReader.js → dist/streamFilesReader.js} +11 -11
  27. package/{worker → dist/worker}/pdf.worker.min.js +21 -21
  28. package/doc_assets/2.png +0 -0
  29. package/doc_assets/demo.md +27 -0
  30. package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +2 -0
  31. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +23699 -0
  32. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +1 -0
  33. package/doc_assets/demos/dist-app/index.html +14 -0
  34. package/doc_assets/demos/dist-app/vite.svg +1 -0
  35. package/doc_assets/images/1.png +0 -0
  36. package/doc_assets/images/3.png +0 -0
  37. package/doc_assets/images/component-screenshot.png +1 -0
  38. package/doc_assets/install.md +5 -0
  39. package/eslint.config.js +92 -0
  40. package/index.html +13 -0
  41. package/package.json +83 -39
  42. package/postcss.config.cjs +19 -0
  43. package/public/vite.svg +1 -0
  44. package/public/worker/pdf.worker.min.js +22 -0
  45. package/scripts/README.md +133 -0
  46. package/scripts/build-demo.js +88 -0
  47. package/scripts/demo-selector.js +216 -0
  48. package/scripts/dev-demo.js +76 -0
  49. package/scripts/preview-demo.js +130 -0
  50. package/scripts/run-demo.bat +34 -0
  51. package/src/assets/img/downArrow.png +0 -0
  52. package/src/assets/img/excel.png +0 -0
  53. package/src/assets/img/img.png +0 -0
  54. package/src/assets/img/pdf.png +0 -0
  55. package/src/assets/img/ppt.png +0 -0
  56. package/src/assets/img/txt.png +0 -0
  57. package/src/assets/img/word.png +0 -0
  58. package/src/assets/login/homeBg.png +0 -0
  59. package/src/assets/login/left.jpg +0 -0
  60. package/src/assets/login/logoImg.png +0 -0
  61. package/src/examples/LoginPage/index.tsx +18 -0
  62. package/src/examples/aaa/index.tsx +3758 -0
  63. package/src/examples/chat/components/DrawerGraphPreview.tsx +78 -0
  64. package/src/examples/chat/index.tsx +190 -0
  65. package/src/examples/gientechStreamFilesReader/index.tsx +1016 -0
  66. package/src/examples/ragDatabaseDataPage/index.tsx +36 -0
  67. package/src/examples/ragDatabaseIdPage/index.tsx +44 -0
  68. package/src/examples/ragDatabasePage/index.tsx +36 -0
  69. package/src/examples/ragModelManagePage/index.tsx +37 -0
  70. package/src/examples/ragSearchPage/index.tsx +0 -0
  71. package/src/examples/ragSensitiveWordsPage/index.tsx +32 -0
  72. package/src/examples/streamFiles/index.tsx +384 -0
  73. package/src/lib_enter.ts +38 -0
  74. package/src/main.tsx +5 -0
  75. package/src/main.tsx.backup +5 -0
  76. package/src/modules/chat/Conversations/Item.tsx +167 -0
  77. package/src/modules/chat/Conversations/List.tsx +143 -0
  78. package/src/modules/chat/Conversations/groupByTime.ts +39 -0
  79. package/src/modules/chat/Conversations/index.tsx +212 -0
  80. package/src/modules/chat/constants.tsx +33 -0
  81. package/src/modules/chat/data.txt +82 -0
  82. package/src/modules/chat/index.tsx +1908 -0
  83. package/src/modules/chat/types.ts +17 -0
  84. package/src/modules/database/CreateModal.tsx +398 -0
  85. package/src/modules/database/assets/Doris.png +0 -0
  86. package/src/modules/database/assets/PostgreSQL.png +0 -0
  87. package/src/modules/database/assets/SQLServer.png +0 -0
  88. package/src/modules/database/assets/database.svg +11 -0
  89. package/src/modules/database/assets/database_add.svg +53 -0
  90. package/src/modules/database/assets/database_connect.svg +66 -0
  91. package/src/modules/database/assets/database_upload.svg +29 -0
  92. package/src/modules/database/assets/empty.png +0 -0
  93. package/src/modules/database/assets/mysql.svg +14 -0
  94. package/src/modules/database/index.tsx +466 -0
  95. package/src/modules/database/server.ts +196 -0
  96. package/src/modules/databaseId/CustomCom.tsx +156 -0
  97. package/src/modules/databaseId/EditConfig.tsx +268 -0
  98. package/src/modules/databaseId/UploadDrawer.tsx +520 -0
  99. package/src/modules/databaseId/assets/aiOptimize.svg +10 -0
  100. package/src/modules/databaseId/assets/empty.png +0 -0
  101. package/src/modules/databaseId/assets/template.svg +6 -0
  102. package/src/modules/databaseId/assets/upload.svg +9 -0
  103. package/src/modules/databaseId/assets/useTemp.svg +6 -0
  104. package/src/modules/databaseId/index.tsx +734 -0
  105. package/src/modules/databaseId/server.ts +286 -0
  106. package/src/modules/databaseId/style.css +5 -0
  107. package/src/modules/databaseTable/EditRowDrawer.tsx +119 -0
  108. package/src/modules/databaseTable/index.tsx +357 -0
  109. package/src/modules/databaseTable/server.ts +180 -0
  110. package/src/modules/headlessChat/constants.tsx +32 -0
  111. package/src/modules/headlessChat/index.tsx +1065 -0
  112. package/src/modules/headlessChat/types.ts +23 -0
  113. package/src/modules/login/components/Login/LoginBox/index.tsx +102 -0
  114. package/src/modules/login/components/Login/RegisterBox/index.tsx +180 -0
  115. package/src/modules/login/components/Login/index.tsx +100 -0
  116. package/src/modules/login/index.tsx +106 -0
  117. package/src/modules/login/style.css +3 -0
  118. package/src/modules/login/useServices.ts +53 -0
  119. package/src/modules/login/utils.ts +42 -0
  120. package/src/modules/modelManage/ConfigDrawer.tsx +249 -0
  121. package/src/modules/modelManage/assets/empty.png +0 -0
  122. package/src/modules/modelManage/const.ts +50 -0
  123. package/src/modules/modelManage/index.tsx +439 -0
  124. package/src/modules/modelManage/server.ts +185 -0
  125. package/src/modules/nodegraph/index.tsx +1 -0
  126. package/src/modules/search/assets/Icon-history.svg +8 -0
  127. package/src/modules/search/assets/answerAwartar.png +0 -0
  128. package/src/modules/search/assets/doc.png +0 -0
  129. package/src/modules/search/assets/genera.gif +0 -0
  130. package/src/modules/search/assets/icon-robot.svg +9 -0
  131. package/src/modules/search/assets/icon-search-bar.svg +14 -0
  132. package/src/modules/search/assets/icon-sub-title.svg +3 -0
  133. package/src/modules/search/assets/icon-title.svg +9 -0
  134. package/src/modules/search/assets/icon-zoomOut.svg +9 -0
  135. package/src/modules/search/assets/iconAi.svg +9 -0
  136. package/src/modules/search/assets/pdf.png +0 -0
  137. package/src/modules/search/assets/ppt.png +0 -0
  138. package/src/modules/search/assets/search.svg +3 -0
  139. package/src/modules/search/assets/selected.svg +4 -0
  140. package/src/modules/search/assets/txt.png +0 -0
  141. package/src/modules/search/assets/xls.png +0 -0
  142. package/src/modules/search/components/AssisSelect.tsx +137 -0
  143. package/src/modules/search/components/Editor/ChatViewEditor.tsx +261 -0
  144. package/src/modules/search/components/Editor/aichat.css +1 -0
  145. package/src/modules/search/components/Editor/constant.ts +13 -0
  146. package/src/modules/search/components/Editor/index.tsx +113 -0
  147. package/src/modules/search/components/Editor/plugins/autofomatRules.ts +332 -0
  148. package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +20 -0
  149. package/src/modules/search/components/Editor/plugins/createIndexes.tsx +38 -0
  150. package/src/modules/search/components/Editor/plugins/displayer.ts +298 -0
  151. package/src/modules/search/components/Editor/plugins/imageClick.tsx +32 -0
  152. package/src/modules/search/components/Editor/plugins/myplugin.tsx +98 -0
  153. package/src/modules/search/components/Editor/ui/avatar.tsx +19 -0
  154. package/src/modules/search/components/Editor/ui/blockquote-element.tsx +21 -0
  155. package/src/modules/search/components/Editor/ui/button.tsx +58 -0
  156. package/src/modules/search/components/Editor/ui/calendar.tsx +68 -0
  157. package/src/modules/search/components/Editor/ui/caption.tsx +46 -0
  158. package/src/modules/search/components/Editor/ui/checkbox.tsx +27 -0
  159. package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +188 -0
  160. package/src/modules/search/components/Editor/ui/code-block-element.css +434 -0
  161. package/src/modules/search/components/Editor/ui/code-block-element.tsx +39 -0
  162. package/src/modules/search/components/Editor/ui/code-leaf.tsx +24 -0
  163. package/src/modules/search/components/Editor/ui/code-line-element.tsx +10 -0
  164. package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +21 -0
  165. package/src/modules/search/components/Editor/ui/column-element.tsx +30 -0
  166. package/src/modules/search/components/Editor/ui/column-group-element.tsx +94 -0
  167. package/src/modules/search/components/Editor/ui/command.tsx +75 -0
  168. package/src/modules/search/components/Editor/ui/comment-avatar.tsx +22 -0
  169. package/src/modules/search/components/Editor/ui/comment-create-form.tsx +37 -0
  170. package/src/modules/search/components/Editor/ui/comment-item.tsx +74 -0
  171. package/src/modules/search/components/Editor/ui/comment-leaf.tsx +49 -0
  172. package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +42 -0
  173. package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +22 -0
  174. package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +32 -0
  175. package/src/modules/search/components/Editor/ui/comment-value.tsx +34 -0
  176. package/src/modules/search/components/Editor/ui/comments-popover.tsx +63 -0
  177. package/src/modules/search/components/Editor/ui/date-element.tsx +83 -0
  178. package/src/modules/search/components/Editor/ui/dialog.tsx +63 -0
  179. package/src/modules/search/components/Editor/ui/draggable.tsx +177 -0
  180. package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +180 -0
  181. package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +85 -0
  182. package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +28 -0
  183. package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +76 -0
  184. package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +8 -0
  185. package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +51 -0
  186. package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +77 -0
  187. package/src/modules/search/components/Editor/ui/heading-element.tsx +48 -0
  188. package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +17 -0
  189. package/src/modules/search/components/Editor/ui/hr-element.tsx +30 -0
  190. package/src/modules/search/components/Editor/ui/icons.tsx +267 -0
  191. package/src/modules/search/components/Editor/ui/image-element.tsx +74 -0
  192. package/src/modules/search/components/Editor/ui/inline-combobox.tsx +368 -0
  193. package/src/modules/search/components/Editor/ui/input.tsx +25 -0
  194. package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +218 -0
  195. package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +20 -0
  196. package/src/modules/search/components/Editor/ui/link-element.tsx +29 -0
  197. package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +161 -0
  198. package/src/modules/search/components/Editor/ui/list-element.tsx +30 -0
  199. package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +24 -0
  200. package/src/modules/search/components/Editor/ui/media-embed-element.tsx +133 -0
  201. package/src/modules/search/components/Editor/ui/media-popover.tsx +97 -0
  202. package/src/modules/search/components/Editor/ui/mention-element.tsx +43 -0
  203. package/src/modules/search/components/Editor/ui/mention-input-element.tsx +141 -0
  204. package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +93 -0
  205. package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +67 -0
  206. package/src/modules/search/components/Editor/ui/paragraph-element.tsx +4 -0
  207. package/src/modules/search/components/Editor/ui/placeholder.tsx +52 -0
  208. package/src/modules/search/components/Editor/ui/popover.tsx +32 -0
  209. package/src/modules/search/components/Editor/ui/resizable.tsx +66 -0
  210. package/src/modules/search/components/Editor/ui/separator.tsx +25 -0
  211. package/src/modules/search/components/Editor/ui/style.less +12 -0
  212. package/src/modules/search/components/Editor/ui/table-cell-element.tsx +143 -0
  213. package/src/modules/search/components/Editor/ui/table-element.tsx +243 -0
  214. package/src/modules/search/components/Editor/ui/table-row-element.tsx +22 -0
  215. package/src/modules/search/components/Editor/ui/tableValue.tsx +135 -0
  216. package/src/modules/search/components/Editor/ui/todo-list-element.tsx +43 -0
  217. package/src/modules/search/components/Editor/ui/toggle-element.tsx +31 -0
  218. package/src/modules/search/components/Editor/ui/toolbar.tsx +157 -0
  219. package/src/modules/search/components/Editor/ui/tooltip.tsx +65 -0
  220. package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +160 -0
  221. package/src/modules/search/components/Editor/ui/with-draggables.tsx +175 -0
  222. package/src/modules/search/components/FileList.tsx +287 -0
  223. package/src/modules/search/components/ImageGroupView/index.tsx +85 -0
  224. package/src/modules/search/components/ResultContent.tsx +232 -0
  225. package/src/modules/search/components/SearchInput.tsx +232 -0
  226. package/src/modules/search/components/SearchLanding.tsx +74 -0
  227. package/src/modules/search/components/SearchView.tsx +563 -0
  228. package/src/modules/search/components/SimpleEditor.tsx +158 -0
  229. package/src/modules/search/components/SimpleFileList.tsx +215 -0
  230. package/src/modules/search/index.tsx +10 -0
  231. package/src/modules/search/reademe.md +1 -0
  232. package/src/modules/search/servers/apis.tsx +19 -0
  233. package/src/modules/search/servers/index.ts +184 -0
  234. package/src/modules/search/style.less +503 -0
  235. package/src/modules/search/type.ts +22 -0
  236. package/src/modules/search/utils.ts +34 -0
  237. package/src/modules/sensitive/index.tsx +313 -0
  238. package/src/modules/sensitive/server.ts +122 -0
  239. package/src/modules/streamFilesReader/GientechStreamReader.tsx +1555 -0
  240. package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
  241. package/src/modules/streamFilesReader/components/Header/index.tsx +297 -0
  242. package/src/modules/streamFilesReader/index.tsx +3 -0
  243. package/src/style.css +6 -0
  244. package/src/type.d.ts +0 -0
  245. package/src/utils/commonFn.tsx +111 -0
  246. package/src/utils/gientechCommon/components/AppError.tsx +32 -0
  247. package/src/utils/gientechCommon/components/AppLoading.tsx +75 -0
  248. package/src/utils/gientechCommon/components/DeleteModal.tsx +75 -0
  249. package/src/utils/gientechCommon/components/DisplayError.tsx +33 -0
  250. package/src/utils/gientechCommon/components/DisplayLoading.tsx +38 -0
  251. package/src/utils/gientechCommon/components/FeedBackModal.tsx +310 -0
  252. package/src/utils/gientechCommon/components/FileCardCommon.tsx +82 -0
  253. package/src/utils/gientechCommon/components/FileManager/index.tsx +390 -0
  254. package/src/utils/gientechCommon/components/FileManager/style.css +5 -0
  255. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +296 -0
  256. package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +339 -0
  257. package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +245 -0
  258. package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +209 -0
  259. package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
  260. package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +148 -0
  261. package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +14 -0
  262. package/src/utils/gientechCommon/components/RenameModal.tsx +86 -0
  263. package/src/utils/gientechCommon/components/style.less +11 -0
  264. package/src/utils/gientechCommon/configs/commonConfig.ts +2 -0
  265. package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
  266. package/src/utils/gientechCommon/configs/stylesConfig.ts +142 -0
  267. package/src/utils/gientechCommon/hooks/AichatUseController.tsx +345 -0
  268. package/src/utils/gientechCommon/slate/converters/deserializers.ts +763 -0
  269. package/src/utils/gientechCommon/slate/converters/mockData.ts +232 -0
  270. package/src/utils/gientechCommon/slate/converters/slateConverters.ts +258 -0
  271. package/src/utils/gientechCommon/slate/richElements/index.tsx +499 -0
  272. package/src/utils/gientechCommon/utils/request.ts +37 -0
  273. package/src/utils/gientechCommon/utils/serverFn.ts +172 -0
  274. package/src/utils/index.tsx +126 -0
  275. package/src/utils/testconfigs/demologin/index.tsx +32 -0
  276. package/src/utils/testconfigs/index.ts +53 -0
  277. package/src/vite-env.d.ts +11 -0
  278. package/stats.html +4949 -0
  279. package/tailwind.config.js +170 -0
  280. package/tsconfig.app.json +30 -0
  281. package/tsconfig.app.tsbuildinfo +11 -0
  282. package/tsconfig.json +13 -0
  283. package/tsconfig.node.json +22 -0
  284. package/tsconfig.node.tsbuildinfo +1 -0
  285. package/vite.config.ts +177 -0
  286. package/workflows/release.yml +60 -0
  287. package/assets/style.css +0 -1
  288. package/assets/style3.css +0 -1
  289. package/database.js +0 -20
  290. /package/{assets → dist/assets}/Doris.png +0 -0
  291. /package/{assets → dist/assets}/PostgreSQL.png +0 -0
  292. /package/{assets → dist/assets}/SQLServer.png +0 -0
  293. /package/{assets → dist/assets}/_commonjsHelpers-gnU0ypJ3.js +0 -0
  294. /package/{assets → dist/assets}/circle-alert-g2Y6zAjt.js +0 -0
  295. /package/{assets → dist/assets}/empty.png +0 -0
  296. /package/{assets → dist/assets}/index-CEK88UzR.js +0 -0
  297. /package/{assets → dist/assets}/index-CpW6Dhpp.js +0 -0
  298. /package/{assets → dist/assets}/plus-omCUN0e3.js +0 -0
  299. /package/{assets → dist/assets}/style2.css +0 -0
  300. /package/{assets → dist/assets}/styled-components.browser.esm-DPkS13KC.js +0 -0
  301. /package/{assets → dist/assets}/x-vPcWt3fC.js +0 -0
  302. /package/{chat.d.ts → dist/chat.d.ts} +0 -0
  303. /package/{database.d.ts → dist/database.d.ts} +0 -0
  304. /package/{databaseId.d.ts → dist/databaseId.d.ts} +0 -0
  305. /package/{databaseTable.d.ts → dist/databaseTable.d.ts} +0 -0
  306. /package/{modelManage.d.ts → dist/modelManage.d.ts} +0 -0
  307. /package/{sensitive.d.ts → dist/sensitive.d.ts} +0 -0
  308. /package/{streamFilesReader.d.ts → dist/streamFilesReader.d.ts} +0 -0
  309. /package/{vite.svg → dist/vite.svg} +0 -0
@@ -0,0 +1,86 @@
1
+ import { BorderBottomOutlined } from "@ant-design/icons";
2
+ import { Button, ConfigProvider, Form, Input, Modal } from "antd";
3
+ import { useForm } from "antd/es/form/Form";
4
+ import { useEffect } from "react";
5
+
6
+ export const RenameModal = ({
7
+ isModalOpen,
8
+ handleOk,
9
+ handleCancel,
10
+ data
11
+ }: any) => {
12
+ const modalStyles = {
13
+ header: {
14
+ height: "60px",
15
+ borderBottom: "1px solid #F0F0F0",
16
+ display: "flex",
17
+ paddingLeft: "24px",
18
+ alignItems: "center",
19
+ marginBottom: "16px"
20
+ },
21
+ title: { fontSize: "16px" },
22
+ body: { padding: "0 24px" },
23
+ mask: {},
24
+ footer: { marginTop: "0px", padding: "0 24px 16px 24px" },
25
+ content: { padding: 0 }
26
+ };
27
+ const [rename_form] = useForm();
28
+ useEffect(() => {
29
+ if (!isModalOpen) {
30
+ rename_form.resetFields();
31
+ return;
32
+ }
33
+ rename_form.setFieldValue("new_name", data?.label);
34
+ }, [data, isModalOpen]);
35
+ return (
36
+ <ConfigProvider
37
+ modal={{
38
+ styles: modalStyles
39
+ }}
40
+ >
41
+ <Modal
42
+ title={<div className="text-[16px]">编辑会话名称</div>}
43
+ closeIcon={null}
44
+ open={isModalOpen}
45
+ width={520}
46
+ centered
47
+ className="[&:[.ant-modal-content]]:bg-red"
48
+ footer={
49
+ <div className="mt-[16px] flex justify-end">
50
+ <Button
51
+ children="取消"
52
+ onClick={handleCancel}
53
+ className="mr-[8px]"
54
+ />
55
+ <Button
56
+ children="确认"
57
+ onClick={async () => {
58
+ try {
59
+ const data = await rename_form.validateFields();
60
+ handleOk("ok_rename", data);
61
+ } catch (e) {
62
+ console.log(e);
63
+ return;
64
+ }
65
+ }}
66
+ type="primary"
67
+ className="border-none"
68
+ />
69
+ </div>
70
+ }
71
+ >
72
+ <Form form={rename_form}>
73
+ <Form.Item
74
+ name="new_name"
75
+ rules={[
76
+ { required: true, message: "请输入" },
77
+ { max: 100, message: "最大字数限制100" }
78
+ ]}
79
+ >
80
+ <Input />
81
+ </Form.Item>
82
+ </Form>
83
+ </Modal>
84
+ </ConfigProvider>
85
+ );
86
+ };
@@ -0,0 +1,11 @@
1
+ .selfTree {
2
+ .ant-tree .ant-tree-treenode {
3
+ padding: 4px 0 4px 0;
4
+ }
5
+ .ant-tree-switcher {
6
+ display: none;
7
+ }
8
+ .ant-tree-indent {
9
+ display: none;
10
+ }
11
+ }
@@ -0,0 +1,2 @@
1
+ export const maxPollCount = 1000;
2
+ export const maxPollInterval = 3000;
@@ -0,0 +1,142 @@
1
+ // 主题类型定义
2
+ export type SizeType = 'sm' | 'md' | 'lg'
3
+ export type FontWeightType = 'normal' | 'bold' |'thin'
4
+ export type FontFamilyType = 'default' | 'serif' | 'mono'
5
+
6
+ export interface AiChatStyles {
7
+ theme?: AppTheme
8
+ mode?: 'light' | 'dark'
9
+ [key: string]: any
10
+ }
11
+
12
+ export interface ThemeColors {
13
+ primary: string
14
+ secondary: string
15
+ success: string
16
+ warning: string
17
+ error: string
18
+ info: string
19
+ background: string
20
+ text: string
21
+ border: string
22
+ disabled: string
23
+ disabledBackground: string
24
+ disabledText: string
25
+ shadow: string
26
+ appBackground: string
27
+ }
28
+
29
+ export interface ThemeOthers {
30
+
31
+ }
32
+
33
+ export interface ThemeSpace {
34
+ sidebar: string
35
+ size: string
36
+ radius: string
37
+ padding: string
38
+ margin: string
39
+ shadow: string
40
+ lineHeight: string
41
+ }
42
+
43
+ export interface ThemeIcons {
44
+ aiAvatar: string
45
+ userAvatar: string
46
+ pdf: string
47
+ word: string
48
+ image: string
49
+ video: string
50
+ audio: string
51
+ excel: string
52
+ ppt: string
53
+ }
54
+
55
+ export interface AppTheme {
56
+ colors: ThemeColors
57
+
58
+ space: ThemeSpace
59
+ icons: ThemeIcons
60
+ others: ThemeOthers
61
+ }
62
+
63
+ // 默认主题实现
64
+ export const defaultTheme: AppTheme = {
65
+ colors: {
66
+ primary: '#007bff',
67
+ secondary: '#6c757d',
68
+ success: '#008000',
69
+ warning: '#FFA500',
70
+ error: '#FF0000',
71
+ info: '#0000FF',
72
+ background: '#f8f9fa',
73
+ text: '#343a40',
74
+ border: '#dee2e6',
75
+ disabled: '#808080',
76
+ disabledBackground: '#F5F5F5',
77
+ disabledText: '#808080',
78
+ shadow: '#000000',
79
+ appBackground: '#fff',
80
+ },
81
+ space: {
82
+ sidebar: 'md',
83
+ size: 'md',
84
+ radius: 'md',
85
+ padding: 'md',
86
+ margin: 'md',
87
+ shadow: 'md',
88
+ lineHeight: 'md',
89
+ },
90
+ icons: {
91
+ aiAvatar: 'http://10.15.12.13:9000/dev-rag-data/header_pic/JIABINBIN00/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20231212161213.jpg',
92
+ userAvatar: 'http://10.15.12.13:9005/assets/nav-logo-BKaOCDqi.png',
93
+ pdf: 'https://ai-chat-1326151111.cos.ap-shanghai.myqcloud.com/pdf-icon.png',
94
+ word: 'https://ai-chat-1326151111.cos.ap-shanghai.myqcloud.com/word-icon.png',
95
+ image: 'https://ai-chat-1326151111.cos.ap-shanghai.myqcloud.com/image-icon.png',
96
+ video: 'https://ai-chat-1326151111.cos.ap-shanghai.myqcloud.com/video-icon.png',
97
+ audio: 'https://ai-chat-1326151111.cos.ap-shanghai.myqcloud.com/audio-icon.png',
98
+ excel: 'https://ai-chat-1326151111.cos.c zap-shanghai.myqcloud.com/excel-icon.png',
99
+ ppt: 'https://ai-chat-1326151111.cos.ap-shanghai.myqcloud.com/ppt-icon.png',
100
+ },
101
+ others: {
102
+ baseFontWeight: 'normal',
103
+ },
104
+ }
105
+
106
+ // SizeType 映射表
107
+ export const sidebarMap = {
108
+ sm: '240px',
109
+ md: '260px',
110
+ lg: '280px',
111
+ };
112
+ export const sizeMap = {
113
+ sm: '12px',
114
+ md: '16px',
115
+ lg: '20px',
116
+ };
117
+ export const radiusMap = {
118
+ sm: '2px',
119
+ md: '4px',
120
+ lg: '8px',
121
+ };
122
+ export const paddingMap = {
123
+ sm: '4px',
124
+ md: '8px',
125
+ lg: '16px',
126
+ };
127
+ export const marginMap = {
128
+ sm: '4px',
129
+ md: '8px',
130
+ lg: '16px',
131
+ };
132
+ export const shadowMap = {
133
+ sm: '0 1px 2px #eee',
134
+ md: '0 2px 8px #ddd',
135
+ lg: '0 4px 16px #ccc',
136
+ };
137
+ export const lineHeightMap = {
138
+ sm: '1.2',
139
+ md: '1.5',
140
+ lg: '2',
141
+ };
142
+
@@ -0,0 +1,345 @@
1
+ import { EventSourceMessage, fetchEventSource } from '@microsoft/fetch-event-source';
2
+
3
+ import { uid } from 'uid';
4
+ import { AppStatusManager } from '@mxmweb/aichat';
5
+
6
+ interface Api_Chat {
7
+ sessionId: string;
8
+ queryId: string;
9
+ name: string;
10
+ lastDate: string | number;
11
+ type: string;
12
+ content: string;
13
+ configId: string;
14
+ audioUrl: string;
15
+ fileUids: any[];
16
+ signal?: AbortSignal;
17
+ sysType?: 'KNO_INDEX' | 'INT_SESSION' | 'TEMPORARY';
18
+ }
19
+
20
+ export enum StatusType {
21
+ Pending = 0,
22
+ Process,
23
+ Done,
24
+ Error,
25
+ }
26
+
27
+ class FatalError extends Error {}
28
+
29
+ let currentStreamController: AbortController | null = null;
30
+
31
+ const AichatUseController = ({
32
+ baseUrl,
33
+ token,
34
+ CSRFToken,
35
+ setChatData,
36
+ activeSessionId,
37
+ setAppStatus,
38
+ setConversationList,
39
+ }: {
40
+ baseUrl: string;
41
+ token: string;
42
+ CSRFToken?: string;
43
+ setChatData: (arg: any[] | ((prev: any[]) => any[])) => void;
44
+ activeSessionId: string | undefined;
45
+ setAppStatus: React.Dispatch<React.SetStateAction<AppStatusManager>>;
46
+ setConversationList: React.Dispatch<React.SetStateAction<any[]>>;
47
+ }) => {
48
+ const reset_chat = ({
49
+ content,
50
+ status,
51
+ respTime,
52
+ filePaths,
53
+ reference,
54
+ webReference,
55
+ graphReference,
56
+ databaseReference,
57
+ llmType,
58
+ resultType,
59
+ queryId,
60
+ tokens,
61
+ }: {
62
+ content: string;
63
+ status: StatusType;
64
+ respTime: number;
65
+ filePaths: any[];
66
+ reference: string;
67
+ webReference: string;
68
+ graphReference?: string;
69
+ databaseReference?: any;
70
+ llmType: number;
71
+ resultType: number;
72
+ queryId?: string;
73
+ tokens: number;
74
+ [key: string]: any;
75
+ }) => {
76
+ setChatData((chatList: any) => {
77
+ if (!chatList[0]) return chatList;
78
+ const current = chatList[0];
79
+ const messages = current.messages || [];
80
+ const lastIndex = messages.length - 1;
81
+ if (lastIndex < 0) return chatList;
82
+ const lastMessage = messages[lastIndex];
83
+ if (lastMessage.istype !== 'ai') return chatList;
84
+
85
+ // 更新上一条 user 的 filePaths(不可变)
86
+ let newMessages = messages.slice();
87
+ if (filePaths?.length) {
88
+ const lastSecondIndex = messages.length - 2;
89
+ if (lastSecondIndex >= 0 && messages[lastSecondIndex]?.istype === 'user') {
90
+ const lastSecond = { ...messages[lastSecondIndex], filePaths };
91
+ newMessages[lastSecondIndex] = lastSecond;
92
+ }
93
+ }
94
+
95
+ const updatedLast = {
96
+ ...lastMessage,
97
+ content: (lastMessage.content || '') + content,
98
+ status,
99
+ respTime,
100
+ filePaths,
101
+ reference,
102
+ webReference,
103
+ graphReference: graphReference ?? lastMessage.graphReference,
104
+ // 流式阶段若后端带来了 databaseReference,写入当前 AI 消息
105
+ databaseReference: databaseReference ?? lastMessage.databaseReference,
106
+ resultType,
107
+ llmType,
108
+ tokens,
109
+ queryId: queryId || lastMessage.queryId || uid(32),
110
+ } as any;
111
+ updatedLast.clientSideId = updatedLast.clientSideId || updatedLast.queryId + '-ai';
112
+ newMessages[lastIndex] = updatedLast;
113
+
114
+ const newChat0 = { ...current, isNew: false, messages: newMessages };
115
+ return [newChat0, ...chatList.slice(1)];
116
+ });
117
+ };
118
+
119
+ const onErrorCallback = (err: any) => {
120
+ if (err instanceof FatalError) {
121
+ setAppStatus((pre:any) => ({ ...pre, display: 'error', sender: 'ready' }));
122
+ if (currentStreamController) {
123
+ currentStreamController.abort();
124
+ currentStreamController = null;
125
+ }
126
+ throw err;
127
+ }
128
+ // 其他错误可选处理
129
+ };
130
+
131
+ const api_startChat_re = (data: Api_Chat, onSuccess?: (gmtModified: number) => void) => {
132
+ if (currentStreamController) {
133
+ currentStreamController.abort();
134
+ }
135
+ currentStreamController = new AbortController();
136
+ const eventSourceUrl = `${baseUrl}/qa/ai/question_re`;
137
+ console.log('data', data);
138
+ const params = { ...data };
139
+ fetchEventSource(eventSourceUrl, {
140
+ method: 'post',
141
+ signal: currentStreamController.signal,
142
+ headers: {
143
+ 'Content-Type': 'application/json',
144
+ Accept: 'text/event-stream',
145
+ Authorization: token || '',
146
+ 'X-CSRF-TOKEN-IN': CSRFToken || '',
147
+ },
148
+ openWhenHidden: true,
149
+ body: JSON.stringify(params),
150
+ onopen: async response => {
151
+ if (response.status === 500) {
152
+ throw new FatalError('Internal Server Error');
153
+ }
154
+ if (!response.ok) {
155
+ throw new FatalError(`HTTP error: ${response.status}`);
156
+ }
157
+ // 其他状态可根据需要处理
158
+ },
159
+ onmessage: event => {
160
+ const curData = JSON.parse(event.data);
161
+ if (activeSessionId !== curData.sessionId) return;
162
+ const {
163
+ reply,
164
+ resultType,
165
+ respTime,
166
+ reference,
167
+ webReference,
168
+ graphReference,
169
+ filePaths,
170
+ status,
171
+ docs,
172
+ llmType,
173
+ databaseReference,
174
+ } = curData;
175
+ const _filePaths = filePaths ? JSON.parse(filePaths) : [];
176
+ //console.log('curData```````````````````````',curData,curData.tokens);
177
+ // === 新增:流式错误兜底 ===
178
+ if (
179
+ status === StatusType.Done &&
180
+ reply &&
181
+ reply.content &&
182
+ (reply.content.includes('模型暂无法返回') ||
183
+ reply.content.includes('失败') ||
184
+ reply.content.includes('错误') ||
185
+ reply.content.includes('请稍后再试'))
186
+ ) {
187
+ setAppStatus((pre:any) => ({ ...pre, display: 'ready', sender: 'ready' }));
188
+ }
189
+ if (status === StatusType.Done) {
190
+ reset_chat({
191
+ content: reply.content || '',
192
+ status: StatusType.Done, // 流式完成时,消息状态应该是 Done
193
+ respTime: respTime,
194
+ filePaths: _filePaths,
195
+ reference: reference || docs || '',
196
+ webReference: webReference || '',
197
+ graphReference: graphReference || null,
198
+ databaseReference,
199
+ llmType,
200
+ resultType,
201
+ queryId: curData.queryId,
202
+ tokens: curData.tokens,
203
+ });
204
+ setAppStatus((pre:any) => {
205
+ return {
206
+ ...pre,
207
+ display: 'ready',
208
+ sender: 'ready',
209
+ };
210
+ });
211
+ if (onSuccess) {
212
+ const gmtModified = respTime || Date.now();
213
+ console.log('[AichatUseController] 消息发送成功,gmtModified:', gmtModified);
214
+ onSuccess(gmtModified);
215
+ }
216
+ } else {
217
+ reset_chat({
218
+ content: reply.content || '',
219
+ status: status,
220
+ respTime: respTime,
221
+ filePaths: _filePaths,
222
+ reference: reference || docs || '',
223
+ webReference: webReference || '',
224
+ graphReference: graphReference || null, // 流式过程中保持之前的graphReference值
225
+ databaseReference,
226
+ llmType,
227
+ resultType,
228
+ queryId: curData.queryId,
229
+ tokens: curData.tokens,
230
+ });
231
+ }
232
+ },
233
+ onerror: onErrorCallback,
234
+ });
235
+ };
236
+
237
+ const setLastEmptyMessage = ({ now }: { now: number }) => {
238
+ setChatData((chatList: any[]) => {
239
+ if (!chatList[0]) return chatList;
240
+ const current = chatList[0];
241
+ const messages = current.messages || [];
242
+ if (!messages.length) return chatList;
243
+ const lastIndex = messages.length - 1;
244
+ if (lastIndex < 0) return chatList;
245
+ const lastMessage = messages[lastIndex];
246
+ if (lastMessage.istype !== 'ai') return chatList;
247
+ const newMessages = messages.slice();
248
+ newMessages[lastIndex] = {
249
+ ...lastMessage,
250
+ istype: 'ai',
251
+ content: '',
252
+ time: now,
253
+ streaming: true,
254
+ status: StatusType.Pending,
255
+ } as any;
256
+ const newChat0 = { ...current, messages: newMessages };
257
+ return [newChat0, ...chatList.slice(1)];
258
+ });
259
+ };
260
+
261
+ const addEmptyMessage = ({
262
+ queryId,
263
+ content,
264
+ filePaths,
265
+ currentFiles,
266
+ }: {
267
+ queryId: string;
268
+ content: string;
269
+ filePaths?: string;
270
+ currentFiles?: any[];
271
+ }) => {
272
+ setChatData((chatList: any[]) => {
273
+ const now = new Date().toISOString();
274
+ const _queryId = queryId || uid(32); // 保证只生成一次
275
+ const userMessage = {
276
+ istype: 'user',
277
+ content: content,
278
+ time: now,
279
+ queryId: _queryId,
280
+ clientSideId: _queryId + '-user',
281
+ filePaths: filePaths || '',
282
+ currentFiles: currentFiles || [],
283
+ };
284
+ const aiMessage = {
285
+ istype: 'ai',
286
+ content: '', // AI回复流式填充
287
+ time: new Date(Date.now() + 1).toISOString(),
288
+ streaming: true,
289
+ status: StatusType.Pending,
290
+ queryId: _queryId,
291
+ clientSideId: _queryId + '-ai',
292
+ };
293
+
294
+ // 找到当前激活的对话
295
+ const activeChat = chatList.find(chat => chat.id === activeSessionId);
296
+
297
+ if (activeChat) {
298
+ // 如果激活的对话存在,则向其添加新消息
299
+ activeChat.messages.push(userMessage, aiMessage);
300
+ } else {
301
+ // 如果没有激活的对话(例如首次加载),则需要特殊处理
302
+ // 这里的逻辑可能需要根据产品需求调整,是创建新对话还是报错
303
+ // 假设我们总是有一个激活的对话
304
+ console.warn('addEmptyMessage called without an active session.');
305
+ }
306
+ return [...chatList];
307
+ });
308
+ };
309
+
310
+ // 主动终止当前 stream
311
+ const stopStream = () => {
312
+ if (currentStreamController) {
313
+ currentStreamController.abort();
314
+ currentStreamController = null;
315
+ }
316
+ setAppStatus((pre:any) => ({ ...pre, display: 'ready', sender: 'ready' }));
317
+ };
318
+
319
+ const updateUserFilesMessage = ({ currentFiles }: { currentFiles: any[] }) => {
320
+ setChatData((chatList: any[]) => {
321
+ if (!chatList[0]) return chatList;
322
+ const current = chatList[0];
323
+ const messages = current.messages || [];
324
+ if (!messages.length) return chatList;
325
+ const lastIndex = messages.length - 2;
326
+ if (lastIndex < 0) return chatList;
327
+ const lastMessage = messages[lastIndex];
328
+ if (lastMessage.istype !== 'user') return chatList;
329
+ const newMessages = messages.slice();
330
+ newMessages[lastIndex] = { ...messages[lastIndex], currentFiles } as any;
331
+ const newChat0 = { ...current, messages: newMessages };
332
+ return [newChat0, ...chatList.slice(1)];
333
+ });
334
+ };
335
+
336
+ return {
337
+ updateUserFilesMessage,
338
+ api_startChat_re,
339
+ addEmptyMessage,
340
+ setLastEmptyMessage,
341
+ stopStream,
342
+ };
343
+ };
344
+
345
+ export default AichatUseController;