From 6d9013f0a1a9f426cfb1f5914dc990c357e7db17 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Tue, 31 Dec 2024 00:11:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9F=A5=E8=AF=86=E5=BA=93=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=90=91=E9=87=8F=E5=8C=96=20MD=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=20#569?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...oader-markdown-npm-0.1.25-d1d536d640.patch | 19 +++++++++++++++++++ package.json | 2 +- src/main/services/KnowledgeService.ts | 2 +- .../src/pages/knowledge/KnowledgeContent.tsx | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 .yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.25-d1d536d640.patch diff --git a/.yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.25-d1d536d640.patch b/.yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.25-d1d536d640.patch new file mode 100644 index 000000000..7e9bb041f --- /dev/null +++ b/.yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.25-d1d536d640.patch @@ -0,0 +1,19 @@ +diff --git a/src/markdown-loader.js b/src/markdown-loader.js +index 8a17cb7f5a68d90d2be21682db6e95ce22a3e71c..9ee868ef9d4ff3dc914b3abc3c8006deb1e9c6c6 100644 +--- a/src/markdown-loader.js ++++ b/src/markdown-loader.js +@@ -1,5 +1,4 @@ + import { micromark } from 'micromark'; +-import { mdxJsx } from 'micromark-extension-mdx-jsx'; + import { gfmHtml, gfm } from 'micromark-extension-gfm'; + import createDebugMessages from 'debug'; + import fs from 'node:fs'; +@@ -21,7 +20,7 @@ export class MarkdownLoader extends BaseLoader { + ? (await getSafe(this.filePathOrUrl, { format: 'buffer' })).body + : await stream2buffer(fs.createReadStream(this.filePathOrUrl)); + this.debug('MarkdownLoader stream created'); +- const result = micromark(buffer, { extensions: [gfm(), mdxJsx()], htmlExtensions: [gfmHtml()] }); ++ const result = micromark(buffer, { extensions: [gfm()], htmlExtensions: [gfmHtml()] }); + this.debug('Markdown parsed...'); + const webLoader = new WebLoader({ + urlOrContent: result, diff --git a/package.json b/package.json index 11967d32a..d7b9ced57 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@llm-tools/embedjs": "patch:@llm-tools/embedjs@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-npm-0.1.25-ec5645cf36.patch", "@llm-tools/embedjs-libsql": "patch:@llm-tools/embedjs-libsql@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-libsql-npm-0.1.25-fad000d74c.patch", "@llm-tools/embedjs-loader-csv": "^0.1.25", - "@llm-tools/embedjs-loader-markdown": "^0.1.25", + "@llm-tools/embedjs-loader-markdown": "patch:@llm-tools/embedjs-loader-markdown@npm%3A0.1.25#~/.yarn/patches/@llm-tools-embedjs-loader-markdown-npm-0.1.25-d1d536d640.patch", "@llm-tools/embedjs-loader-msoffice": "^0.1.25", "@llm-tools/embedjs-loader-pdf": "^0.1.25", "@llm-tools/embedjs-loader-sitemap": "^0.1.25", diff --git a/src/main/services/KnowledgeService.ts b/src/main/services/KnowledgeService.ts index 2ca38a3ae..b8af2e74b 100644 --- a/src/main/services/KnowledgeService.ts +++ b/src/main/services/KnowledgeService.ts @@ -122,7 +122,7 @@ class KnowledgeService { return await ragApplication.addLoader(new ExcelLoader({ filePathOrUrl: file.path }) as any, forceReload) } - if (['.md', '.mdx'].includes(file.ext)) { + if (['.md'].includes(file.ext)) { return await ragApplication.addLoader(new MarkdownLoader({ filePathOrUrl: file.path }) as any, forceReload) } diff --git a/src/renderer/src/pages/knowledge/KnowledgeContent.tsx b/src/renderer/src/pages/knowledge/KnowledgeContent.tsx index ac7c94c33..43364d7ae 100644 --- a/src/renderer/src/pages/knowledge/KnowledgeContent.tsx +++ b/src/renderer/src/pages/knowledge/KnowledgeContent.tsx @@ -29,7 +29,7 @@ interface KnowledgeContentProps { selectedBase: KnowledgeBase } -const fileTypes = ['.pdf', '.docx', '.pptx', '.xlsx', '.txt', '.md', '.mdx'] +const fileTypes = ['.pdf', '.docx', '.pptx', '.xlsx', '.txt', '.md'] const FlexColumn = styled.div` display: flex;