@lobehub/chat 1.11.9 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/.github/workflows/release.yml +2 -1
  2. package/.github/workflows/test.yml +2 -1
  3. package/CHANGELOG.md +25 -0
  4. package/Dockerfile.database +2 -0
  5. package/docs/self-hosting/advanced/knowledge-base.zh-CN.mdx +65 -0
  6. package/locales/ar/chat.json +13 -3
  7. package/locales/ar/components.json +2 -0
  8. package/locales/bg-BG/chat.json +13 -3
  9. package/locales/bg-BG/components.json +2 -0
  10. package/locales/de-DE/chat.json +13 -3
  11. package/locales/de-DE/components.json +2 -0
  12. package/locales/en-US/chat.json +13 -3
  13. package/locales/en-US/components.json +2 -0
  14. package/locales/es-ES/chat.json +13 -3
  15. package/locales/es-ES/components.json +2 -0
  16. package/locales/fr-FR/chat.json +13 -3
  17. package/locales/fr-FR/components.json +2 -0
  18. package/locales/it-IT/chat.json +13 -3
  19. package/locales/it-IT/components.json +2 -0
  20. package/locales/ja-JP/chat.json +13 -3
  21. package/locales/ja-JP/components.json +2 -0
  22. package/locales/ko-KR/chat.json +13 -3
  23. package/locales/ko-KR/components.json +2 -0
  24. package/locales/nl-NL/chat.json +13 -3
  25. package/locales/nl-NL/components.json +2 -0
  26. package/locales/pl-PL/chat.json +13 -3
  27. package/locales/pl-PL/components.json +2 -0
  28. package/locales/pt-BR/chat.json +13 -3
  29. package/locales/pt-BR/components.json +2 -0
  30. package/locales/ru-RU/chat.json +13 -3
  31. package/locales/ru-RU/components.json +2 -0
  32. package/locales/tr-TR/chat.json +13 -3
  33. package/locales/tr-TR/components.json +2 -0
  34. package/locales/vi-VN/chat.json +13 -3
  35. package/locales/vi-VN/components.json +2 -0
  36. package/locales/zh-CN/chat.json +13 -3
  37. package/locales/zh-CN/components.json +2 -0
  38. package/locales/zh-TW/chat.json +13 -3
  39. package/locales/zh-TW/components.json +2 -0
  40. package/package.json +3 -2
  41. package/scripts/migrateServerDB/docker.cjs +6 -0
  42. package/scripts/migrateServerDB/errorHint.js +17 -0
  43. package/scripts/migrateServerDB/index.ts +6 -0
  44. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/Content.tsx +37 -0
  45. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/index.tsx +87 -0
  46. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/style.ts +4 -0
  47. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileItem/utils.ts +28 -0
  48. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/FileList.tsx +41 -0
  49. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/FilePreview/index.tsx +40 -0
  50. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/SendMore.tsx +1 -1
  51. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/index.tsx +7 -22
  52. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.tsx +1 -1
  53. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +2 -4
  54. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/File.tsx +72 -0
  55. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/Image.tsx +74 -0
  56. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/index.tsx +39 -0
  57. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/FileItem/style.ts +1 -0
  58. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files/index.tsx +33 -0
  59. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/InputArea/Container.tsx +41 -0
  60. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/InputArea/index.tsx +154 -0
  61. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Send.tsx +34 -0
  62. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/index.tsx +24 -11
  63. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/components/UploadDetail/UploadStatus.tsx +71 -0
  64. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/components/UploadDetail/index.tsx +49 -0
  65. package/src/app/(main)/chat/(workspace)/@portal/FilePreview/index.tsx +26 -0
  66. package/src/app/(main)/chat/(workspace)/@portal/Home/Files/FileList/Item.tsx +53 -0
  67. package/src/app/(main)/chat/(workspace)/@portal/Home/Files/FileList/index.tsx +50 -0
  68. package/src/app/(main)/chat/(workspace)/@portal/Home/Files/index.tsx +21 -0
  69. package/src/app/(main)/chat/(workspace)/@portal/Home/index.tsx +2 -0
  70. package/src/app/(main)/chat/(workspace)/@portal/router.tsx +4 -0
  71. package/src/app/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/KnowledgeTag.tsx +41 -0
  72. package/src/app/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Tags.tsx +7 -2
  73. package/src/app/(main)/chat/(workspace)/_layout/Desktop/HotKeys.tsx +1 -1
  74. package/src/app/(main)/files/(content)/@menu/default.tsx +27 -0
  75. package/src/app/(main)/files/(content)/@menu/features/FileMenu/index.tsx +97 -0
  76. package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/EmptyStatus.tsx +53 -0
  77. package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/Item/Content.tsx +175 -0
  78. package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/Item/index.tsx +69 -0
  79. package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/KnowledgeBaseList.tsx +30 -0
  80. package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/SkeletonList.tsx +57 -0
  81. package/src/app/(main)/files/(content)/@menu/features/KnowledgeBase/index.tsx +54 -0
  82. package/src/app/(main)/files/(content)/@modal/(.)[id]/FileDetail.tsx +16 -0
  83. package/src/app/(main)/files/(content)/@modal/(.)[id]/FilePreview.tsx +15 -0
  84. package/src/app/(main)/files/(content)/@modal/(.)[id]/FullscreenModal.tsx +85 -0
  85. package/src/app/(main)/files/(content)/@modal/(.)[id]/page.tsx +19 -0
  86. package/src/app/(main)/files/(content)/@modal/default.tsx +3 -0
  87. package/src/app/(main)/files/(content)/NotSupportClient.tsx +152 -0
  88. package/src/app/(main)/files/(content)/_layout/Desktop/index.tsx +28 -0
  89. package/src/app/(main)/files/(content)/_layout/Mobile.tsx +47 -0
  90. package/src/app/(main)/files/(content)/_layout/type.ts +7 -0
  91. package/src/app/(main)/files/(content)/layout.tsx +18 -0
  92. package/src/app/(main)/files/(content)/page.tsx +14 -0
  93. package/src/app/(main)/files/[id]/Header.tsx +63 -0
  94. package/src/app/(main)/files/[id]/page.tsx +44 -0
  95. package/src/app/(main)/files/features/FileDetail.tsx +93 -0
  96. package/src/app/(main)/files/hooks/useFileCategory.ts +9 -0
  97. package/src/app/(main)/files/layout.tsx +12 -0
  98. package/src/app/(main)/files/loading.tsx +21 -0
  99. package/src/app/(main)/repos/[id]/@menu/Head/index.tsx +33 -0
  100. package/src/app/(main)/repos/[id]/@menu/Menu/index.tsx +56 -0
  101. package/src/app/(main)/repos/[id]/@menu/default.tsx +25 -0
  102. package/src/app/(main)/repos/[id]/_layout/Desktop/index.tsx +25 -0
  103. package/src/app/(main)/repos/[id]/_layout/Mobile.tsx +47 -0
  104. package/src/app/(main)/repos/[id]/_layout/type.ts +6 -0
  105. package/src/app/(main)/repos/[id]/hooks/useKnowledgeItem.ts +7 -0
  106. package/src/app/(main)/repos/[id]/layout.tsx +13 -0
  107. package/src/app/(main)/repos/[id]/page.tsx +18 -0
  108. package/src/app/(main)/repos/layout.tsx +13 -0
  109. package/src/app/(main)/repos/page.tsx +5 -0
  110. package/src/app/trpc/async/[trpc]/route.ts +28 -0
  111. package/src/chains/abstractChunk.ts +19 -0
  112. package/src/chains/answerWithContext.ts +34 -0
  113. package/src/chains/rewriteQuery.ts +22 -0
  114. package/src/components/DragUpload/index.tsx +6 -99
  115. package/src/components/DragUpload/useDragUpload.tsx +146 -0
  116. package/src/components/FeatureList/index.tsx +64 -0
  117. package/src/components/FileParsingStatus/index.tsx +230 -0
  118. package/src/components/ImageItem/index.tsx +10 -2
  119. package/src/components/KnowledgeIcon/index.tsx +28 -0
  120. package/src/config/app.ts +6 -1
  121. package/src/config/featureFlags/schema.ts +1 -1
  122. package/src/const/file.ts +1 -0
  123. package/src/const/url.ts +1 -0
  124. package/src/database/client/models/file.ts +8 -2
  125. package/src/database/server/migrations/0005_pgvector.sql +2 -0
  126. package/src/database/server/migrations/0006_add_knowledge_base.sql +307 -0
  127. package/src/database/server/migrations/meta/0005_snapshot.json +2119 -0
  128. package/src/database/server/migrations/meta/0006_snapshot.json +3006 -0
  129. package/src/database/server/migrations/meta/_journal.json +14 -0
  130. package/src/database/server/models/__tests__/_test_template.ts +155 -0
  131. package/src/database/server/models/__tests__/agent.test.ts +226 -0
  132. package/src/database/server/models/__tests__/asyncTask.test.ts +176 -0
  133. package/src/database/server/models/__tests__/chunk.test.ts +336 -0
  134. package/src/database/server/models/__tests__/file.test.ts +317 -29
  135. package/src/database/server/models/__tests__/fixtures/embedding.ts +568 -0
  136. package/src/database/server/models/__tests__/knowledgeBase.test.ts +132 -0
  137. package/src/database/server/models/__tests__/message.test.ts +7 -4
  138. package/src/database/server/models/_template.ts +10 -1
  139. package/src/database/server/models/agent.ts +165 -0
  140. package/src/database/server/models/asyncTask.ts +96 -0
  141. package/src/database/server/models/chunk.ts +203 -0
  142. package/src/database/server/models/embedding.ts +47 -0
  143. package/src/database/server/models/file.ts +231 -12
  144. package/src/database/server/models/knowledgeBase.ts +94 -0
  145. package/src/database/server/models/message.ts +156 -30
  146. package/src/database/server/models/user.ts +12 -1
  147. package/src/database/server/schemas/lobechat/agent.ts +93 -0
  148. package/src/database/server/schemas/lobechat/discover.ts +1 -1
  149. package/src/database/server/schemas/lobechat/file.ts +118 -1
  150. package/src/database/server/schemas/lobechat/index.ts +5 -1
  151. package/src/database/server/schemas/lobechat/message.ts +169 -0
  152. package/src/database/server/schemas/lobechat/rag.ts +51 -0
  153. package/src/database/server/schemas/lobechat/relations.ts +68 -48
  154. package/src/database/server/schemas/lobechat/session.ts +77 -0
  155. package/src/database/server/schemas/lobechat/topic.ts +32 -0
  156. package/src/database/server/schemas/lobechat/user.ts +40 -25
  157. package/src/database/server/utils/idGenerator.ts +1 -0
  158. package/src/features/ChatInput/ActionBar/Clear.tsx +1 -1
  159. package/src/features/ChatInput/ActionBar/Knowledge/Dropdown.tsx +160 -0
  160. package/src/features/ChatInput/ActionBar/Knowledge/ListItem.tsx +52 -0
  161. package/src/features/ChatInput/ActionBar/Knowledge/index.tsx +54 -0
  162. package/src/features/ChatInput/ActionBar/Tools/index.tsx +1 -1
  163. package/src/features/ChatInput/ActionBar/Upload/ClientMode.tsx +52 -0
  164. package/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx +104 -0
  165. package/src/features/ChatInput/ActionBar/Upload/index.tsx +8 -0
  166. package/src/features/ChatInput/ActionBar/config.ts +14 -5
  167. package/src/features/ChatInput/useSend.ts +16 -7
  168. package/src/features/Conversation/Messages/Assistant/FileChunks/Item/index.tsx +51 -0
  169. package/src/features/Conversation/Messages/Assistant/FileChunks/Item/style.ts +38 -0
  170. package/src/features/Conversation/Messages/Assistant/FileChunks/index.tsx +76 -0
  171. package/src/features/Conversation/Messages/Assistant/index.tsx +13 -4
  172. package/src/features/Conversation/Messages/Default.tsx +4 -0
  173. package/src/features/Conversation/Messages/User/BelowMessage.tsx +78 -0
  174. package/src/features/Conversation/Messages/User/FileListViewer/Item.tsx +53 -0
  175. package/src/features/Conversation/Messages/User/FileListViewer/index.tsx +21 -0
  176. package/src/{components/FileList/FileListViewer.tsx → features/Conversation/Messages/User/ImageFileListViewer.tsx} +10 -2
  177. package/src/features/Conversation/Messages/{User.tsx → User/index.tsx} +11 -2
  178. package/src/features/Conversation/Messages/index.ts +8 -3
  179. package/src/features/Conversation/components/ChatItem/index.tsx +33 -10
  180. package/src/features/Conversation/components/InboxWelcome/QuestionSuggest.tsx +1 -1
  181. package/src/features/Conversation/types/index.tsx +1 -0
  182. package/src/features/FileManager/ChunkDrawer/ChunkList/ChunkItem.tsx +61 -0
  183. package/src/features/FileManager/ChunkDrawer/ChunkList/index.tsx +42 -0
  184. package/src/features/FileManager/ChunkDrawer/Content.tsx +38 -0
  185. package/src/features/FileManager/ChunkDrawer/Loading/index.tsx +16 -0
  186. package/src/features/FileManager/ChunkDrawer/SimilaritySearchList/Item.tsx +62 -0
  187. package/src/features/FileManager/ChunkDrawer/SimilaritySearchList/index.tsx +31 -0
  188. package/src/features/FileManager/ChunkDrawer/index.tsx +48 -0
  189. package/src/features/FileManager/FileList/EmptyStatus.tsx +153 -0
  190. package/src/features/FileManager/FileList/FileListItem/ChunkTag.tsx +35 -0
  191. package/src/features/FileManager/FileList/FileListItem/DropdownMenu.tsx +150 -0
  192. package/src/features/FileManager/FileList/FileListItem/index.tsx +211 -0
  193. package/src/features/FileManager/FileList/FileSkeleton.tsx +25 -0
  194. package/src/features/FileManager/FileList/ToolBar/Config.tsx +28 -0
  195. package/src/features/FileManager/FileList/ToolBar/MultiSelectActions.tsx +152 -0
  196. package/src/features/FileManager/FileList/ToolBar/index.tsx +114 -0
  197. package/src/features/FileManager/FileList/index.tsx +143 -0
  198. package/src/features/FileManager/FileList/useCheckTaskStatus.ts +27 -0
  199. package/src/features/FileManager/Header/FilesSearchBar.tsx +41 -0
  200. package/src/features/FileManager/Header/UploadFileButton.tsx +79 -0
  201. package/src/features/FileManager/Header/index.tsx +39 -0
  202. package/src/features/FileManager/UploadDock/Item.tsx +124 -0
  203. package/src/features/FileManager/UploadDock/index.tsx +183 -0
  204. package/src/features/FileManager/index.tsx +38 -0
  205. package/src/features/FileSidePanel/index.tsx +79 -0
  206. package/src/features/FileViewer/NotSupport/index.tsx +54 -0
  207. package/src/features/FileViewer/PDFViewer/HighlightLayer.tsx +81 -0
  208. package/src/features/FileViewer/PDFViewer/index.tsx +93 -0
  209. package/src/features/FileViewer/PDFViewer/style.ts +20 -0
  210. package/src/features/FileViewer/PDFViewer/useResizeObserver.ts +33 -0
  211. package/src/features/FileViewer/TXTViewer/index.tsx +41 -0
  212. package/src/features/FileViewer/index.tsx +45 -0
  213. package/src/features/KnowledgeBaseModal/AddFilesToKnowledgeBase/SelectForm.tsx +115 -0
  214. package/src/features/KnowledgeBaseModal/AddFilesToKnowledgeBase/index.tsx +43 -0
  215. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/Action.tsx +103 -0
  216. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/EditCustomPlugin.tsx +55 -0
  217. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/PluginTag.tsx +58 -0
  218. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/index.tsx +70 -0
  219. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/List.tsx +49 -0
  220. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Loading.tsx +13 -0
  221. package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/index.tsx +39 -0
  222. package/src/features/KnowledgeBaseModal/CreateNew/CreateForm.tsx +73 -0
  223. package/src/features/KnowledgeBaseModal/CreateNew/index.tsx +35 -0
  224. package/src/features/KnowledgeBaseModal/index.ts +3 -0
  225. package/src/libs/langchain/loaders/pdf/index.ts +2 -2
  226. package/src/libs/trpc/async/asyncAuth.ts +24 -0
  227. package/src/libs/trpc/async/index.ts +10 -0
  228. package/src/libs/trpc/async/init.ts +11 -0
  229. package/src/libs/trpc/client/async.ts +14 -0
  230. package/src/libs/trpc/client/index.ts +1 -0
  231. package/src/libs/trpc/client/lambda.ts +9 -0
  232. package/src/libs/trpc/middleware/keyVaults.ts +18 -0
  233. package/src/libs/unstructured/__tests__/index.test.ts +0 -10
  234. package/src/libs/unstructured/index.ts +6 -11
  235. package/src/locales/default/chat.ts +47 -3
  236. package/src/locales/default/common.ts +1 -0
  237. package/src/locales/default/components.ts +2 -0
  238. package/src/locales/default/error.ts +6 -1
  239. package/src/locales/default/file.ts +92 -0
  240. package/src/locales/default/index.ts +4 -0
  241. package/src/locales/default/knowledgeBase.ts +31 -0
  242. package/src/locales/default/portal.ts +1 -0
  243. package/src/middleware.ts +3 -0
  244. package/src/server/asyncContext.ts +40 -0
  245. package/src/server/modules/ContentChunk/index.ts +135 -0
  246. package/src/server/modules/S3/index.ts +30 -5
  247. package/src/server/routers/async/caller.ts +27 -0
  248. package/src/server/routers/async/file.ts +247 -0
  249. package/src/server/routers/async/index.ts +12 -0
  250. package/src/server/routers/lambda/_template.ts +77 -0
  251. package/src/server/routers/lambda/agent.ts +159 -0
  252. package/src/server/routers/lambda/chunk.ts +189 -0
  253. package/src/server/routers/lambda/file.ts +129 -5
  254. package/src/server/routers/lambda/index.ts +6 -0
  255. package/src/server/routers/lambda/knowledgeBase.ts +79 -0
  256. package/src/server/routers/lambda/message.ts +6 -0
  257. package/src/server/routers/lambda/session.ts +0 -25
  258. package/src/server/routers/lambda/user.ts +5 -1
  259. package/src/server/services/chunk/index.ts +74 -0
  260. package/src/server/utils/files.ts +9 -0
  261. package/src/services/__tests__/chat.test.ts +18 -20
  262. package/src/services/__tests__/{upload.test.ts → upload_legacy.test.ts} +1 -1
  263. package/src/services/agent.ts +45 -0
  264. package/src/services/chat.ts +17 -15
  265. package/src/services/file/client.test.ts +1 -50
  266. package/src/services/file/client.ts +12 -25
  267. package/src/services/file/server.ts +25 -3
  268. package/src/services/file/type.ts +7 -4
  269. package/src/services/knowledgeBase.ts +34 -0
  270. package/src/services/message/client.test.ts +1 -1
  271. package/src/services/message/client.ts +29 -3
  272. package/src/services/message/index.ts +0 -2
  273. package/src/services/message/server.ts +9 -3
  274. package/src/services/message/type.ts +1 -13
  275. package/src/services/rag.ts +29 -0
  276. package/src/services/session/server.ts +1 -1
  277. package/src/services/upload.ts +89 -84
  278. package/src/services/upload_legacy.ts +104 -0
  279. package/src/services/user/client.ts +7 -2
  280. package/src/services/user/server.ts +6 -2
  281. package/src/services/user/type.ts +3 -2
  282. package/src/store/agent/slices/chat/action.ts +90 -18
  283. package/src/store/agent/slices/chat/initialState.ts +1 -0
  284. package/src/store/agent/slices/chat/selectors.ts +58 -0
  285. package/src/store/chat/slices/builtinTool/action.test.ts +2 -2
  286. package/src/store/chat/slices/builtinTool/action.ts +2 -2
  287. package/src/store/chat/slices/message/action.test.ts +2 -1
  288. package/src/store/chat/slices/message/action.ts +102 -26
  289. package/src/store/chat/slices/message/actions/rag.ts +148 -0
  290. package/src/store/chat/slices/message/initialState.ts +7 -0
  291. package/src/store/chat/slices/message/reducer.ts +6 -2
  292. package/src/store/chat/slices/message/selectors.ts +38 -3
  293. package/src/store/chat/slices/plugin/action.ts +8 -2
  294. package/src/store/chat/slices/portal/action.ts +8 -0
  295. package/src/store/chat/slices/portal/initialState.ts +3 -0
  296. package/src/store/chat/slices/portal/selectors.ts +8 -2
  297. package/src/store/file/initialState.ts +5 -1
  298. package/src/store/file/reducers/uploadFileList.ts +133 -0
  299. package/src/store/file/selectors.ts +3 -0
  300. package/src/store/file/slices/chat/action.test.ts +90 -90
  301. package/src/store/file/slices/chat/action.ts +164 -109
  302. package/src/store/file/slices/chat/initialState.ts +7 -2
  303. package/src/store/file/slices/chat/selectors.test.ts +84 -61
  304. package/src/store/file/slices/chat/selectors.ts +22 -32
  305. package/src/store/file/slices/chunk/action.ts +36 -0
  306. package/src/store/file/slices/chunk/index.ts +3 -0
  307. package/src/store/file/slices/chunk/initialState.ts +15 -0
  308. package/src/store/file/slices/chunk/selectors.ts +10 -0
  309. package/src/store/file/slices/fileManager/action.ts +187 -0
  310. package/src/store/file/slices/fileManager/index.ts +3 -0
  311. package/src/store/file/slices/fileManager/initialState.ts +18 -0
  312. package/src/store/file/slices/fileManager/selectors.ts +58 -0
  313. package/src/store/file/slices/tts/action.test.ts +1 -1
  314. package/src/store/file/slices/tts/action.ts +2 -2
  315. package/src/store/file/slices/upload/action.ts +164 -0
  316. package/src/store/file/store.ts +12 -1
  317. package/src/store/knowledgeBase/index.ts +2 -0
  318. package/src/store/knowledgeBase/initialState.ts +7 -0
  319. package/src/store/knowledgeBase/selectors.ts +1 -0
  320. package/src/store/knowledgeBase/slices/content/action.ts +27 -0
  321. package/src/store/knowledgeBase/slices/content/index.ts +1 -0
  322. package/src/store/knowledgeBase/slices/crud/action.ts +78 -0
  323. package/src/store/knowledgeBase/slices/crud/index.ts +3 -0
  324. package/src/store/knowledgeBase/slices/crud/initialState.ts +12 -0
  325. package/src/store/knowledgeBase/slices/crud/selectors.ts +7 -0
  326. package/src/store/knowledgeBase/store.ts +30 -0
  327. package/src/store/serverConfig/selectors.test.ts +1 -1
  328. package/src/store/user/slices/preference/selectors.ts +8 -0
  329. package/src/store/user/slices/settings/selectors/systemAgent.ts +2 -0
  330. package/src/tools/dalle/Render/Item/ImageFileItem.tsx +3 -23
  331. package/src/types/agent/index.ts +9 -0
  332. package/src/types/asyncTask.ts +31 -0
  333. package/src/types/chunk/document.ts +9 -0
  334. package/src/types/chunk/index.ts +52 -0
  335. package/src/types/files/index.ts +35 -0
  336. package/src/types/files/list.ts +44 -0
  337. package/src/types/files/upload.ts +91 -0
  338. package/src/types/knowledgeBase/index.ts +45 -0
  339. package/src/types/message/index.ts +54 -5
  340. package/src/types/rag.ts +16 -0
  341. package/src/utils/filter.test.ts +2 -0
  342. package/src/utils/server/auth.ts +23 -0
  343. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/LocalFiles.tsx +0 -46
  344. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/Files.tsx +0 -19
  345. package/src/components/FileList/EditableFileList.tsx +0 -47
  346. package/src/components/FileList/index.ts +0 -2
  347. package/src/components/FileList/type.tsx +0 -7
  348. package/src/database/server/schemas/lobechat/chat.ts +0 -331
  349. package/src/features/ChatInput/ActionBar/FileUpload.tsx +0 -69
  350. package/src/features/ChatInput/useChatInput.ts +0 -45
  351. package/src/features/FileList/EditableFileList.tsx +0 -31
  352. package/src/features/FileList/FileListPreviewer.tsx +0 -17
  353. package/src/features/FileList/index.tsx +0 -2
  354. package/src/types/files.ts +0 -42
