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: add YAML type in document extractor node (#9997)
zhuhao00958960510a
diff --git a/api/core/workflow/nodes/document_extractor/node.py b/api/core/workflow/nodes/document_extractor/node.pyindex 9e09b6d29ae..c2f51ad1e5e 100644--- a/api/core/workflow/nodes/document_extractor/node.py+++ b/api/core/workflow/nodes/document_extractor/node.py@@ -5,6 +5,7 @@ import jsonimport docximport pandas as pdimport pypdfium2+import yamlfrom unstructured.partition.email import partition_emailfrom unstructured.partition.epub import partition_epubfrom unstructured.partition.msg import partition_msg@@ -101,6 +102,8 @@ def _extract_text_by_mime_type(*, file_content: bytes, mime_type: str) -> str:return _extract_text_from_msg(file_content)case "application/json":return _extract_text_from_json(file_content)+ case "application/x-yaml" | "text/yaml":+ return _extract_text_from_yaml(file_content)case _:raise UnsupportedFileTypeError(f"Unsupported MIME type: {mime_type}")@@ -112,6 +115,8 @@ def _extract_text_by_file_extension(*, file_content: bytes, file_extension: str)return _extract_text_from_plain_text(file_content)case ".json":return _extract_text_from_json(file_content)+ case ".yaml" | ".yml":+ return _extract_text_from_yaml(file_content)case ".pdf":return _extract_text_from_pdf(file_content)case ".doc" | ".docx":@@ -149,6 +154,15 @@ def _extract_text_from_json(file_content: bytes) -> str:raise TextExtractionError(f"Failed to decode or parse JSON file: {e}") from e+def _extract_text_from_yaml(file_content: bytes) -> str:+ """Extract the content from yaml file"""+ try:+ yaml_data = yaml.safe_load_all(file_content.decode("utf-8"))+ return yaml.dump_all(yaml_data, allow_unicode=True, sort_keys=False)+ except (UnicodeDecodeError, yaml.YAMLError) as e:+ raise TextExtractionError(f"Failed to decode or parse YAML file: {e}") from e++def _extract_text_from_pdf(file_content: bytes) -> str:try:pdf_file = io.BytesIO(file_content)