Skip to content

sen-ltd/schema-prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

schema-prompt

Demo

JSON Schema → LLM-ready prompt fragment + output validator. Paste a schema, copy the prompt fragment your LLM consumes for structured output, paste back what came out, see if it conforms.

From the Thoughtworks Technology Radar Vol 34 (Adopt, April 2026): Structured output from LLMs.

Live demo: https://sen.ltd/portfolio/schema-prompt/

Screenshot

特徴

  • Schema → prompt fragment: turns properties / types / constraints into natural-language bullets the LLM consumes (the same shape Instructor / Pydantic AI / Outlines produce internally)
  • Synthesized example output: shows the JSON shape the LLM should produce — useful as a few-shot anchor in the prompt
  • Validator panel: paste the LLM's response, see per-field errors with paths ($.user.age — −5 < minimum 0)
  • 5 real-world preset schemas: sentiment + confidence, address parsing, meeting summary, entity extraction, product extraction
  • Pure prompt generator + validator (33 unit tests), no LLM API calls, no build step, no dependencies

ローカル起動

npm run serve
# → http://localhost:8080

テスト

npm test

アーキテクチャ

prompt.js    ← Schema → LLM prompt + example generator (15 tests)
validate.js  ← JSON Schema validator subset for LLM output (18 tests)
presets.js   ← 5 real-world schemas + matching sample outputs
app.js       ← UI glue (schema → prompt + example, output → validation)

prompt.jsvalidate.js は DOM 非依存。documentwindow も触らない。Node テストでスキーマ生成 + バリデーション両方を完全検証してから UI を組む。

実装している JSON Schema サブセット

LLM workflow が使う構文だけに絞っている:

  • type (string / number / integer / boolean / array / object / null + union)
  • properties + required
  • items + minItems / maxItems
  • enum / const
  • minimum / maximum
  • minLength / maxLength
  • pattern (regex)
  • format (hint only — no validation)
  • description (used by prompt generator)

意図的に対応していないもの: oneOf / anyOf / allOf / $ref / additionalProperties の厳格チェック (LLM 出力では実用上不要)。

ライセンス

MIT. See LICENSE.

Links

About

JSON Schema → LLM-ready prompt fragment + output validator. Built for the Structured output from LLMs pattern (Tech Radar Vol 34 Adopt). 33 unit tests, no LLM API calls.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors