Instructor Structured Output
/install instructor-structured-output
这个 skill 适合什么用户?能做哪些任务?
概览
Instructor 是把 Pydantic BaseModel 直接绑到 LLM 输出的 Python 框架(github.com/jxnl/instructor)。核心机制:monkey-patch(instructor.patch / instructor.from_*)拦截 provider client 的 create() 调用,注入 schema-aware kwargs,在 tenacity 重试循环里跑,验证 JSON 响应到模型,ValidationError 时把 failed_attempts 作为 XML 重写 prompt 再试。
支持 20 个 provider...
Doramagic 晶体页: https://doramagic.ai/zh/crystal/instructor-structured-output
知识规模
- 47 条约束 (4 fatal + 43 non-fatal)
- 上游源码:
jxnl/instructor@ commit3f1d6ddb - 蓝图 ID:
finance-bp-139
用法
Host AI(Claude Code / Cursor / OpenClaw)读 references/seed.yaml,按其中的:
intent_router匹配用户意图architecture理解项目架构constraints应用 anti-pattern 约束business_decisions参考核心设计决策
FAQ 摘要
这个 skill 适合什么用户?能做哪些任务?
适合需要从 LLM 拿到强类型结构化输出的工程师:信息抽取、表单解析、JSON API 直接返回 Pydantic 模型、agent 工具调用参数解析等。20 个 provider 一致 API。访问 doramagic.ai/r/instructor 查看完整用例。
需要准备什么环境?依赖什么?
Python 3.9+(instructor 在 pyproject 中声明 >=3.9)。Pydantic v2 事实上必须(function_calls.py 用 model_validate_json + TypeAdapter,都是 v2-only,v1 在 Partial 路径上 AttributeError)。
会踩哪些坑?这个 skill 怎么防护?
本 skill 内置 47 条约束(4 条 fatal)。典型踩坑:(1) failed_attempts XML 每次重试线性增长,max_retries=5 可超 context window;(2) from_openai 的 mode 验证用 assert,python -O 下静默剥离;
完整文档: 见 references/seed.yaml (v6.1 schema). 浏览页: https://doramagic.ai/zh/crystal/instructor-structured-output
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install instructor-structured-output - After installation, invoke the skill by name or use
/instructor-structured-output - Provide required inputs per the skill's parameter spec and get structured output
What is Instructor Structured Output?
Instructor:声明 Pydantic BaseModel 即可从 20 个 LLM provider 拿到类型化实例。核心是 monkey-patch(instructor.patch / from_*)拦截 create(),注入 schema-aware kwargs,tenacity 重试 + In... It is an AI Agent Skill for Claude Code / OpenClaw, with 64 downloads so far.
How do I install Instructor Structured Output?
Run "/install instructor-structured-output" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Instructor Structured Output free?
Yes, Instructor Structured Output is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Instructor Structured Output support?
Instructor Structured Output is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Instructor Structured Output?
It is built and maintained by Tang Weigang (@tangweigang-jpg); the current version is v0.1.0.