inputs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrepare Inputs for MTHDS methods
为MTHDS方法准备输入
Prepare input data for running MTHDS method bundles. This skill is the single entry point for all input preparation needs: extracting a placeholder template, generating synthetic test data, integrating user-provided files, or any combination.
为运行MTHDS方法包准备输入数据。本技能是所有输入准备需求的统一入口:提取占位符模板、生成合成测试数据、整合用户提供的文件,或以上任意组合。
Mode Selection
模式选择
See Mode Selection for general mode behavior.
Default: Automatic.
Input strategy detection heuristics (evaluated in order):
| Signal | Strategy |
|---|---|
| User provides file paths, folder paths, or mentions "my data" / "this file" / "use these images" / "here's my PDF" | User Data (or Mixed if some inputs remain unfilled) |
| User says "test data" / "generate inputs" / "synthesize" / "fake data" / "sample data" | Synthetic |
| User says "template" / "schema" / "placeholder" / "what inputs does it need?" | Template |
No clear signal (e.g., called after | Template, then offer to populate |
Interactive additions: Ask about:
- Which user files map to which inputs (when ambiguous)
- Domain/industry context for realistic synthetic data
- Whether to generate edge cases or happy-path data
- Specific values or constraints for certain fields
有关通用模式行为,请参阅模式选择。
默认值:自动模式。
输入策略检测规则(按顺序评估):
| 信号 | 策略 |
|---|---|
| 用户提供文件路径、文件夹路径,或提及“my data”/“this file”/“use these images”/“here's my PDF” | 用户数据(若部分输入未填充则为混合模式) |
| 用户说出“test data”/“generate inputs”/“synthesize”/“fake data”/“sample data” | 合成数据 |
| 用户说出“template”/“schema”/“placeholder”/“它需要哪些输入?” | 模板 |
无明确信号(例如,在 | 模板,随后提供填充选项 |
交互式补充:询问以下内容:
- 当匹配存在歧义时,用户文件与哪些输入对应
- 生成真实合成数据所需的领域/行业上下文
- 是否生成边缘案例或正常流程数据
- 特定字段的具体值或约束条件
Prerequisites
前置条件
See CLI Prerequisites
请参阅CLI前置条件
Process
流程
Step 1: Identify the Target Method
步骤1:确定目标方法
Determine the bundle and its output directory (). This is usually the directory containing (e.g., ).
.mthds<output_dir>bundle.mthdsmthds-wip/pipeline_01/The file is saved directly in this directory (next to ):
inputs.jsonbundle.mthds<output_dir>/inputs.json
If data files need to be generated or copied (images, PDFs, etc.), they go in a subdirectory:
<output_dir>/inputs/
The subdirectory is only created when there are actual data files to store. Paths to these files are referenced from within .
/inputsinputs.json确定包及其输出目录()。通常为包含的目录(例如)。
.mthds<output_dir>bundle.mthdsmthds-wip/pipeline_01/inputs.jsonbundle.mthds<output_dir>/inputs.json
若需要生成或复制数据文件(图片、PDF等),则保存至子目录:
<output_dir>/inputs/
仅当存在实际数据文件需要存储时,才会创建子目录。这些文件的路径会在中被引用。
/inputsinputs.jsonStep 2: Get Input Schema
步骤2:获取输入Schema
Extract the input template from the method:
bash
mthds-agent pipelex inputs <bundle.mthds> -L <bundle-dir>/ [--pipe specific_pipe]Output format:
json
{
"success": true,
"pipe_code": "process_document",
"inputs": {
"document": {
"concept": "native.Document",
"content": {"url": "url_value"}
},
"context": {
"concept": "native.Text",
"content": {"text": "text_value"}
}
}
}For error handling, see Error Handling Reference.
从方法中提取输入模板:
bash
mthds-agent pipelex inputs <bundle.mthds> -L <bundle-dir>/ [--pipe specific_pipe]输出格式:
json
{
"success": true,
"pipe_code": "process_document",
"inputs": {
"document": {
"concept": "native.Document",
"content": {"url": "url_value"}
},
"context": {
"concept": "native.Text",
"content": {"text": "text_value"}
}
}
}有关错误处理,请参阅错误处理参考。
Step 3: Choose Input Strategy
步骤3:选择输入策略
Based on the heuristics above and what the user has provided, follow the appropriate strategy:
- Template Strategy — placeholder JSON, no real data
- Synthetic Strategy — AI-generated realistic test data
- User Data Strategy — integrate user-provided files
- Mixed Strategy — user files + synthetic for the rest
Template Strategy
模板策略
The fastest path. Produces a placeholder that the user can fill in manually.
inputs.json- Take the object from Step 2's output
inputs - Save it to (next to
<output_dir>/inputs.json)bundle.mthds - Report the saved file path and show the template content
- Offer: "To populate this with realistic test data, re-run /inputs and ask for synthetic data. Or provide your own files."
最快的实现路径。生成占位符,供用户手动填充。
inputs.json- 提取步骤2输出中的对象
inputs - 将其保存至(与
<output_dir>/inputs.json同级)bundle.mthds - 报告保存的文件路径并展示模板内容
- 提供选项:“如需用真实测试数据填充,请重新运行/inputs并选择合成数据。或提供您自己的文件。”
Synthetic Strategy
合成数据策略
Generate realistic fake data tailored to the method's purpose.
生成符合方法用途的真实模拟数据。
Identify Input Types
识别输入类型
Parse the schema to identify what types of synthetic data are needed:
| Concept | Content Fields | Synthesis Method |
|---|---|---|
| | Generate realistic text matching the method context |
| | Generate appropriate numeric values |
| | Use |
| | Use document generation skills or Python |
| | Composite: text + optional images |
| | Composite: text + image list |
| | Generate structured JSON matching context |
| Custom structured | Per-field types | Recurse through structure fields |
List types ( or ): Generate multiple items. Variable lists typically need 2-5 items; fixed lists need exactly N items.
Type[]Type[N]解析Schema以确定所需的合成数据类型:
| 概念 | 内容字段 | 合成方法 |
|---|---|---|
| | 生成符合方法上下文的真实文本 |
| | 生成合适的数值 |
| | 使用 |
| | 使用文档生成技能或Python |
| | 复合类型:文本 + 可选图片 |
| | 复合类型:文本 + 图片列表 |
| | 生成符合上下文的结构化JSON |
| 自定义结构化类型 | 按字段类型 | 递归处理结构字段 |
列表类型 (或):生成多个条目。可变列表通常需要2-5个条目;固定列表需要恰好N个条目。
Type[]Type[N]Generate Text Content
生成文本内容
Create realistic text that matches the method's purpose:
- If the method processes invoices, generate invoice-like text
- If it analyzes reports, generate report-style content
- Match expected length (short prompts vs long documents)
创建符合方法用途的真实文本:
- 若方法处理发票,则生成发票样式的文本
- 若方法分析报告,则生成报告风格的内容
- 匹配预期长度(短提示 vs 长文档)
Generate Numeric Content
生成数值内容
Generate sensible values within expected ranges based on the method context.
根据方法上下文生成合理范围内的数值。
Generate Structured Concepts
生成结构化概念
Fill each field according to its type and description.
根据字段类型和描述填充每个字段。
Generate File Inputs
生成文件输入
When inputs require actual files (Image, Document), use the appropriate generation method. See Image Generation and Document Generation below.
Assemble and Save
组装并保存
Create the complete and save to (next to ). Any generated data files go in .
inputs.json<output_dir>/inputs.jsonbundle.mthds<output_dir>/inputs/创建完整的并保存至(与同级)。所有生成的数据文件保存至。
inputs.json<output_dir>/inputs.jsonbundle.mthds<output_dir>/inputs/User Data Strategy
用户数据策略
Integrate the user's own files into the method's input schema.
将用户自有文件整合到方法的输入Schema中。
Step A: Inventory User Files
步骤A:盘点用户文件
Collect all files the user has provided (explicit paths, folders, or files mentioned earlier in conversation). For each file, determine its type:
| Extension(s) | Detected Type | Maps To |
|---|---|---|
| PDF document | |
| Word document | |
| Spreadsheet | |
| Presentation | |
| JPEG image | |
| PNG image | |
| WebP image | |
| GIF image | |
| SVG image | |
| TIFF image | |
| BMP image | |
| Plain text | |
| Markdown text | |
| JSON data | |
| CSV data | |
| HTML | |
收集用户提供的所有文件(明确的路径、文件夹,或对话中提及的文件)。为每个文件确定其类型:
| 扩展名 | 检测类型 | 映射至 |
|---|---|---|
| PDF文档 | |
| Word文档 | |
| 电子表格 | |
| 演示文稿 | |
| JPEG图片 | |
| PNG图片 | |
| WebP图片 | |
| GIF图片 | |
| SVG图片 | |
| TIFF图片 | |
| BMP图片 | |
| 纯文本 | |
| Markdown文本 | |
| JSON数据 | |
| CSV数据 | |
| HTML | |
Step B: Expand Folders
步骤B:展开文件夹
When the user provides a folder path:
- List all files in the folder (non-recursive by default, recursive if user requests)
- Filter to supported file types
- Group files by detected type
- Match to list-type inputs (,
Image[], etc.)Document[]
Example: User provides containing 5 PDFs. The method expects . Map all 5 PDFs to that list input.
./invoices/documents: Document[]当用户提供文件夹路径时:
- 列出文件夹中的所有文件(默认非递归,若用户要求则递归)
- 筛选出支持的文件类型
- 按检测类型分组文件
- 匹配至列表类型输入(、
Image[]等)Document[]
示例:用户提供,其中包含5个PDF文件。方法需要。将所有5个PDF映射至该列表输入。
./invoices/documents: Document[]Step C: Match Files to Inputs
步骤C:匹配文件与输入
For each input variable in the schema, attempt to match user-provided files:
Matching rules (applied in order):
- Exact name match: Input variable matches a file named
invoiceinvoice.pdf - Type match (single candidate): If only one input expects and the user provided exactly one image file, match them
native.Image - Type match (multiple candidates): If multiple inputs of the same type exist:
- In automatic mode: match by name similarity (variable name vs filename)
- In interactive mode: ask the user which file goes where
- Folder to list: If a folder contains files of a single type and an input expects a list of that type, map the folder contents to that input
- Unmatched files: Report them and ask if they should be ignored or mapped to a specific input
- Unfilled inputs: After matching, any inputs still without data can be left as placeholders or filled with synthetic data (see Mixed Strategy)
为Schema中的每个输入变量尝试匹配用户提供的文件:
匹配规则(按顺序应用):
- 精确名称匹配:输入变量匹配名为
invoice的文件invoice.pdf - 类型匹配(唯一候选):若仅有一个输入需要,且用户恰好提供了一个图片文件,则匹配二者
native.Image - 类型匹配(多个候选):若存在多个同类型输入:
- 自动模式:按名称相似度匹配(变量名 vs 文件名)
- 交互模式:询问用户文件与哪个输入对应
- 文件夹映射至列表:若文件夹包含单一类型的文件,且输入需要该类型的列表,则将文件夹内容映射至该输入
- 未匹配文件:报告这些文件并询问是否忽略或映射至特定输入
- 未填充输入:匹配完成后,任何未填充的输入可保留为占位符或用合成数据填充(请参阅混合策略)
Step D: Copy Files to Output Directory
步骤D:复制文件至输出目录
Copy (or symlink) user files into so uses paths relative to the output directory. This keeps the pipeline directory self-contained. Only create the subdirectory if there are actual files to copy.
<output_dir>/inputs/inputs.jsoninputs/Use descriptive filenames: if the input variable is , copy to (preserving original extension).
invoice<output_dir>/inputs/invoice.pdf将用户文件复制(或创建符号链接)至,使使用相对于输出目录的路径。这样可保持管道目录的独立性。仅当有实际文件需要复制时,才创建子目录。
<output_dir>/inputs/inputs.jsoninputs/使用描述性文件名:若输入变量为,则复制至(保留原扩展名)。
invoice<output_dir>/inputs/invoice.pdfStep E: Build Content Objects
步骤E:构建内容对象
For each matched file, construct the proper content object:
Document input:
json
{
"concept": "native.Document",
"content": {
"url": "<output_dir>/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
}Image input:
json
{
"concept": "native.Image",
"content": {
"url": "<output_dir>/inputs/photo.jpg",
"mime_type": "image/jpeg"
}
}Text input (from or file — read the file content):
.txt.mdjson
{
"concept": "native.Text",
"content": {
"text": "<actual file content read from the .txt/.md file>"
}
}Image list input (from folder):
json
{
"concept": "native.Image",
"content": [
{"url": "<output_dir>/inputs/img_001.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_002.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_003.png", "mime_type": "image/png"}
]
}为每个匹配的文件构建合适的内容对象:
文档输入:
json
{
"concept": "native.Document",
"content": {
"url": "<output_dir>/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
}图片输入:
json
{
"concept": "native.Image",
"content": {
"url": "<output_dir>/inputs/photo.jpg",
"mime_type": "image/jpeg"
}
}文本输入(来自或文件 — 读取文件内容):
.txt.mdjson
{
"concept": "native.Text",
"content": {
"text": "<从.txt/.md文件读取的实际内容>"
}
}图片列表输入(来自文件夹):
json
{
"concept": "native.Image",
"content": [
{"url": "<output_dir>/inputs/img_001.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_002.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_003.png", "mime_type": "image/png"}
]
}Step F: Assemble and Save
步骤F:组装并保存
Combine all content objects into a single and save to (next to ).
inputs.json<output_dir>/inputs.jsonbundle.mthds将所有内容对象合并为单个,并保存至(与同级)。
inputs.json<output_dir>/inputs.jsonbundle.mthdsStep G: Report
步骤G:报告
Show the user:
- Which files were matched to which inputs
- Any unfilled inputs (offer synthetic or placeholder)
- The final content
inputs.json - Path to the saved file
向用户展示:
- 哪些文件与哪些输入匹配
- 任何未填充的输入(提供合成数据或占位符选项)
- 最终的内容
inputs.json - 保存的文件路径
Mixed Strategy
混合策略
Combines user data with synthetic generation for any remaining gaps.
- Follow User Data Strategy Steps A-E to match user files
- For each unfilled input, apply Synthetic Strategy
- Assemble the complete combining both sources
inputs.json - Report which inputs came from user data and which were synthesized
Image Generation
图片生成
Use the Pipelex pipeline to generate test images.
synthesize_imageCommand:
First, create an input file (e.g., ):
<output_dir>/image_request.jsonjson
{
"request": {
"concept": "synthetic_data.ImageRequest",
"content": {
"category": "<category>",
"description": "<optional description>"
}
}
}Then run:
bash
mthds-agent pipelex run pipe pipelex/builder/synthetic_inputs/synthesize_image.mthds --inputs <output_dir>/image_request.jsonImage Categories:
| Category | Use For | Example Description |
|---|---|---|
| Real-world photos, product images, portraits | "A professional headshot of a business person" |
| UI mockups, app screens, web pages | "A mobile banking app dashboard showing account balance" |
| Data visualizations, graphs, plots | "A bar chart showing quarterly sales by region" |
| Technical diagrams, flowcharts, architecture | "A system architecture diagram with microservices" |
| Scanned papers, receipts, forms | "A scanned invoice from a hardware store" |
| Handwritten notes, signatures | "Handwritten meeting notes on lined paper" |
Output: The pipeline saves the generated image to and returns the file path.
<output_dir>/inputs/For image synthesis error handling, see Error Handling Reference.
使用 Pipelex管道生成测试图片。
synthesize_image命令:
首先,创建输入文件(例如):
<output_dir>/image_request.jsonjson
{
"request": {
"concept": "synthetic_data.ImageRequest",
"content": {
"category": "<category>",
"description": "<可选描述>"
}
}
}然后运行:
bash
mthds-agent pipelex run pipe pipelex/builder/synthetic_inputs/synthesize_image.mthds --inputs <output_dir>/image_request.json图片类别:
| 类别 | 适用场景 | 示例描述 |
|---|---|---|
| 真实照片、产品图片、肖像 | "商务人士的专业头像" |
| UI原型、应用界面、网页 | "显示账户余额的移动银行应用仪表盘" |
| 数据可视化、图表、图形 | "按区域划分的季度销售柱状图" |
| 技术图表、流程图、架构图 | "包含微服务的系统架构图" |
| 扫描文档、收据、表单 | "五金店的扫描发票" |
| 手写笔记、签名 | "写在横格纸上的手写会议笔记" |
输出:管道将生成的图片保存至并返回文件路径。
<output_dir>/inputs/有关图片合成的错误处理,请参阅错误处理参考。
Document Generation
文档生成
Generate test documents based on the document type needed.
根据所需的文档类型生成测试文档。
PDF Documents
PDF文档
is a dependency ofreportlab— always available, no additional installation needed.pipelex
是reportlab的依赖项 — 始终可用,无需额外安装。pipelex
Basic PDF (Canvas API)
基础PDF(Canvas API)
python
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("<output_dir>/inputs/test_document.pdf", pagesize=letter)
width, height = letterpython
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("<output_dir>/inputs/test_document.pdf", pagesize=letter)
width, height = letterAdd text
添加文本
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")
Add a line
添加线条
c.line(100, height - 140, 400, height - 140)
c.line(100, height - 140, 400, height - 140)
Save
保存
c.save()
undefinedc.save()
undefinedMulti-Page PDF (Platypus)
多页PDF(Platypus)
python
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []python
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []Add content
添加内容
title = Paragraph("Report Title", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))
body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())
title = Paragraph("Report Title", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))
body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())
Page 2
第2页
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))
Build PDF
构建PDF
doc.build(story)
undefineddoc.build(story)
undefinedProfessional Reports with Tables
带表格的专业报告
python
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colorspython
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colorsSample data
示例数据
data = [
['Product', 'Q1', 'Q2', 'Q3', 'Q4'],
['Widgets', '120', '135', '142', '158'],
['Gadgets', '85', '92', '98', '105']
]
data = [
['Product', 'Q1', 'Q2', 'Q3', 'Q4'],
['Widgets', '120', '135', '142', '158'],
['Gadgets', '85', '92', '98', '105']
]
Create PDF with table
创建带表格的PDF
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf")
elements = []
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf")
elements = []
Add title
添加标题
styles = getSampleStyleSheet()
title = Paragraph("Quarterly Sales Report", styles['Title'])
elements.append(title)
styles = getSampleStyleSheet()
title = Paragraph("Quarterly Sales Report", styles['Title'])
elements.append(title)
Add table with advanced styling
添加带高级样式的表格
table = Table(data)
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 14),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
('GRID', (0, 0), (-1, -1), 1, colors.black)
]))
elements.append(table)
doc.build(elements)
**Last resort** — use a public test PDF URL:
```json
{
"url": "https://www.w3.org/WAI/WCAG21/Techniques/pdf/img/table-word.pdf",
"mime_type": "application/pdf"
}table = Table(data)
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 14),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
('GRID', (0, 0), (-1, -1), 1, colors.black)
]))
elements.append(table)
doc.build(elements)
**最后手段** — 使用公开测试PDF URL:
```json
{
"url": "https://www.w3.org/WAI/WCAG21/Techniques/pdf/img/table-word.pdf",
"mime_type": "application/pdf"
}Word Documents (DOCX)
Word文档(DOCX)
If skill is available:
example-skills:docxUse the /docx skill to create a Word document with the following content:
[Describe the document content, structure, and formatting]
Save to: <output_dir>/inputs/<filename>.docxIf skill is NOT available, create using Python:
python
undefined若技能可用:
example-skills:docx使用/docx技能创建包含以下内容的Word文档:
[描述文档内容、结构和格式]
保存至:<output_dir>/inputs/<filename>.docx若技能不可用,使用Python创建:
python
undefinedRequires: pip install python-docx
需安装:pip install python-docx
from docx import Document
doc = Document()
doc.add_heading('Test Document', 0)
doc.add_paragraph('This is synthetic test content for method testing.')
from docx import Document
doc = Document()
doc.add_heading('Test Document', 0)
doc.add_paragraph('This is synthetic test content for method testing.')
Add more content as needed
根据需要添加更多内容
doc.save('<output_dir>/inputs/test_document.docx')
undefineddoc.save('<output_dir>/inputs/test_document.docx')
undefinedSpreadsheets (XLSX)
电子表格(XLSX)
If skill is available:
example-skills:xlsxUse the /xlsx skill to create a spreadsheet with the following data:
[Describe columns, rows, and sample data]
Save to: <output_dir>/inputs/<filename>.xlsxIf skill is NOT available, create using Python:
python
undefined若技能可用:
example-skills:xlsx使用/xlsx技能创建包含以下数据的电子表格:
[描述列、行和示例数据]
保存至:<output_dir>/inputs/<filename>.xlsx若技能不可用,使用Python创建:
python
undefinedRequires: pip install openpyxl
需安装:pip install openpyxl
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws['A1'] = 'Column1'
ws['B1'] = 'Column2'
ws['A2'] = 'Value1'
ws['B2'] = 'Value2'
wb.save('<output_dir>/inputs/test_spreadsheet.xlsx')
---
**Fallback Strategy:**
1. For PDFs: use `reportlab` (always available via pipelex) with the patterns above
2. For DOCX/XLSX: use the `/docx` or `/xlsx` skill (install from the Anthropic example-skills marketplace if not available)
3. For any format: use public test file URLs as fallback
4. As last resort, ask user to provide test files
---from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws['A1'] = 'Column1'
ws['B1'] = 'Column2'
ws['A2'] = 'Value1'
ws['B2'] = 'Value2'
wb.save('<output_dir>/inputs/test_spreadsheet.xlsx')
---
** fallback策略:**
1. 对于PDF:使用`reportlab`(通过pipelex始终可用),采用上述模板
2. 对于DOCX/XLSX:使用`/docx`或`/xlsx`技能(若不可用,从Anthropic示例技能市场安装)
3. 对于任何格式:使用公开测试文件URL作为备选
4. 最后手段:请求用户提供测试文件
---Validate & Run
验证与运行
After assembling the inputs, confirm readiness:
Inputs are ready.has been saved with real values — no placeholders remain.inputs.json
Then offer to run:
bash
undefined组装输入后,确认准备就绪:
输入已准备完成。已保存真实值 — 无占位符剩余。inputs.json
随后提供运行选项:
bash
undefinedDry run with the prepared inputs (directory mode auto-detects bundle, inputs, library dir)
使用准备好的输入进行试运行(目录模式自动检测包、输入和库目录)
mthds-agent pipelex run pipe <bundle-dir>/ --dry-run
mthds-agent pipelex run pipe <bundle-dir>/ --dry-run
Full run (uses actual AI/extraction models)
完整运行(使用实际AI/提取模型)
mthds-agent pipelex run pipe <bundle-dir>/
---mthds-agent pipelex run pipe <bundle-dir>/
---Native Concept Content Structures
原生概念内容结构
Text
Text
json
{"text": "The actual text content"}json
{"text": "实际文本内容"}Number
Number
json
{"number": 42}json
{"number": 42}Image
Image
json
{
"url": "/path/to/image.jpg",
"caption": "Optional description",
"mime_type": "image/jpeg"
}json
{
"url": "/path/to/image.jpg",
"caption": "可选描述",
"mime_type": "image/jpeg"
}Document
Document
json
{
"url": "/path/to/document.pdf",
"mime_type": "application/pdf"
}json
{
"url": "/path/to/document.pdf",
"mime_type": "application/pdf"
}TextAndImages
TextAndImages
json
{
"text": {"text": "Main text content"},
"images": [
{"url": "/path/to/img1.png", "caption": "Figure 1"}
]
}json
{
"text": {"text": "主要文本内容"},
"images": [
{"url": "/path/to/img1.png", "caption": "图1"}
]
}Page
Page
json
{
"text_and_images": {
"text": {"text": "Page content..."},
"images": []
},
"page_view": null
}json
{
"text_and_images": {
"text": {"text": "页面内容..."},
"images": []
},
"page_view": null
}JSON
JSON
json
{"json_obj": {"key": "value", "nested": {"data": 123}}}json
{"json_obj": {"key": "value", "nested": {"data": 123}}}Complete Examples
完整示例
Example 1: Template for a Haiku writer
示例1:俳句生成器的模板
Method: Haiku pipeline expecting
theme: Textbash
mthds-agent pipelex inputs mthds-wip/pipeline_01/bundle.mthds -L mthds-wip/pipeline_01/Save the from the output directly to .
inputsmthds-wip/pipeline_01/inputs.json方法:需要的俳句管道
theme: Textbash
mthds-agent pipelex inputs mthds-wip/pipeline_01/bundle.mthds -L mthds-wip/pipeline_01/将输出中的直接保存至。
inputsmthds-wip/pipeline_01/inputs.jsonExample 2: Synthetic data for an image analysis pipeline
示例2:图片分析管道的合成数据
Method: Image analyzer expecting and
image: Imageanalysis_prompt: Text- Get schema, identify needs: test photograph + instruction text
- Generate image via with category
synthesize_image.mthdsphotograph - Write analysis prompt text matching the method context
- Assemble:
json
{
"image": {
"concept": "native.Image",
"content": {
"url": "mthds-wip/pipeline_01/inputs/city_street.jpg",
"mime_type": "image/jpeg"
}
},
"analysis_prompt": {
"concept": "native.Text",
"content": {
"text": "Analyze this street scene. Count visible people and describe the atmosphere."
}
}
}方法:需要和的图片分析器
image: Imageanalysis_prompt: Text- 获取Schema,确定需求:测试图片 + 指令文本
- 使用生成
synthesize_image.mthds类别的图片photograph - 编写符合方法上下文的分析提示文本
- 组装:
json
{
"image": {
"concept": "native.Image",
"content": {
"url": "mthds-wip/pipeline_01/inputs/city_street.jpg",
"mime_type": "image/jpeg"
}
},
"analysis_prompt": {
"concept": "native.Text",
"content": {
"text": "分析此街景。统计可见人数并描述氛围。"
}
}
}Example 3: User-provided invoice PDF
示例3:用户提供的发票PDF
Method: Invoice processor expecting and
invoice: Documentinstructions: TextUser says: "Use my file "
~/documents/invoice_march.pdf- Get schema: needs (Document) +
invoice(Text)instructions - Inventory: user provided (PDF = Document type)
invoice_march.pdf - Match: maps to
invoice_march.pdfinput (name similarity + type match)invoice - Copy:
cp ~/documents/invoice_march.pdf mthds-wip/pipeline_01/inputs/invoice.pdf - Unfilled: has no user file. Generate synthetic text: "Extract all line items, totals, and vendor information from this invoice."
instructions - Assemble:
json
{
"invoice": {
"concept": "native.Document",
"content": {
"url": "mthds-wip/pipeline_01/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
},
"instructions": {
"concept": "native.Text",
"content": {
"text": "Extract all line items, totals, and vendor information from this invoice."
}
}
}方法:需要和的发票处理器
invoice: Documentinstructions: Text用户说:“使用我的文件”
~/documents/invoice_march.pdf- 获取Schema:需要(Document) +
invoice(Text)instructions - 盘点:用户提供(PDF = Document类型)
invoice_march.pdf - 匹配:映射至
invoice_march.pdf输入(名称相似度 + 类型匹配)invoice - 复制:
cp ~/documents/invoice_march.pdf mthds-wip/pipeline_01/inputs/invoice.pdf - 未填充:无用户文件。生成合成文本:“提取此发票中的所有行项目、总计和供应商信息。”
instructions - 组装:
json
{
"invoice": {
"concept": "native.Document",
"content": {
"url": "mthds-wip/pipeline_01/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
},
"instructions": {
"concept": "native.Text",
"content": {
"text": "提取此发票中的所有行项目、总计和供应商信息。"
}
}
}Example 4: Folder of images for batch processing
示例4:用于批量处理的图片文件夹
Method: Batch image captioner expecting
images: Image[]User says: "Use the photos in "
./product-photos/- Get schema: needs (Image[])
images - Expand folder: contains
./product-photos/,shoe.jpg,hat.pngbag.jpg - Copy all to
<output_dir>/inputs/ - Assemble:
json
{
"images": {
"concept": "native.Image",
"content": [
{"url": "mthds-wip/pipeline_01/inputs/shoe.jpg", "mime_type": "image/jpeg"},
{"url": "mthds-wip/pipeline_01/inputs/hat.png", "mime_type": "image/png"},
{"url": "mthds-wip/pipeline_01/inputs/bag.jpg", "mime_type": "image/jpeg"}
]
}
}方法:需要的批量图片标注器
images: Image[]用户说:“使用中的照片”
./product-photos/- 获取Schema:需要(Image[])
images - 展开文件夹:包含
./product-photos/、shoe.jpg、hat.pngbag.jpg - 将所有文件复制至
<output_dir>/inputs/ - 组装:
json
{
"images": {
"concept": "native.Image",
"content": [
{"url": "mthds-wip/pipeline_01/inputs/shoe.jpg", "mime_type": "image/jpeg"},
{"url": "mthds-wip/pipeline_01/inputs/hat.png", "mime_type": "image/png"},
{"url": "mthds-wip/pipeline_01/inputs/bag.jpg", "mime_type": "image/jpeg"}
]
}
}Reference
参考
- CLI Prerequisites — read at skill start to check CLI availability
- Error Handling — read when CLI returns an error to determine recovery
- MTHDS Agent Guide — read for CLI command syntax or output format details
- MTHDS Language Reference — read for concept definitions and syntax
- Native Content Types — read for the full attribute reference of each native content type when assembling input JSON
- CLI前置条件 — 技能启动时读取,检查CLI可用性
- 错误处理 — 当CLI返回错误时读取,确定恢复方式
- MTHDS Agent指南 — 读取CLI命令语法或输出格式细节
- MTHDS语言参考 — 读取概念定义和语法
- 原生内容类型 — 组装输入JSON时,读取每个原生内容类型的完整属性参考