Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
add doc support in knowledge base for unstructured (#17352)
Jyong6104b91d3ff7
diff --git a/api/core/rag/extractor/extract_processor.py b/api/core/rag/extractor/extract_processor.pyindex f9fd7f92a12..e80d0f0bbe6 100644--- a/api/core/rag/extractor/extract_processor.py+++ b/api/core/rag/extractor/extract_processor.py@@ -18,6 +18,7 @@ from core.rag.extractor.markdown_extractor import MarkdownExtractorfrom core.rag.extractor.notion_extractor import NotionExtractorfrom core.rag.extractor.pdf_extractor import PdfExtractorfrom core.rag.extractor.text_extractor import TextExtractor+from core.rag.extractor.unstructured.unstructured_doc_extractor import UnstructuredWordExtractorfrom core.rag.extractor.unstructured.unstructured_eml_extractor import UnstructuredEmailExtractorfrom core.rag.extractor.unstructured.unstructured_epub_extractor import UnstructuredEpubExtractorfrom core.rag.extractor.unstructured.unstructured_markdown_extractor import UnstructuredMarkdownExtractor@@ -104,7 +105,7 @@ class ExtractProcessor:etl_type = dify_config.ETL_TYPEextractor: Optional[BaseExtractor] = Noneif etl_type == "Unstructured":- unstructured_api_url = dify_config.UNSTRUCTURED_API_URL+ unstructured_api_url = dify_config.UNSTRUCTURED_API_URL or ""unstructured_api_key = dify_config.UNSTRUCTURED_API_KEY or ""if file_extension in {".xlsx", ".xls"}:@@ -121,6 +122,8 @@ class ExtractProcessor:extractor = HtmlExtractor(file_path)elif file_extension == ".docx":extractor = WordExtractor(file_path, upload_file.tenant_id, upload_file.created_by)+ elif file_extension == ".doc":+ extractor = UnstructuredWordExtractor(file_path, unstructured_api_url, unstructured_api_key)elif file_extension == ".csv":extractor = CSVExtractor(file_path, autodetect_encoding=True)elif file_extension == ".msg":diff --git a/api/core/rag/extractor/unstructured/unstructured_doc_extractor.py b/api/core/rag/extractor/unstructured/unstructured_doc_extractor.pyindex a525c9e9e3c..5199208f705 100644--- a/api/core/rag/extractor/unstructured/unstructured_doc_extractor.py+++ b/api/core/rag/extractor/unstructured/unstructured_doc_extractor.py@@ -10,14 +10,11 @@ logger = logging.getLogger(__name__)class UnstructuredWordExtractor(BaseExtractor):"""Loader that uses unstructured to load word documents."""- def __init__(- self,- file_path: str,- api_url: str,- ):+ def __init__(self, file_path: str, api_url: str, api_key: str = ""):"""Initialize with file path."""self._file_path = file_pathself._api_url = api_url+ self._api_key = api_keydef extract(self) -> list[Document]:from unstructured.__version__ import __version__ as __unstructured_version__@@ -41,9 +38,10 @@ class UnstructuredWordExtractor(BaseExtractor):)if is_doc:- from unstructured.partition.doc import partition_doc+ from unstructured.partition.api import partition_via_api++ elements = partition_via_api(filename=self._file_path, api_url=self._api_url, api_key=self._api_key)- elements = partition_doc(filename=self._file_path)else:from unstructured.partition.docx import partition_docx