Validate and retry LLM outputs with RubyLLM::Contract #809
justi
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone! I've built RubyLLM::Contract, a gem that wraps
RubyLLM::Chatwith input/output contracts, business-rule validation, retry with model escalation, pre-flight cost ceilings, and a regression-eval framework.The problem it solves: LLMs can return JSON that looks correct - valid shape, right types - while being silently wrong in ways schema validation doesn't catch. Contract lets you declare business rules next to the prompt, escalate to a stronger model when the cheap one fails them, and gate CI on eval regressions.
It composes with RubyLLM::Tribunal - Contract gates at runtime (before output reaches your code, with retries on failure), Tribunal grades at test time (in your spec suite). Ecosystem PR: #808. Feedback very welcome!
Beta Was this translation helpful? Give feedback.
All reactions