Skip to main content

Local CLI and desktop checker for repairing structured LLM outputs against lightweight schemas

Project description

Terminal report screenshot

structured-output-doctor

structured-output-doctor is a local CLI and desktop checker for pasted model outputs that are supposed to match a JSON contract.

It helps catch:

  • invalid JSON hidden inside Markdown fences or surrounding prose
  • missing required fields
  • type drift such as "yes" where a boolean is expected
  • enum values outside an allowed set
  • mixed array item types
  • unexpected top-level fields

The tool has no runtime dependencies.

Install

pip install structured-output-doctor

For local development:

python3 -m pip install -e .

Quick Start

Check a model output against a lightweight schema:

structured-output-doctor examples/model-output.txt --schema examples/support-schema.json

Write a Markdown handoff report:

structured-output-doctor examples/model-output.txt \
  --schema examples/support-schema.json \
  --format markdown \
  --output-file structured-output-report.md

Read output from stdin:

cat response.txt | structured-output-doctor --schema schema.json --fail-under 80

Open the desktop paste-and-check app:

structured-output-doctor-gui

Schema Format

Use a compact fields array:

{
  "additional_fields": "warn",
  "fields": [
    { "path": "summary", "type": "string", "non_empty": true },
    { "path": "priority", "type": "string", "enum": ["low", "medium", "high"] },
    { "path": "actions", "type": "array", "items": "string" },
    { "path": "needs_human_review", "type": "boolean" }
  ]
}

Supported types are any, array, boolean, float, integer, null, number, object, and string. Nested paths use dotted names and array indexes, such as choices[0].message.content.

Basic JSON Schema-style objects with properties and required are also accepted for simple field checks.

Report Formats

structured-output-doctor response.txt -s schema.json --format text
structured-output-doctor response.txt -s schema.json --format markdown
structured-output-doctor response.txt -s schema.json --format json
structured-output-doctor response.txt -s schema.json --format html --output-file report.html

Exit codes:

  • 0: parsed and passed the configured score threshold
  • 1: validation failed or the score is below --fail-under
  • 2: command usage or file loading failed

Development

Run tests:

PYTHONPATH=src python3 -m unittest discover -s tests

Build and check package artifacts:

python3 -m build --no-isolation
python3 -m twine check dist/*

Contributing

Issues and pull requests are welcome. Keep changes focused, include tests for behavior changes, and update this README when command behavior changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

structured_output_doctor-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

structured_output_doctor-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file structured_output_doctor-0.1.0.tar.gz.

File metadata

File hashes

Hashes for structured_output_doctor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f1e75e3713eb50bbf870543dc8ae7d56d8b4281b23e040099a28689a62b7a18
MD5 ea7e01598aebd93756075066e29b995d
BLAKE2b-256 87f0aed26b0a7e03885e8d62b52ec66f86a4037f90013e2428a7c14be48f5e0d

See more details on using hashes here.

File details

Details for the file structured_output_doctor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for structured_output_doctor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8efaa8812f9baf4d087b4ef2fb503b1fe56e523722e626bdd084b273272e298b
MD5 89f1e4ace772d21c05204c2a8eac3969
BLAKE2b-256 5f9087bc0e908a495b4c931adea5c64cbc4bc291eef72c2dcae10bcdddb264fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page