diff --git a/astrbot/core/knowledge_base/parsers/util.py b/astrbot/core/knowledge_base/parsers/util.py index 52cffa5cd..a98ed60ed 100644 --- a/astrbot/core/knowledge_base/parsers/util.py +++ b/astrbot/core/knowledge_base/parsers/util.py @@ -2,7 +2,7 @@ from .base import BaseParser async def select_parser(ext: str) -> BaseParser: - if ext in {".md", ".txt", ".markdown", ".xlsx", ".docx", ".xls"}: + if ext in {".md", ".txt", ".markdown", ".rst", ".adoc", ".xlsx", ".docx", ".xls"}: from .markitdown_parser import MarkitdownParser return MarkitdownParser() diff --git a/dashboard/src/i18n/locales/en-US/features/knowledge-base/detail.json b/dashboard/src/i18n/locales/en-US/features/knowledge-base/detail.json index a6c277db9..78a00669e 100644 --- a/dashboard/src/i18n/locales/en-US/features/knowledge-base/detail.json +++ b/dashboard/src/i18n/locales/en-US/features/knowledge-base/detail.json @@ -49,7 +49,7 @@ "title": "Upload Document", "selectFile": "Select File", "dropzone": "Drop files here or click to select", - "supportedFormats": "Supported formats: .txt, .md, .pdf, .docx, .epub, .xls, .xlsx", + "supportedFormats": "Supported formats: .txt, .md, .markdown, .rst, .adoc, .pdf, .docx, .epub, .xls, .xlsx", "maxSize": "Max file size: 128MB", "chunkSettings": "Chunk Settings", "batchSettings": "Batch Settings", diff --git a/dashboard/src/i18n/locales/ru-RU/features/knowledge-base/detail.json b/dashboard/src/i18n/locales/ru-RU/features/knowledge-base/detail.json index 328131bc3..5145d5c28 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/knowledge-base/detail.json +++ b/dashboard/src/i18n/locales/ru-RU/features/knowledge-base/detail.json @@ -49,7 +49,7 @@ "title": "Добавление контента", "selectFile": "Файл", "dropzone": "Нажмите или перетащите файл сюда", - "supportedFormats": "Форматы: .txt, .md, .pdf, .docx, .epub, .xls, .xlsx", + "supportedFormats": "Форматы: .txt, .md, .markdown, .rst, .adoc, .pdf, .docx, .epub, .xls, .xlsx", "maxSize": "Максимум: 128MB", "chunkSettings": "Фрагментация", "batchSettings": "Пакетная обработка", diff --git a/dashboard/src/i18n/locales/zh-CN/features/knowledge-base/detail.json b/dashboard/src/i18n/locales/zh-CN/features/knowledge-base/detail.json index af38f4509..54bc60b7a 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/knowledge-base/detail.json +++ b/dashboard/src/i18n/locales/zh-CN/features/knowledge-base/detail.json @@ -49,7 +49,7 @@ "title": "上传文档", "selectFile": "选择文件", "dropzone": "拖放文件到这里或点击选择", - "supportedFormats": "支持的格式: .txt, .md, .pdf, .docx, .epub, .xls, .xlsx", + "supportedFormats": "支持的格式: .txt, .md, .markdown, .rst, .adoc, .pdf, .docx, .epub, .xls, .xlsx", "maxSize": "最大文件大小: 128MB", "chunkSettings": "分块设置", "batchSettings": "批处理设置", diff --git a/dashboard/src/views/knowledge-base/components/DocumentsTab.vue b/dashboard/src/views/knowledge-base/components/DocumentsTab.vue index 9d432878e..5bff7cd71 100644 --- a/dashboard/src/views/knowledge-base/components/DocumentsTab.vue +++ b/dashboard/src/views/knowledge-base/components/DocumentsTab.vue @@ -85,7 +85,7 @@

{{ t('upload.supportedFormats') }}

{{ t('upload.maxSize') }}

最多可上传 10 个文件

- @@ -709,6 +709,7 @@ const getFileIcon = (fileType: string) => { const type = fileType?.toLowerCase() || '' if (type.includes('pdf')) return 'mdi-file-pdf-box' if (type.includes('epub')) return 'mdi-book-open-page-variant' + if (type.includes('rst') || type.includes('adoc')) return 'mdi-file-document-outline' if (type.includes('md') || type.includes('markdown')) return 'mdi-language-markdown' if (type.includes('txt')) return 'mdi-file-document-outline' if (type.includes('url')) return 'mdi-link-variant' @@ -719,6 +720,7 @@ const getFileColor = (fileType: string) => { const type = fileType?.toLowerCase() || '' if (type.includes('pdf')) return 'error' if (type.includes('epub')) return 'warning' + if (type.includes('rst') || type.includes('adoc')) return 'success' if (type.includes('md')) return 'info' if (type.includes('txt')) return 'success' if (type.includes('url')) return 'primary' diff --git a/tests/test_epub_parser.py b/tests/test_epub_parser.py index a53f89f36..b5e4aa066 100644 --- a/tests/test_epub_parser.py +++ b/tests/test_epub_parser.py @@ -6,6 +6,7 @@ import zipfile import pytest from astrbot.core.knowledge_base.parsers.epub_parser import EpubParser +from astrbot.core.knowledge_base.parsers.markitdown_parser import MarkitdownParser from astrbot.core.knowledge_base.parsers.util import select_parser @@ -174,6 +175,14 @@ async def test_select_parser_supports_epub(): assert isinstance(parser, EpubParser) +@pytest.mark.asyncio +@pytest.mark.parametrize("ext", [".rst", ".adoc"]) +async def test_select_parser_supports_text_markup_formats(ext): + parser = await select_parser(ext) + + assert isinstance(parser, MarkitdownParser) + + @pytest.mark.asyncio async def test_epub_parser_reads_spine_order_as_text(): result = await EpubParser().parse(_make_epub_bytes(), "book.epub")