Logo Structured Output

Structured Output

Cộng đồng
nahid-sparktales
structured-output

Get parseable, trustworthy structured results out of a model — schema design, the enforcement mechanism the provider actually offers, validation at the boundary, bounded retry that feeds the error back, and recognising where a schema stops buying correctness. Use when a model's output feeds code rather than a human, when parsing keeps failing or fields come back plausible-but-wrong, or when designing an extraction, classification or grading step. Not for designing the tools an agent calls (tool-design), and not for free-form prose quality.

Add to TypingMind

Tổng quan

Nhà phát hànhnahid-sparktales
Kho mãagent-dispatcher
Tên kỹ năngstructured-output
Sao
58
Bản fork
5
Tệp đi kèm
1
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được nahid-sparktales công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Structured Output trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/nahid-sparktales/agent-dispatcher/tree/main/skills/ai/structured-output
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nahid-sparktales/agent-dispatcher.git /tmp/agent-dispatcher
mkdir -p .claude/skills
cp -r /tmp/agent-dispatcher/skills/ai/structured-output .claude/skills/structured-output
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Structured Output trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Structured Output ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Structured Output với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Structured output

A schema constrains shape, never truth. It buys you parse() succeeding; it does not buy you a correct value in the field. Most structured-output work is deciding which of those two problems you actually have.

When this fires

Any model output that code consumes: extraction, classification, routing, scoring, grading, filling a record. Also when parsing fails intermittently, when required fields arrive empty or invented, or when a downstream system trips over a value that validated fine. It does not fire for output a human reads.

Procedure

  1. Decide what the code truly needs. Every field is something the model must get right and you must validate. A schema with three well-defined fields outperforms one with twelve where four are guesses. Drop anything no caller reads.
  2. Use the strongest enforcement the provider gives you, and know which one it is. Ranked: constrained decoding against the schema, where the provider guarantees conformance; a tool or function call carrying the schema; a prompt asking for JSON, parsed defensively. The third is not a guarantee. Check the provider's current documentation for which mode applies and which JSON Schema keywords it supports — unsupported keywords are commonly ignored rather than rejected, and an ignored constraint fails later as a mysterious bad value.
  3. Make illegal values unrepresentable. Closed enums instead of free strings for anything with a known set. Numbers as numbers, with bounds. Dates in one stated format. No field that means two things depending on another field. Flat beats deeply nested: nesting and recursion cost accuracy and are the first thing a strict mode refuses.
  4. Name fields so the schema teaches the task. refund_reason_code with an enum and a one-line description does work no prompt sentence has to repeat. Put the per-field instruction in the schema description, not scattered in the prompt.
  5. Give uncertainty somewhere to go. Add an explicit unknown or not_stated enum member and a nullable field where absence is genuine. Without it, a required field forces a fabrication — the schema converts "I don't know" into a confident wrong answer. A refusal or safety stop also needs a representable path; do not model it as a parse error.
  6. Order the fields so reasoning precedes conclusion. Where a decision needs thinking, put a short rationale field before the verdict, or take the reasoning outside the object entirely. A verdict emitted first and justified afterwards is a rationalization, not a reason.
  7. Validate at the boundary, every time. Parse with the real validator — the schema library the project already uses — and then check what the schema cannot: does the id exist, is the date in range, do the extracted spans appear in the source, does the total match the line items. Never let unvalidated model output into a database, a query, a shell command or a URL.
  8. Retry narrowly, bounded, with the error fed back. On a validation failure, return the validator's message and the offending output, and ask for a correction. One or two attempts, then fail loudly. An unbounded repair loop hides a broken schema and bills for it. Escalating to a larger model or splitting the task beats a third retry.
  9. Know when to stop adding schema. A schema cannot make a field accurate, cannot resolve a genuinely ambiguous source, cannot enforce a relationship between fields, and cannot stop confident invention. When failures are wrong values rather than wrong shapes, the fix is upstream: better retrieval, a smaller task, an example or two, a split into separate calls — not another constraint. Say this plainly instead of tightening a schema that is already conforming.
  10. Measure on a fixed set before trusting it. Twenty to fifty labelled cases including the ugly ones — missing data, ambiguity, adversarial text, empty input. Record parse rate and field accuracy separately; they fail for different reasons and a high parse rate hides a low accuracy. Re-run it when the schema, prompt or model changes.
  11. Stop at the boundary. Producing validated output is extracted. Writing it into a system of record, sending it onward, or acting on it is a separate, outward-facing step — and where the output drives a destructive action, it stops and asks first.

Checklist

  • Every field is read by a caller; the rest are gone
  • Enforcement mechanism named, and confirmed against current provider documentation
  • Enums closed, numbers bounded, one date format, no overloaded fields
  • Nesting kept shallow and supported by the mode in use
  • Per-field meaning lives in the schema description
  • unknown / null paths exist so the model need not fabricate; refusal is representable
  • Rationale precedes verdict where a judgement is made
  • Output validated with a real validator, plus the semantic checks the schema cannot make
  • Retry bounded, error message fed back, hard failure after the bound
  • Fixed evaluation set run; parse rate and field accuracy reported separately

Failure handling

  • Parse fails intermittently — prose around the JSON, a truncated response hitting the token limit, or a mode that was never actually enforcing. Check the finish reason before blaming the prompt.
  • It validates but the values are wrong — a schema problem no longer. Go to step 9.
  • A required field is always filled and sometimes invented — you removed the model's escape hatch. Add unknown.
  • The schema is rejected by the provider — an unsupported keyword or too much nesting. Simplify the schema rather than dropping to unenforced prompting.
  • Retries succeed often enough to look fine — that is a defect rate you are paying to hide. Report the pre-retry rate.
  • No labelled cases exist — say the accuracy is unmeasured. "Parses reliably" is not "is correct", and the two must never be reported as one claim.

Evidence to report

The schema as shipped. The enforcement mode, named, with what it does and does not guarantee. Validation code and the semantic checks beyond the schema. Results on the fixed set: parse rate before retries, parse rate after, field-level accuracy, and the failure cases with their inputs. Keep the verbs apart — parses, validates and is correct are three different results, and only the third needs labelled data to claim.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Structured Output làm được gì?

Get parseable, trustworthy structured results out of a model — schema design, the enforcement mechanism the provider actually offers, validation at the boundary, bounded retry that feeds the error back, and recognising where a schema stops buying correctness. Use when a model's output feeds code rather than a human, when parsing keeps failing or fields come back plausible-but-wrong, or when designing an extraction, classification or grading step. Not for designing the tools an agent calls (tool-design), and not for free-form prose quality.

Vì sao nên dùng Structured Output trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Structured Output là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Structured Output trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/nahid-sparktales/agent-dispatcher/tree/main/skills/ai/structured-output. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Structured Output?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Structured Output với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Structured Output với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Structured Output có miễn phí không?

Có. Kỹ năng này được nahid-sparktales phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