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
feat:api Add support for extracting EPUB files in ExtractProcessor (#3254)
LiuVaayneb00466f025f4
diff --git a/api/core/rag/extractor/extract_processor.py b/api/core/rag/extractor/extract_processor.pyindex 0de70653352..8bb884c2dd5 100644--- a/api/core/rag/extractor/extract_processor.py+++ b/api/core/rag/extractor/extract_processor.py@@ -16,6 +16,7 @@ from core.rag.extractor.pdf_extractor import PdfExtractorfrom core.rag.extractor.text_extractor import TextExtractorfrom core.rag.extractor.unstructured.unstructured_doc_extractor import UnstructuredWordExtractorfrom core.rag.extractor.unstructured.unstructured_eml_extractor import UnstructuredEmailExtractor+from core.rag.extractor.unstructured.unstructured_epub_extractor import UnstructuredEpubExtractorfrom core.rag.extractor.unstructured.unstructured_markdown_extractor import UnstructuredMarkdownExtractorfrom core.rag.extractor.unstructured.unstructured_msg_extractor import UnstructuredMsgExtractorfrom core.rag.extractor.unstructured.unstructured_ppt_extractor import UnstructuredPPTExtractor@@ -106,6 +107,8 @@ class ExtractProcessor:extractor = UnstructuredPPTXExtractor(file_path, unstructured_api_url)elif file_extension == '.xml':extractor = UnstructuredXmlExtractor(file_path, unstructured_api_url)+ elif file_extension == 'epub':+ extractor = UnstructuredEpubExtractor(file_path, unstructured_api_url)else:# txtextractor = UnstructuredTextExtractor(file_path, unstructured_api_url) if is_automatic \@@ -123,6 +126,8 @@ class ExtractProcessor:extractor = WordExtractor(file_path)elif file_extension == '.csv':extractor = CSVExtractor(file_path, autodetect_encoding=True)+ elif file_extension == 'epub':+ extractor = UnstructuredEpubExtractor(file_path)else:# txtextractor = TextExtractor(file_path, autodetect_encoding=True)diff --git a/api/core/rag/extractor/unstructured/unstructured_epub_extractor.py b/api/core/rag/extractor/unstructured/unstructured_epub_extractor.pynew file mode 100644index 00000000000..44cf958ea2b--- /dev/null+++ b/api/core/rag/extractor/unstructured/unstructured_epub_extractor.py@@ -0,0 +1,37 @@+import logging++from core.rag.extractor.extractor_base import BaseExtractor+from core.rag.models.document import Document++logger = logging.getLogger(__name__)+++class UnstructuredEpubExtractor(BaseExtractor):+ """Load epub files.+++ Args:+ file_path: Path to the file to load.+ """++ def __init__(+ self,+ file_path: str,+ api_url: str = None,+ ):+ """Initialize with file path."""+ self._file_path = file_path+ self._api_url = api_url++ def extract(self) -> list[Document]:+ from unstructured.partition.epub import partition_epub++ elements = partition_epub(filename=self._file_path, xml_keep_tags=True)+ from unstructured.chunking.title import chunk_by_title+ chunks = chunk_by_title(elements, max_characters=2000, combine_text_under_n_chars=2000)+ documents = []+ for chunk in chunks:+ text = chunk.text.strip()+ documents.append(Document(page_content=text))++ return documentsdiff --git a/api/requirements.txt b/api/requirements.txtindex 19d8d4128f3..f9ff2ee60da 100644--- a/api/requirements.txt+++ b/api/requirements.txt@@ -65,7 +65,7 @@ qdrant-client==1.7.3cohere~=5.2.4pyyaml~=6.0.1numpy~=1.25.2-unstructured[docx,pptx,msg,md,ppt]~=0.10.27+unstructured[docx,pptx,msg,md,ppt,epub]~=0.10.27bs4~=0.0.1markdown~=3.5.1httpx[socks]~=0.24.1diff --git a/api/services/file_service.py b/api/services/file_service.pyindex 53dd090236a..39f31098ae4 100644--- a/api/services/file_service.py+++ b/api/services/file_service.py@@ -22,7 +22,7 @@ IMAGE_EXTENSIONS.extend([ext.upper() for ext in IMAGE_EXTENSIONS])ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx', 'docx', 'csv']UNSTRUSTURED_ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx',- 'docx', 'csv', 'eml', 'msg', 'pptx', 'ppt', 'xml']+ 'docx', 'csv', 'eml', 'msg', 'pptx', 'ppt', 'xml', 'epub']PREVIEW_WORDS_LIMIT = 3000