@@ -0,0 +1,61 @@
1
+ import { createStyles } from 'antd-style';
2
+ import { memo, useMemo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
4
+
5
+ import { useFileStore } from '@/store/file';
6
+ import { FileChunk } from '@/types/chunk';
7
+
8
+ const useStyles = createStyles(({ css, token }) => ({
9
+ container: css`
10
+ padding-block: 12px;
11
+ padding-inline: 8px;
12
+ border-block-end: 1px dashed ${token.colorBorderSecondary};
13
+ border-radius: 4px;
14
+
15
+ &:hover {
16
+ background: ${token.colorFillTertiary};
17
+ }
18
+ `,
19
+ text: css`
20
+ font-size: 14px;
21
+ line-height: 24px;
22
+ `,
23
+ title: css`
24
+ font-size: 18px;
25
+ `,
26
+ }));
27
+
28
+ type ChunkItemProps = FileChunk;
29
+
30
+ const ChunkItem = memo<ChunkItemProps>(({ text, type, id }) => {
31
+ const { styles, cx } = useStyles();
32
+
33
+ const highlightChunks = useFileStore((s) => s.highlightChunks);
34
+
35
+ const typeClassName = useMemo(() => {
36
+ switch (type) {
37
+ default: {
38
+ return styles.text;
39
+ }
40
+ case 'Title': {
41
+ return styles.title;
42
+ }
43
+ }
44
+ }, [type]);
45
+
46
+ return (
47
+ <Flexbox
48
+ className={cx(styles.container, typeClassName)}
49
+ onMouseEnter={() => {
50
+ highlightChunks([id]);
51
+ }}
52
+ onMouseLeave={() => {
53
+ highlightChunks([]);
54
+ }}
55
+ >
56
+ {text}
57
+ </Flexbox>
58
+ );
59
+ });
60
+
61
+ export default ChunkItem;
@@ -0,0 +1,42 @@
1
+ import { memo } from 'react';
2
+ import { Flexbox } from 'react-layout-kit';
3
+ import { Virtuoso } from 'react-virtuoso';
4
+
5
+ import { lambdaQuery } from '@/libs/trpc/client';
6
+
7
+ import SkeletonLoading from '../Loading';
8
+ import ChunkItem from './ChunkItem';
9
+
10
+ interface ChunkListProps {
11
+ fileId: string;
12
+ }
13
+ const ChunkList = memo<ChunkListProps>(({ fileId }) => {
14
+ const { data, isLoading, fetchNextPage } = lambdaQuery.chunk.getChunksByFileId.useInfiniteQuery(
15
+ { id: fileId },
16
+ {
17
+ getNextPageParam: (lastPage) => lastPage.nextCursor,
18
+ },
19
+ );
20
+
21
+ const dataSource = data?.pages.flatMap((page) => page.items) || [];
22
+
23
+ return isLoading ? (
24
+ <SkeletonLoading />
25
+ ) : (
26
+ <Flexbox flex={1}>
27
+ <Virtuoso
28
+ data={dataSource}
29
+ endReached={() => {
30
+ fetchNextPage();
31
+ }}
32
+ itemContent={(index, item) => (
33
+ <Flexbox key={item.id} paddingInline={12}>
34
+ <ChunkItem {...item} index={index} />
35
+ </Flexbox>
36
+ )}
37
+ />
38
+ </Flexbox>
39
+ );
40
+ });
41
+
42
+ export default ChunkList;
@@ -0,0 +1,38 @@
1
+ import { SearchBar } from '@lobehub/ui';
2
+ import { memo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
4
+
5
+ import { useFileStore } from '@/store/file';
6
+ import { fileChunkSelectors } from '@/store/file/slices/chunk';
7
+
8
+ import ChunkList from './ChunkList';
9
+ import SimilaritySearchList from './SimilaritySearchList';
10
+
11
+ const Content = memo(() => {
12
+ const [fileId, showSimilaritySearch, semanticSearch] = useFileStore((s) => [
13
+ fileChunkSelectors.enabledChunkFileId(s),
14
+ fileChunkSelectors.showSimilaritySearchResult(s),
15
+ s.semanticSearch,
16
+ ]);
17
+
18
+ if (!fileId) return;
19
+
20
+ return (
21
+ <Flexbox gap={8} height={'100%'} paddingBlock={'16px 0'}>
22
+ <Flexbox paddingInline={12}>
23
+ <SearchBar
24
+ onChange={(text) => {
25
+ if (!text) useFileStore.setState({ isSimilaritySearch: false });
26
+ }}
27
+ onSearch={async (text) => {
28
+ useFileStore.setState({ isSimilaritySearch: !!text });
29
+ semanticSearch(text, fileId);
30
+ }}
31
+ />
32
+ </Flexbox>
33
+ {showSimilaritySearch ? <SimilaritySearchList /> : <ChunkList fileId={fileId} />}
34
+ </Flexbox>
35
+ );
36
+ });
37
+
38
+ export default Content;
@@ -0,0 +1,16 @@
1
+ import { Skeleton } from 'antd';
2
+ import { memo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
4
+
5
+ const SkeletonLoading = memo(() => (
6
+ <Flexbox padding={12}>
7
+ <Skeleton active paragraph={{ width: '70%' }} title={false} />
8
+ <Skeleton active paragraph={{ width: '40%' }} title={false} />
9
+ <Skeleton active paragraph={{ width: '80%' }} title={false} />
10
+ <Skeleton active paragraph={{ width: '30%' }} title={false} />
11
+ <Skeleton active paragraph={{ width: '50%' }} title={false} />
12
+ <Skeleton active paragraph={{ width: '70%' }} title={false} />
13
+ </Flexbox>
14
+ ));
15
+
16
+ export default SkeletonLoading;
@@ -0,0 +1,62 @@
1
+ import { Tag } from 'antd';
2
+ import { createStyles } from 'antd-style';
3
+ import { memo, useMemo } from 'react';
4
+ import { Flexbox } from 'react-layout-kit';
5
+
6
+ import { SemanticSearchChunk } from '@/types/chunk';
7
+
8
+ const useStyles = createStyles(({ css, token }) => ({
9
+ container: css`
10
+ padding-block: 12px;
11
+ padding-inline: 8px;
12
+ border-block-end: 1px solid ${token.colorBorderSecondary};
13
+ border-radius: 4px;
14
+
15
+ &:hover {
16
+ background: ${token.colorFillTertiary};
17
+ }
18
+ `,
19
+ pageNumber: css`
20
+ font-size: 12px;
21
+ color: ${token.colorTextDescription};
22
+ `,
23
+ text: css`
24
+ font-size: 14px;
25
+ line-height: 24px;
26
+ `,
27
+ title: css`
28
+ font-size: 18px;
29
+ `,
30
+ }));
31
+
32
+ interface ChunkItemProps extends Omit<SemanticSearchChunk, 'index'> {
33
+ index: number;
34
+ }
35
+
36
+ const SearchItem = memo<ChunkItemProps>(({ text, pageNumber, type, similarity }) => {
37
+ const { styles, cx } = useStyles();
38
+
39
+ const typeClassName = useMemo(() => {
40
+ switch (type) {
41
+ default: {
42
+ return styles.text;
43
+ }
44
+ case 'Title': {
45
+ return styles.title;
46
+ }
47
+ }
48
+ }, [type]);
49
+
50
+ return (
51
+ <Flexbox className={cx(styles.container, typeClassName)} gap={8}>
52
+ {text}
53
+
54
+ <Flexbox align={'center'} distribution={'space-between'} horizontal>
55
+ <Tag bordered={false}>{similarity.toFixed(2)}</Tag>
56
+ <Flexbox className={styles.pageNumber}>第 {pageNumber} 页</Flexbox>
57
+ </Flexbox>
58
+ </Flexbox>
59
+ );
60
+ });
61
+
62
+ export default SearchItem;
@@ -0,0 +1,31 @@
1
+ import isEqual from 'fast-deep-equal';
2
+ import { memo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
4
+ import { Virtuoso } from 'react-virtuoso';
5
+
6
+ import { useFileStore } from '@/store/file';
7
+
8
+ import SkeletonLoading from '../Loading';
9
+ import ChunkItem from './Item';
10
+
11
+ const SimilaritySearchList = memo(() => {
12
+ const isSimilaritySearching = useFileStore((s) => s.isSimilaritySearching);
13
+ const dataSource = useFileStore((s) => s.similaritySearchChunks, isEqual);
14
+
15
+ return isSimilaritySearching ? (
16
+ <SkeletonLoading />
17
+ ) : (
18
+ <Flexbox flex={1}>
19
+ <Virtuoso
20
+ data={dataSource}
21
+ itemContent={(index, item) => (
22
+ <Flexbox key={item.id} paddingInline={12}>
23
+ <ChunkItem {...item} index={index} />
24
+ </Flexbox>
25
+ )}
26
+ />
27
+ </Flexbox>
28
+ );
29
+ });
30
+
31
+ export default SimilaritySearchList;
@@ -0,0 +1,48 @@
1
+ import { Drawer } from 'antd';
2
+ import { useTheme } from 'antd-style';
3
+ import dynamic from 'next/dynamic';
4
+ import { memo } from 'react';
5
+ import { Flexbox } from 'react-layout-kit';
6
+
7
+ import { fileManagerSelectors, useFileStore } from '@/store/file';
8
+
9
+ import Content from './Content';
10
+
11
+ const FileViewer = dynamic(() => import('@/features/FileViewer'), { ssr: false });
12
+
13
+ const ChunkDrawer = memo(() => {
14
+ const [fileId, open, closeChunkDrawer] = useFileStore((s) => [
15
+ s.chunkDetailId,
16
+ !!s.chunkDetailId,
17
+ s.closeChunkDrawer,
18
+ ]);
19
+ const file = useFileStore(fileManagerSelectors.getFileById(fileId));
20
+
21
+ const theme = useTheme();
22
+ return (
23
+ <Drawer
24
+ onClose={() => {
25
+ closeChunkDrawer();
26
+ }}
27
+ open={open}
28
+ styles={{
29
+ body: { padding: 0 },
30
+ }}
31
+ title={file?.name}
32
+ width={'90%'}
33
+ >
34
+ <Flexbox height={'100%'} horizontal style={{ overflow: 'hidden' }}>
35
+ {file && (
36
+ <Flexbox flex={2} style={{ overflow: 'scroll' }}>
37
+ <FileViewer {...file} />
38
+ </Flexbox>
39
+ )}
40
+ <Flexbox flex={1} style={{ borderInlineStart: `1px solid ${theme.colorSplit}` }}>
41
+ <Content />
42
+ </Flexbox>
43
+ </Flexbox>
44
+ </Drawer>
45
+ );
46
+ });
47
+
48
+ export default ChunkDrawer;
@@ -0,0 +1,153 @@
1
+ import { FileTypeIcon, Icon } from '@lobehub/ui';
2
+ import { Typography, Upload } from 'antd';
3
+ import { createStyles, useTheme } from 'antd-style';
4
+ import { ArrowUpIcon, PlusIcon } from 'lucide-react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { Center, Flexbox } from 'react-layout-kit';
7
+
8
+ import { useCreateNewModal } from '@/features/KnowledgeBaseModal';
9
+ import { useFileStore } from '@/store/file';
10
+
11
+ const ICON_SIZE = 80;
12
+
13
+ const useStyles = createStyles(({ css, token }) => ({
14
+ actionTitle: css`
15
+ margin-block-start: 12px;
16
+ font-size: 16px;
17
+ color: ${token.colorTextSecondary};
18
+ `,
19
+ card: css`
20
+ cursor: pointer;
21
+
22
+ position: relative;
23
+
24
+ overflow: hidden;
25
+
26
+ width: 200px;
27
+ height: 140px;
28
+
29
+ font-weight: 500;
30
+ text-align: center;
31
+
32
+ background: ${token.colorFillTertiary};
33
+ border-radius: ${token.borderRadiusLG}px;
34
+ box-shadow: 0 0 0 1px ${token.colorFillTertiary} inset;
35
+
36
+ transition: background 0.3s ease-in-out;
37
+
38
+ &:hover {
39
+ background: ${token.colorFillSecondary};
40
+ }
41
+ `,
42
+ glow: css`
43
+ position: absolute;
44
+ inset-block-end: -12px;
45
+ inset-inline-end: 0;
46
+
47
+ width: 48px;
48
+ height: 48px;
49
+
50
+ opacity: 0.5;
51
+ filter: blur(24px);
52
+ `,
53
+ icon: css`
54
+ position: absolute;
55
+ z-index: 1;
56
+ inset-block-end: -24px;
57
+ inset-inline-end: 8px;
58
+
59
+ flex: none;
60
+ `,
61
+ }));
62
+
63
+ interface EmptyStatusProps {
64
+ knowledgeBaseId?: string;
65
+ showKnowledgeBase: boolean;
66
+ }
67
+ const EmptyStatus = ({ showKnowledgeBase, knowledgeBaseId }: EmptyStatusProps) => {
68
+ const { t } = useTranslation('components');
69
+ const theme = useTheme();
70
+ const { styles } = useStyles();
71
+
72
+ const pushDockFileList = useFileStore((s) => s.pushDockFileList);
73
+
74
+ const { open } = useCreateNewModal();
75
+
76
+ return (
77
+ <Center gap={24} height={'100%'} style={{ paddingBottom: 100 }} width={'100%'}>
78
+ <Flexbox justify={'center'} style={{ textAlign: 'center' }}>
79
+ <Typography.Title level={4}>{t('FileManager.emptyStatus.title')}</Typography.Title>
80
+ <Typography.Text type={'secondary'}>{t('FileManager.emptyStatus.or')}</Typography.Text>
81
+ </Flexbox>
82
+ <Flexbox gap={12} horizontal>
83
+ {showKnowledgeBase && (
84
+ <Flexbox
85
+ className={styles.card}
86
+ onClick={() => {
87
+ open();
88
+ }}
89
+ padding={16}
90
+ >
91
+ <span className={styles.actionTitle}>
92
+ {t('FileManager.emptyStatus.actions.knowledgeBase')}
93
+ </span>
94
+ <div className={styles.glow} style={{ background: theme.purple }} />
95
+ <FileTypeIcon
96
+ className={styles.icon}
97
+ color={theme.purple}
98
+ icon={<Icon color={'#fff'} icon={PlusIcon} />}
99
+ size={ICON_SIZE}
100
+ type={'folder'}
101
+ />
102
+ </Flexbox>
103
+ )}
104
+ <Upload
105
+ beforeUpload={async (_, fileList) => {
106
+ await pushDockFileList(Array.from(fileList), knowledgeBaseId);
107
+
108
+ return false;
109
+ }}
110
+ multiple={true}
111
+ showUploadList={false}
112
+ >
113
+ <Flexbox className={styles.card} padding={16}>
114
+ <span className={styles.actionTitle}>{t('FileManager.emptyStatus.actions.file')}</span>
115
+ <div className={styles.glow} style={{ background: theme.gold }} />
116
+ <FileTypeIcon
117
+ className={styles.icon}
118
+ color={theme.gold}
119
+ icon={<Icon color={'#fff'} icon={ArrowUpIcon} />}
120
+ size={ICON_SIZE}
121
+ />
122
+ </Flexbox>
123
+ </Upload>
124
+ <Upload
125
+ beforeUpload={async (_, fileList) => {
126
+ await pushDockFileList(Array.from(fileList), knowledgeBaseId);
127
+
128
+ return false;
129
+ }}
130
+ directory
131
+ multiple={true}
132
+ showUploadList={false}
133
+ >
134
+ <Flexbox className={styles.card} padding={16}>
135
+ <span className={styles.actionTitle}>
136
+ {t('FileManager.emptyStatus.actions.folder')}
137
+ </span>
138
+ <div className={styles.glow} style={{ background: theme.geekblue }} />
139
+ <FileTypeIcon
140
+ className={styles.icon}
141
+ color={theme.geekblue}
142
+ icon={<Icon color={'#fff'} icon={ArrowUpIcon} />}
143
+ size={ICON_SIZE}
144
+ type={'folder'}
145
+ />
146
+ </Flexbox>
147
+ </Upload>
148
+ </Flexbox>
149
+ </Center>
150
+ );
151
+ };
152
+
153
+ export default EmptyStatus;
@@ -0,0 +1,35 @@
1
+ import { memo } from 'react';
2
+
3
+ import FileParsingStatusTag from '@/components/FileParsingStatus';
4
+ import { fileManagerSelectors, useFileStore } from '@/store/file';
5
+ import { FileParsingTask } from '@/types/asyncTask';
6
+
7
+ interface ChunkTagProps extends FileParsingTask {
8
+ id: string;
9
+ }
10
+
11
+ const ChunksBadge = memo<ChunkTagProps>(({ id, ...res }) => {
12
+ const [isCreatingChunkEmbeddingTask, embeddingChunks, reParseFile, openChunkDrawer] =
13
+ useFileStore((s) => [
14
+ fileManagerSelectors.isCreatingChunkEmbeddingTask(id)(s),
15
+ s.embeddingChunks,
16
+ s.reParseFile,
17
+ s.openChunkDrawer,
18
+ ]);
19
+
20
+ return (
21
+ <FileParsingStatusTag
22
+ onClick={(status) => {
23
+ if (status === 'success') openChunkDrawer(id);
24
+ }}
25
+ onEmbeddingClick={() => embeddingChunks([id])}
26
+ onErrorClick={(task) => {
27
+ if (task === 'chunking') reParseFile(id);
28
+ }}
29
+ preparingEmbedding={isCreatingChunkEmbeddingTask}
30
+ {...res}
31
+ />
32
+ );
33
+ });
34
+
35
+ export default ChunksBadge;
@@ -0,0 +1,150 @@
1
+ import { ActionIcon, Icon, copyToClipboard } from '@lobehub/ui';
2
+ import { App, Dropdown } from 'antd';
3
+ import { ItemType } from 'antd/es/menu/interface';
4
+ import {
5
+ BookMinusIcon,
6
+ BookPlusIcon,
7
+ DownloadIcon,
8
+ LinkIcon,
9
+ MoreHorizontalIcon,
10
+ Trash,
11
+ } from 'lucide-react';
12
+ import { memo, useMemo } from 'react';
13
+ import { useTranslation } from 'react-i18next';
14
+
15
+ import { useAddFilesToKnowledgeBaseModal } from '@/features/KnowledgeBaseModal';
16
+ import { useFileStore } from '@/store/file';
17
+ import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
18
+ import { downloadFile } from '@/utils/downloadFile';
19
+
20
+ interface DropdownMenuProps {
21
+ filename: string;
22
+ id: string;
23
+ knowledgeBaseId?: string;
24
+ url: string;
25
+ }
26
+
27
+ const DropdownMenu = memo<DropdownMenuProps>(({ id, knowledgeBaseId, url, filename }) => {
28
+ const { t } = useTranslation(['components', 'common']);
29
+ const { message, modal } = App.useApp();
30
+
31
+ const [removeFile] = useFileStore((s) => [s.removeFileItem]);
32
+ const [removeFilesFromKnowledgeBase] = useKnowledgeBaseStore((s) => [
33
+ s.removeFilesFromKnowledgeBase,
34
+ ]);
35
+
36
+ const inKnowledgeBase = !!knowledgeBaseId;
37
+ const { open } = useAddFilesToKnowledgeBaseModal();
38
+
39
+ const items = useMemo(() => {
40
+ const knowledgeBaseActions = (
41
+ inKnowledgeBase
42
+ ? [
43
+ {
44
+ icon: <Icon icon={BookPlusIcon} />,
45
+ key: 'addToOtherKnowledgeBase',
46
+ label: t('FileManager.actions.addToOtherKnowledgeBase'),
47
+ onClick: async ({ domEvent }) => {
48
+ domEvent.stopPropagation();
49
+
50
+ open({ fileIds: [id], knowledgeBaseId });
51
+ },
52
+ },
53
+ {
54
+ icon: <Icon icon={BookMinusIcon} />,
55
+ key: 'removeFromKnowledgeBase',
56
+ label: t('FileManager.actions.removeFromKnowledgeBase'),
57
+ onClick: async ({ domEvent }) => {
58
+ domEvent.stopPropagation();
59
+
60
+ modal.confirm({
61
+ okButtonProps: {
62
+ danger: true,
63
+ },
64
+ onOk: async () => {
65
+ await removeFilesFromKnowledgeBase(knowledgeBaseId, [id]);
66
+
67
+ message.success(t('FileManager.actions.removeFromKnowledgeBaseSuccess'));
68
+ },
69
+ title: t('FileManager.actions.confirmRemoveFromKnowledgeBase', {
70
+ count: 1,
71
+ }),
72
+ });
73
+ },
74
+ },
75
+ ]
76
+ : [
77
+ {
78
+ icon: <Icon icon={BookPlusIcon} />,
79
+ key: 'addToKnowledgeBase',
80
+ label: t('FileManager.actions.addToKnowledgeBase'),
81
+ onClick: async ({ domEvent }) => {
82
+ domEvent.stopPropagation();
83
+ open({ fileIds: [id] });
84
+ },
85
+ },
86
+ ]
87
+ ) as ItemType[];
88
+
89
+ return (
90
+ [
91
+ ...knowledgeBaseActions,
92
+ {
93
+ type: 'divider',
94
+ },
95
+ {
96
+ icon: <Icon icon={LinkIcon} />,
97
+ key: 'copyUrl',
98
+ label: t('FileManager.actions.copyUrl'),
99
+ onClick: async ({ domEvent }) => {
100
+ domEvent.stopPropagation();
101
+ await copyToClipboard(url);
102
+ message.success(t('FileManager.actions.copyUrlSuccess'));
103
+ },
104
+ },
105
+ {
106
+ icon: <Icon icon={DownloadIcon} />,
107
+ key: 'download',
108
+ label: t('download', { ns: 'common' }),
109
+ onClick: async ({ domEvent }) => {
110
+ domEvent.stopPropagation();
111
+ const key = 'file-downloading';
112
+ message.loading({
113
+ content: t('FileManager.actions.downloading'),
114
+ duration: 0,
115
+ key,
116
+ });
117
+ await downloadFile(url, filename);
118
+ message.destroy(key);
119
+ },
120
+ },
121
+ {
122
+ type: 'divider',
123
+ },
124
+ {
125
+ danger: true,
126
+ icon: <Icon icon={Trash} />,
127
+ key: 'delete',
128
+ label: t('delete', { ns: 'common' }),
129
+ onClick: async ({ domEvent }) => {
130
+ domEvent.stopPropagation();
131
+ modal.confirm({
132
+ content: t('FileManager.actions.confirmDelete'),
133
+ okButtonProps: { danger: true },
134
+ onOk: async () => {
135
+ await removeFile(id);
136
+ },
137
+ });
138
+ },
139
+ },
140
+ ] as ItemType[]
141
+ ).filter(Boolean);
142
+ }, [inKnowledgeBase]);
143
+ return (
144
+ <Dropdown menu={{ items }}>
145
+ <ActionIcon icon={MoreHorizontalIcon} size={'small'} />
146
+ </Dropdown>
147
+ );
148
+ });
149
+
150
+ export default DropdownMenu;