document-workflows
它能做什么
这项技能展示如何把文档读取步骤连接成完整的工作流,用于批量处理文件。适合构建大批量处理发票、表单或其他文档系统的开发者。
适用场景
- ✓当你需要在一批次中处理大量文档的时候。
- ✓当你想通过分块为 AI 搜索系统准备文档的时候。
- ✓当你想把提取出的文档结果加载到数据库中的时候。
技能链接
https://github.com/andrewyng/context-hub/blob/main/content/landingai/skills/ade/document-workflows/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想处理我文件夹中的所有发票,并把总额导入我的数据库。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能提供了可直接套用的模式,将读取、提取和分类步骤结合起来,并包含错误处理和并行处理。智能体会先检查一份样本文档,然后再编写代码。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Document Workflows — ADE Pipeline Patterns
Overview
This skill provides reusable building blocks for composing LandingAI ADE
primitives (parse, extract, split) into production-ready document processing
pipelines. It complements the document-extraction skill:
| Concern | document-extraction |
document-workflows |
|---|---|---|
| Scope | ADE SDK API: parse, extract, split, grounding | End-to-end pipelines: batch, RAG, DB, classify-route |
| When | Need to call a single ADE operation | Need to compose operations into a workflow |
| Code | SDK method calls with parameters | Complete functions with error handling, parallelism |
| Deps | landingai-ade only |
+ workflow-specific libs (pandas, chromadb, etc.) |
Philosophy: Organize by workflow pattern (batch, RAG, DB insertion), not by document type. The same pattern applies whether documents are invoices, utility bills, or medical forms.
Step 0 (mandatory) — Pre-Flight Document Exploration {#pre-flight}
Run this before writing any pipeline code whenever working with documents whose internal structure has not already been inspected in this session.
Rule: never write section-detection, heading-matching, or text-search code without first running Tool 2 (diagnostic parse) on the sample document. Heading format is document-specific and cannot be inferred from the task description or document type alone — the only reliable way to know it is to look at the actual ADE output.
Common surprises: a paper's "Introduction" heading may appear as
1. Introduction(plain text, no#),## Introduction,INTRODUCTION(all-caps), or embedded inside a text chunk with body copy. Getting this wrong means a silent failure (zero chunks matched) that requires a full re-parse to debug.
Run Tool 1 (visual render) and Tool 2 (diagnostic parse) on 1–3 representative sample documents before writing any code. This takes under a minute and prevents debugging iterations that a pre-flight would have avoided.
Tool 1 — Visual page render
Render 1–2 pages as PNG and read them as visual context. No ADE credits used, but each PNG consumes context tokens. Use when layout is ambiguous or document origin is unknown (handwriting? scan? form?).
.venv/bin/python - << 'EOF'
import pymupdf
from pathlib import Path
from PIL import Image
pdf = Path('path/to/sample.pdf')
out_dir = Path('/tmp/ade_preflight'); out_dir.mkdir(exist_ok=True)
doc = pymupdf.open(pdf)
for pg in range(min(2, len(doc))): # first 2 pages only
pix = doc[pg].get_pixmap(matrix=pymupdf.Matrix(1.5, 1.5)) # 108 DPI
img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples)
out = out_dir / f"{pdf.stem}_page{pg + 1}.png"
img.save(out)
print(out)
doc.close()
EOF
Then read the saved PNGs. Immediately answers:
- Are headings bold text (→ ADE may output plain-text heading, not
# Heading) - Is the document handwritten or scanned? → Tesseract OCR needed, not PyMuPDF
- Single-column or two-column layout?
- Any noise: running headers, page numbers, watermarks, stamps?
Tool 2 — ADE diagnostic parse
Parses 1 sample and prints markdown structure + chunk inventory. Uses ADE credits — keep to 1–3 samples only, never the full corpus.
.venv/bin/python - << 'EOF'
import os
from pathlib import Path
from collections import Counter
from dotenv import load_dotenv
# Load API key: prefer existing env var, then .env file lookup
load_dotenv() # Load API key from .env. Add a path to the .env if needed.
from landingai_ade import LandingAIADE
client = LandingAIADE()
pr = client.parse(document=Path('path/to/sample.pdf'))
print("=== MARKDOWN (first 80 lines) ===")
for i, ln in enumerate(pr.markdown.splitlines()[:80], 1):
print(f"{i:3}: {ln}")
print("\n=== CHUNKS ===")
for ch in pr.chunks:
txt = (ch.markdown or '').replace('\n', ' ')[:70]
b = ch.grounding.box
print(f"p{ch.grounding.page} {ch.type:12} "
f"l={b.left:.2f} t={b.top:.2f} r={b.right:.2f} b={b.bottom:.2f} | {txt}")
print(f"\nPages: {pr.metadata.page_count} "
f"Chunks: {len(pr.chunks)} "
f"Types: {dict(Counter(ch.type for ch in pr.chunks))}")
EOF
Cost note: Save the parse result with
pr.model_dump()to a JSON file after the first run. Load it for later development instead of callingclient.parse()again. Only re-parse when the document set changes.
What to look for
|
常见问题
它需要先查看样本文档吗?
需要。该技能要求在编写章节或标题代码之前,先检查一份样本文档。
它提到了哪些数据库?
它提到了将结果加载到 Snowflake 等数据库中。
它与文档提取技能有什么不同?
文档提取技能涵盖单次服务调用,而本技能涵盖由多个步骤组成的完整流程。
详情
作者的原始描述
Use this skill for building end-to-end document processing workflows and pipelines using LandingAI ADE. Trigger when users need to: (1) Process batches of documents in parallel or async, (2) Build classify-then-extract pipelines for mixed document types, (3) Prepare parsed documents for RAG systems with chunking and vector DB ingestion, (4) Load extraction results into databases like Snowflake or export to CSV/DataFrames, (5) Visualize extraction results: draw bounding box overlays on pages, crop chunk images, or highlight/annotate specific words or phrases found in documents, (6) Build Stream
repo: andrewyng/context-hub
热度
- GitHub 星标
- 14k
- 排名
- #11272
- 许可证
- MIT
- 更新时间
- 2026/5/31
评论
- …
同一仓库的更多技能
get-api-docs
14k帮你的智能体在编写代码之前获取第三方 API 和库的最新文档,而不是依赖旧的记忆。
bloc-cubit
14k教你的智能体如何用 Bloc 或 Cubit 管理 Flutter 应用的状态,包括何时选择哪一个,以及便于测试的安全默认设置。
riverpod
14k教你的智能体如何用 Riverpod 管理 Flutter 应用的状态,涵盖 provider、异步数据和测试,并为每种情况提供合理的默认设置。
document-extraction
14k帮你的智能体读取 PDF、图片和电子表格,将其转换为干净的文本,并使用 LandingAI 的 ADE 服务提取发票总额等字段。