Multimodal Cascade Text Extraction
多阶段文本抽取流水线,具备质量驱动的回退、自适应预处理和逐片段错误恢复能力。
按格式选择提取器从单个文件提取文本;PDF 逐页读取,文本层质量足够时直接采用,其余页面用 Tesseract OCR 识别。并附加质量评分和语言检测。
按 MIME 类型选择主抽取器,对抽取质量打分;当主结果为空或无法阅读时,升级到次级引擎。它会生成丰富的元数据,下游分类器无需重新读取源文件即可判断置信度和语言。
各格式的主抽取器:
- PDF: 逐页处理,优先使用文本层。带有良好内嵌文本层的页面直接采信;没有文本层的页面则用 Tesseract(LSTM)逐页 OCR。页面通过 PyMuPDF 以灰度方式逐页栅格化,因此无论文档多长,峰值内存都有上限(不会对整个文档做栅格化)。
- DOCX / XLSX / PPTX: 使用 python-docx / openpyxl / python-pptx,并保留结构(标题、表格转为 markdown、演讲者备注)。
- HTML / XHTML: 使用 trafilatura,清除样板内容并采集元数据。
- 图片: 使用 Tesseract(LSTM);当首轮得分较低时,按升级条件应用预处理(自动对比度、基于投影轮廓的纠偏、Otsu 二值化)。
- 纯文本 / CSV / JSON / XML: 直接解码,并自动嗅探字符集。
OCR 质量(逐页): OCR 通过 image_to_data 运行,以获取逐词置信度。当某页的平均置信度或质量得分偏低时,仅对该页以更高 DPI 重新渲染并预处理,保留置信度更高的那一轮;升级是逐页进行的,因此内存占用保持平稳。可通过 ocr_* 配置项调节。
质量评分:
- 字符分布的香农熵用于检测均匀噪声。
- 字母数字占比用于剔除以符号或孤立字形为主的 OCR 输出。
- 句子密度启发式(每句 token 数、平均词长)用于识别能通过字符级检查但实际乱码的段落。
- 汇总得分取值
[0, 1];低于0.5时自动触发回退路径,并记录在metadata.fallback_reason中。
运行特性:
- 逐片段错误恢复: 页面、工作表或幻灯片的失败会被隔离:文件其余部分继续处理,失败片段记录在元数据中,而不会中止整个抽取。
- 语言检测: 对最终文本运行 langdetect 并填充
metadata.language,便于下游路由和本地化分类。 - 部分结果端口: 当汇总质量得分低于 HITL 阈值时,worker 触发
partial端口,使工作流可以转交审阅人,而不是静默接受低质量的抽取结果。 - 单文件范围: 每次调用处理一个文件。批量输入请在上游组合
ai.email.parse或ai.archive.decompress与flow.split。
输出增强:
quality_score:取值[0, 1]的汇总得分。metadata.language:从最终文本检测出的 ISO 639-1 代码。metadata.fallback_reason:绕过主抽取器的原因(empty_text_layer、low_quality、not_supported)。metadata.segment_quality:逐页/逐工作表/逐幻灯片的质量数组。metadata.extractor_chain:实际调用的引擎有序列表。
工作原理
- 从节点配置读取
content_base64、file_path、source_url、name、content_type和download_timeout_ms,缺失时回退到上游载荷。优先级:content_base64,其次file_path,最后source_url。 - 仅有
source_url时,以流式 GET 下载到临时目录(文件名取name,否则随机),超时为download_timeout_ms(默认 120000)。节点结束时删除该目录。 - 检测 MIME 类型:优先使用
content_type,否则依据文件字节,再依据扩展名。路由到对应提取器:PDF、图片(PNG、JPEG、TIFF、BMP、WEBP)、DOCX、XLSX、PPTX、HTML;text/*及未知类型按纯文本处理。 - PDF:逐页处理,文本层至少有 20 个非空白字符且质量分不低于
ocr_page_quality_threshold时直接采用;否则以ocr_dpi渲染该页并执行 OCR。ocr_preprocess: "auto"时,若某页平均词置信度低于ocr_conf_threshold(或质量低于 0.5),则以ocr_max_dpi重新渲染并做纠偏和二值化,保留较好的一次结果。每页以--- PAGE <n> ---开头。 - 图片使用相同的升级规则进行 OCR(不重新渲染)。Office、HTML 和纯文本使用各自的读取器。
- 对最终文本打分(0–1,依据字符熵、字母数字占比和标点密度)写入
quality_score,文本不少于 20 个字符时基于前 2000 个字符检测语言。 - 文本为空时从
empty输出;metadata.fallback_reason有值且quality_score低于 0.5 时从partial输出;否则从extracted输出。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-ocr-attachment",
"label": "OCR attachment",
"operator_slug": "ai.multimodal.extract.text.cascade-pipeline",
"operator_version": "1.0.0",
"config": {
"source_url": "{{ $json.download_url }}",
"name": "{{ $json.name }}",
"ocr_lang": "spa+eng",
"ocr_dpi": 300,
"ocr_max_dpi": 400,
"ocr_preprocess": "auto",
"ocr_psm": 6,
"ocr_conf_threshold": 60,
"ocr_page_quality_threshold": 0.5,
"execution": {
"timeout_ms": 600000
}
}
}{
"ok": true,
"data": {
"text": "--- PAGE 1 ---\nResolution 118 of 2026",
"chars": 36,
"empty": false,
"method": "pdf_per_page_cascade",
"metadata": {
"pages": 1,
"pages_text_layer": 1,
"pages_ocred": 0,
"pages_failed": 0,
"segment_quality": [
{
"page": 1,
"source": "text_layer",
"score": 0.902,
"mean_conf": null,
"dpi_used": null
}
],
"fallback_reason": null,
"ocr_language": "spa+eng",
"language": "en",
"language_confidence": 0.998
},
"quality_score": 0.902
},
"port": "extracted"
}配置
-
ocr_langstring 可选 -
OCR 页面使用的 Tesseract 语言(例如“spa”“eng”“spa+eng”)。也作为语言检测的先验。
-
ocr_dpiinteger 可选 -
需要 OCR 的页面的基础渲染 DPI。
-
ocr_max_dpiinteger 可选 -
升级时重新渲染单个低置信度页面所用的 DPI(上限 450)。
-
ocr_preprocessstring 可选 -
none = 不做预处理;auto = 仅对低置信度页面做纠偏 + Otsu(推荐);always = 对每个 OCR 页面都做预处理。
-
ocr_psminteger 可选 -
页面分割模式。6 = 单一均匀文本块(密集的单栏文本);多栏版面使用 3/4。
-
ocr_conf_thresholdnumber 可选 -
平均词置信度(0-100)低于此值时,该页会被升级处理(重新渲染 + 预处理)。
-
ocr_page_quality_thresholdnumber 可选 -
内嵌文本层需达到的逐页质量得分(0-1),达到后无需 OCR 即可采信。
-
languagestring 可选 -
已弃用,请使用 ocr_lang。保留以向后兼容。
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
content_base64, file_path, source_url, name, content_type, download_timeout_ms - 未在配置 schema 中声明(位于输入契约中),但会先从节点配置读取,再从上游载荷读取。
-
ocr_lang - Tesseract 语言代码,例如
spa、eng或spa+eng;缺失时回退到language,再回退到spa。语言检测器不会把它当作先验。 -
ocr_max_dpi - 上限为 450。升级处理时以
ocr_max_dpi与ocr_dpi中较大者渲染。 -
ocr_preprocess none:只做一次不预处理的 OCR。auto:仅对低置信度页面升级处理。always:对所有 OCR 页面预处理(不再做升级处理)。-
execution - 仅读取
execution.timeout_ms(缺省回退 300000 毫秒)。retryOnFail、maxTries、waitBetweenTries、continueOnFail和alwaysOutputData均被忽略。
输出端口
extracted 默认 已提取文本;若使用了 OCR,其质量不低于 0.5。
{
"text": "--- PAGE 1 ---\nResolution 118 of 2026\n\n--- PAGE 2 ---\nArticle 1. The board approves the budget.",
"chars": 92,
"empty": false,
"method": "pdf_per_page_cascade",
"metadata": {
"pages": 2,
"pages_text_layer": 1,
"pages_ocred": 1,
"pages_failed": 0,
"segment_quality": [
{
"page": 1,
"source": "text_layer",
"score": 0.912,
"mean_conf": null,
"dpi_used": null
},
{
"page": 2,
"source": "ocr",
"score": 0.871,
"mean_conf": 88.4,
"dpi_used": 300,
"escalated": false
}
],
"fallback_reason": "partial_ocr",
"ocr_language": "spa",
"language": "en",
"language_confidence": 0.999
},
"quality_score": 0.884
}partial 仅适用于至少有一页需要 OCR 的 PDF(fallback_reason 为 empty_text_layer 或 partial_ocr)且最终 quality_score 低于 0.5 的情况。图片和其他格式永远不会走此端口。
{
"text": "--- PAGE 1 ---\nRe5olut1on 1l8 ,, 2O26",
"chars": 36,
"empty": false,
"method": "pdf_per_page_cascade",
"metadata": {
"pages": 1,
"pages_text_layer": 0,
"pages_ocred": 1,
"pages_failed": 0,
"segment_quality": [
{
"page": 1,
"source": "ocr",
"score": 0.41,
"mean_conf": 42.7,
"dpi_used": 400,
"escalated": true
}
],
"fallback_reason": "empty_text_layer",
"ocr_language": "spa",
"language": "en",
"language_confidence": 0.71
},
"quality_score": 0.43
}empty 提取器未返回文本。对于 PDF,只有在页数为 0 时才会发生,因为每页都会添加 --- PAGE <n> --- 标记。
{
"text": "",
"chars": 0,
"empty": true,
"method": "image_ocr_tesseract",
"metadata": {
"language": "spa",
"mean_conf": 0,
"preprocessed": true
},
"quality_score": 0
}error 未提供任何来源、下载失败、文件无法读取或脚本失败。
{
"error": "Request failed with status code 404"
}在表达式中
后续节点可通过 $("Multimodal Cascade Text Extraction").item.json.<路径> 读取此节点输出中的内容(请把 Multimodal Cascade Text Extraction 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 extracted 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Multimodal Cascade Text Extraction").item.json.text | ||
$("Multimodal Cascade Text Extraction").item.json.chars | ||
$("Multimodal Cascade Text Extraction").item.json.empty | ||
$("Multimodal Cascade Text Extraction").item.json.method | ||
$("Multimodal Cascade Text Extraction").item.json.quality_score0-1 的质量评估。 | ||
$("Multimodal Cascade Text Extraction").item.json.metadata丰富的元数据:语言、页数/工作表/幻灯片、fallback_reason 等。 | ||
$("Multimodal Cascade Text Extraction").item.json.metadata.pages | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.pages_text_layer | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.pages_ocred | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.pages_failed | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.segment_quality | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.fallback_reason | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.ocr_language | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.language | — | |
$("Multimodal Cascade Text Extraction").item.json.metadata.language_confidence | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
One of `content_base64`, `file_path`, or `source_url` is required. | error | 配置和上游载荷中都没有任何来源。 |
Request failed with status code <status> | error | source_url 下载返回了非 2xx 状态或超时(timeout of <ms>ms exceeded)。此时 data 只有 error,没有 stderr。 |
Either content_base64 or file_path is required | error | 当只提供了 file_path 而主机上不存在该文件时由脚本抛出。 |
<parser exception message> | error | Python 解析器抛出异常(Office 文件损坏或图片无法读取;PDF 中失败的单页会以 source: "failed" 记录在 segment_quality 中)。该消息原样放入 data.error,脚本的 stderr 放入 data.stderr。 |
Python timed out after <timeout_ms>ms | error | 脚本超出了节点超时。请调大 execution.timeout_ms 或发送更小的文件。 |
Python stdout exceeded MAX_STDOUT_BYTES (52428800 bytes) | error | 结果(文本或 base64 文件)超过 50 MB 上限。请在上游拆分输入。 |
Python runtime not available (ENOENT) | error | 主机上没有 Python 解释器。若依赖安装失败,消息为 PythonRunner failed: <message>。两者都是主机问题,而非工作流问题。 |
输入契约
-
content_base64string 可选 -
以 base64 表示的原始字节。仅适合小文件,否则会让工作流信封膨胀。
-
file_pathstring 可选 -
该 worker 上的本地文件系统路径。适用于上游节点已将文件落盘的情况;由调用方负责清理。
-
source_urlstring 可选 -
以流式下载到该 worker 临时文件的 HTTPS URL。推荐用于由 Blob / CDN / S3 提供的大附件:工作流载荷中无需携带 base64,并能控制内存占用。流水线结束时会清理临时文件。
-
download_timeout_msnumber 可选 -
source_url 下载的超时时间(毫秒)。默认 120000(2 分钟)。
-
namestring 可选 -
文件名提示(下载时作为带扩展名的文件名保留)。
-
content_typestring 可选 -
手动指定 MIME 类型。
输出契约
-
textstring 可选 -
charsnumber 可选 -
emptyboolean 可选 -
methodstring 可选 -
quality_scorenumber 可选 -
0-1 的质量评估。
-
metadataobject 可选 -
丰富的元数据:语言、页数/工作表/幻灯片、fallback_reason 等。
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "ai.multimodal.extract.text.cascade-pipeline",
"name": "Multimodal Cascade Text Extraction",
"category": "ai",
"version": "1.0.0",
"description": "Multi-stage text extraction pipeline with quality-driven fallback, adaptive preprocessing, and per-segment error recovery.\n\n Selects a primary extractor by MIME type, scores the extraction quality, and escalates to secondary engines when the primary result is empty or unreadable. Produces rich metadata so downstream classifiers can reason about confidence and language without re-reading the source.\n\n **Primary extractors by format:**\n - **PDF:** Per-page, text-layer-first. Each page that carries a good embedded text layer is trusted as-is; pages without one are OCR'd individually with Tesseract (LSTM). Pages are rasterized one at a time in grayscale via PyMuPDF, so peak memory is bounded regardless of document length (no whole-document rasterization).\n - **DOCX / XLSX / PPTX:** python-docx / openpyxl / python-pptx with structural preservation (headings, tables as markdown, presenter notes).\n - **HTML / XHTML:** trafilatura with boilerplate removal and metadata harvesting.\n - **Images:** Tesseract (LSTM) with escalation-gated preprocessing (autocontrast, projection-profile deskew, Otsu binarization) applied when the first pass scores low.\n - **Plain text / CSV / JSON / XML:** direct decoding with charset sniffing.\n\n **OCR quality (per page):** OCR runs through `image_to_data` to capture per-word confidence. When a page's mean confidence or quality score is low, that single page is re-rendered at a higher DPI and preprocessed, and the higher-confidence pass is kept — escalation is per-page so memory stays flat. Tunable via the `ocr_*` config knobs.\n\n **Quality scoring:**\n - Shannon entropy of the character distribution detects uniform noise.\n - Alphanumeric ratio rejects OCR output dominated by symbols or isolated glyphs.\n - Sentence-density heuristic (tokens per sentence, average word length) catches garbled passages that pass char-level checks.\n - Aggregated score in `[0, 1]`; below `0.5` triggers the fallback path automatically and is reported as `metadata.fallback_reason`.\n\n **Operational features:**\n - **Per-segment error recovery:** Page, sheet, or slide failures are isolated — the rest of the file continues and failed segments are reported in metadata rather than aborting the whole extraction.\n - **Language detection:** langdetect runs on the final text and populates `metadata.language`, useful for downstream routing and localized classification.\n - **Partial results port:** When the aggregate quality score falls below the HITL threshold, the worker emits port `partial` so the workflow can route to a reviewer instead of silently accepting a low-quality extraction.\n - **Single-file scope:** Processes one file per invocation. Compose `ai.email.parse` or `ai.archive.decompress` upstream with `flow.split` for batch inputs.\n\n **Output enrichment:**\n - `quality_score`: aggregate score in `[0, 1]`.\n - `metadata.language`: ISO 639-1 code detected from the final text.\n - `metadata.fallback_reason`: why the primary extractor was bypassed (`empty_text_layer`, `low_quality`, `not_supported`).\n - `metadata.segment_quality`: per-page / per-sheet / per-slide quality array.\n - `metadata.extractor_chain`: ordered list of engines actually invoked.",
"capabilities": [
"multimodal",
"text-extraction",
"cascade",
"quality-scoring",
"language-detection",
"ocr-fallback",
"adaptive-preprocessing"
],
"config_schema": {
"type": "object",
"properties": {
"ocr_lang": {
"type": "string",
"title": "OCR Language",
"default": "spa",
"description": "Tesseract language for OCR pages (e.g. \"spa\", \"eng\", \"spa+eng\"). Also used as a prior for language detection."
},
"ocr_dpi": {
"type": "integer",
"title": "OCR DPI",
"default": 300,
"description": "Base render DPI for pages that require OCR."
},
"ocr_max_dpi": {
"type": "integer",
"title": "OCR Escalation DPI",
"default": 400,
"description": "DPI used to re-render a single low-confidence page during escalation (capped at 450)."
},
"ocr_preprocess": {
"type": "string",
"title": "OCR Preprocessing",
"default": "auto",
"enum": [
"none",
"auto",
"always"
],
"description": "none = no preprocessing; auto = deskew + Otsu only on low-confidence pages (recommended); always = preprocess every OCR page."
},
"ocr_psm": {
"type": "integer",
"title": "Tesseract PSM",
"default": 6,
"description": "Page-segmentation mode. 6 = single uniform block (dense single-column text); 3/4 for multi-column layouts."
},
"ocr_conf_threshold": {
"type": "number",
"title": "OCR Confidence Threshold",
"default": 60,
"description": "Mean word-confidence (0-100) below which a page is escalated (re-render + preprocess)."
},
"ocr_page_quality_threshold": {
"type": "number",
"title": "Text-Layer Quality Gate",
"default": 0.5,
"description": "Per-page quality score (0-1) the embedded text layer must reach to be trusted without OCR."
},
"language": {
"type": "string",
"title": "OCR Language (deprecated alias)",
"default": "spa",
"description": "Deprecated — use ocr_lang. Kept for backward compatibility."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"properties": {
"content_base64": {
"type": "string",
"description": "Raw bytes as base64. Suitable only for small files — bloats the workflow envelope."
},
"file_path": {
"type": "string",
"description": "Local filesystem path on this worker. For upstream nodes that already materialized a file to disk; caller owns cleanup."
},
"source_url": {
"type": "string",
"description": "HTTPS URL to stream-download into a temp file on this worker. Recommended for large attachments served from Blob / CDN / S3 — keeps the workflow payload free of base64 and bounds memory. The pipeline cleans up the temp file on exit."
},
"download_timeout_ms": {
"type": "number",
"description": "Timeout for the source_url download in milliseconds. Defaults to 120000 (2 min)."
},
"name": {
"type": "string",
"description": "Filename hint (preserved as the extension-bearing name when downloading)."
},
"content_type": {
"type": "string",
"description": "MIME override."
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"chars": {
"type": "number"
},
"empty": {
"type": "boolean"
},
"method": {
"type": "string"
},
"quality_score": {
"type": "number",
"description": "0-1 quality assessment."
},
"metadata": {
"type": "object",
"description": "Rich metadata: language, pages/sheets/slides, fallback_reason, etc."
}
}
},
"ports": [
{
"port_id": "extracted",
"label": "Extracted",
"is_default": true,
"supports_condition": true
},
{
"port_id": "partial",
"label": "Partial (low quality)",
"is_default": false,
"supports_condition": true,
"description": "Text extracted but quality is below threshold. Consider HITL."
},
{
"port_id": "empty",
"label": "Empty",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"tags": [
"ai",
"multimodal",
"cascade",
"super-node",
"advanced"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"ocr_lang": {
"type": "string",
"title": "OCR Language",
"default": "spa",
"description": "Tesseract language for OCR pages (e.g. \"spa\", \"eng\", \"spa+eng\"). Also used as a prior for language detection."
},
"ocr_dpi": {
"type": "integer",
"title": "OCR DPI",
"default": 300,
"description": "Base render DPI for pages that require OCR."
},
"ocr_max_dpi": {
"type": "integer",
"title": "OCR Escalation DPI",
"default": 400,
"description": "DPI used to re-render a single low-confidence page during escalation (capped at 450)."
},
"ocr_preprocess": {
"type": "string",
"title": "OCR Preprocessing",
"default": "auto",
"enum": [
"none",
"auto",
"always"
],
"description": "none = no preprocessing; auto = deskew + Otsu only on low-confidence pages (recommended); always = preprocess every OCR page."
},
"ocr_psm": {
"type": "integer",
"title": "Tesseract PSM",
"default": 6,
"description": "Page-segmentation mode. 6 = single uniform block (dense single-column text); 3/4 for multi-column layouts."
},
"ocr_conf_threshold": {
"type": "number",
"title": "OCR Confidence Threshold",
"default": 60,
"description": "Mean word-confidence (0-100) below which a page is escalated (re-render + preprocess)."
},
"ocr_page_quality_threshold": {
"type": "number",
"title": "Text-Layer Quality Gate",
"default": 0.5,
"description": "Per-page quality score (0-1) the embedded text layer must reach to be trusted without OCR."
},
"language": {
"type": "string",
"title": "OCR Language (deprecated alias)",
"default": "spa",
"description": "Deprecated — use ocr_lang. Kept for backward compatibility."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"properties": {
"content_base64": {
"type": "string",
"description": "Raw bytes as base64. Suitable only for small files — bloats the workflow envelope."
},
"file_path": {
"type": "string",
"description": "Local filesystem path on this worker. For upstream nodes that already materialized a file to disk; caller owns cleanup."
},
"source_url": {
"type": "string",
"description": "HTTPS URL to stream-download into a temp file on this worker. Recommended for large attachments served from Blob / CDN / S3 — keeps the workflow payload free of base64 and bounds memory. The pipeline cleans up the temp file on exit."
},
"download_timeout_ms": {
"type": "number",
"description": "Timeout for the source_url download in milliseconds. Defaults to 120000 (2 min)."
},
"name": {
"type": "string",
"description": "Filename hint (preserved as the extension-bearing name when downloading)."
},
"content_type": {
"type": "string",
"description": "MIME override."
}
}
}{
"type": "object",
"properties": {
"text": {
"type": "string"
},
"chars": {
"type": "number"
},
"empty": {
"type": "boolean"
},
"method": {
"type": "string"
},
"quality_score": {
"type": "number",
"description": "0-1 quality assessment."
},
"metadata": {
"type": "object",
"description": "Rich metadata: language, pages/sheets/slides, fallback_reason, etc."
}
}
}[
{
"port_id": "extracted",
"label": "Extracted",
"is_default": true,
"supports_condition": true
},
{
"port_id": "partial",
"label": "Partial (low quality)",
"is_default": false,
"supports_condition": true,
"description": "Text extracted but quality is below threshold. Consider HITL."
},
{
"port_id": "empty",
"label": "Empty",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 重试(
retryOnFail) - 否
- 能力
multimodaltext-extractioncascadequality-scoringlanguage-detectionocr-fallbackadaptive-preprocessing- 标签
aimultimodalcascadesuper-nodeadvanced
说明与限制
- 在子进程中运行 Python 脚本。某台 worker 主机上的首次运行会创建虚拟环境并安装脚本锁定的依赖(可能耗时数分钟,且不计入节点超时);之后的运行会复用该环境。
file_path必须指向运行该节点的编排器主机本地磁盘上的文件;它不是 URL,也不会从存储中下载。- 脚本会在
execution.timeout_ms到期后被终止;未设置该键时代码使用 300000 毫秒,而不是 schema 默认的 300000。 - 脚本返回的 JSON 上限为 50 MB(52428800 字节,可在主机上配置)。文件以 base64 传输,较大的输入或输出可能触及该上限。
source_url接受主机可访问的任意 URL,但不附带认证头,请使用预签名或公开链接。大文件请优先用它代替content_base64,以免 base64 进入工作流状态。- OCR 单线程逐页处理,长篇扫描 PDF 会较慢,请相应调大
execution.timeout_ms。测试运行时会向画布报告逐页进度。 - 对于图片,
metadata.language初始为 OCR 语言;当文本不少于 20 个字符时,会被检测到的语言替换。 - 旧版
.doc、.xls、.ppt以及任何无法识别的类型都会按 UTF-8 纯文本读取,通常得到乱码且quality_score较低。
已对照编排器代码核实 · 31e874b · 2026-11-26