Ruby LLM 合约验证 是 AI Skill Hub 本期精选Prompt模板之一。综合评分 7.5 分,整体质量较高。我们推荐使用将其纳入你的 AI 工具库,帮助提升工作效率。
Validate 和 retry LLM 输出,适用于 Ruby LLM。
Ruby LLM 合约验证 是经过精心设计和反复验证的专业 Prompt 模板集合。这些 Prompt 框架能够有效激活 Claude、ChatGPT 等大型语言模型的深层能力,让 AI 生成更准确、更有价值的输出结果。无需任何安装,直接复制模板内容到 AI 对话框即可使用。
Validate 和 retry LLM 输出,适用于 Ruby LLM。
Ruby LLM 合约验证 是经过精心设计和反复验证的专业 Prompt 模板集合。这些 Prompt 框架能够有效激活 Claude、ChatGPT 等大型语言模型的深层能力,让 AI 生成更准确、更有价值的输出结果。无需任何安装,直接复制模板内容到 AI 对话框即可使用。
# Prompt 无需安装,直接复制使用 # 支持:Claude / ChatGPT / Gemini / 通义千问 等主流模型 # 使用步骤 # 1. 复制 Prompt 模板内容 # 2. 粘贴到 AI 对话框 # 3. 替换 [占位符] 为实际内容 # 4. 发送后获取结构化输出 # 获取原始文件 git clone https://github.com/justi/ruby_llm-contract
# 粘贴到 Claude/ChatGPT 使用 # 示例 Prompt 结构: 你是一位 [角色],擅长 [领域]。 请根据以下要求完成任务: 任务背景:[描述背景] 具体要求:[详细说明] 输出格式:[期望格式] # 将 [] 内内容替换为实际需求
# ruby_llm-contract 配置说明 # 查看配置选项 ruby_llm-contract --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export RUBY_LLM_CONTRACT_CONFIG="/path/to/config.yml"
Contracts + Evals for ruby_llm.
Your eval passed. Prod broke anyway? This gem wraps RubyLLM::Chat with input/output contracts, business-rule validation, retry with model escalation on validation failure, pre-flight cost ceilings, and a regression-eval framework — so a flaky cheap-model call escalates to a stronger model instead of shipping garbage to your user.
ruby_llm handles the HTTP side (rate limits, timeouts, streaming, tool calls, embeddings). This gem handles what the model returned at runtime: schema validation, business rules, model escalation on failed validation, regression datasets that gate prompt/model changes in CI.
gem "ruby_llm-contract"
```ruby RubyLLM.configure do |c| c.openai_api_key = ENV["OPENAI_API_KEY"] c.default_model = "gpt-4.1-mini" # used when a Step has no explicit model end
A Rails app takes article text extracted from a user-submitted URL and wants to show a summary card: a short TL;DR, 3–5 key takeaways, and a tone label. The output has to fit the UI (TL;DR under 200 chars) and the schema has to be strict enough to render without conditionals.
```ruby
RubyLLM::Contract.configure { } ```
Works with any ruby_llm provider (OpenAI, Anthropic, Gemini, etc). Requires ruby_llm ~> 1.12 and Ruby ≥ 3.2.
Thread-safe / Sidekiq? Yes. Each Step.run builds an isolated RubyLLM::Chat; class-level state (output_schema, validate, retry_policy) is set up once at class load and read-only afterwards. Safe to run from concurrent jobs/threads.
How do I stub Step.run in specs? Include RubyLLM::Contract::RSpec::Helpers and use stub_step(MyStep, response: { ... }). The block form scopes the stub to one it. See testing guide.
Where in a Rails app? Default app/contracts/. The Railtie reloads app/contracts/eval/ and app/steps/eval/ in development; any autoloaded directory also works. See Rails integration.
Upgraded from pre-0.10.0 and getting :limit_exceeded with attachments? Multimodal contracts with max_cost/max_input need attachment_token_estimate. See multimodal input guide for setup, fail-closed behaviour, and on_unknown_attachment_size :warn opt-out.
该项目提供了一个开源 Prompt 模板,用于验证和重试 LLM 输出,适用于 Ruby LLM。虽然该项目有潜在的应用价值,但仍需要进一步优化和测试。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,Ruby LLM 合约验证 在Prompt模板赛道中表现稳健,质量良好。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | ruby_llm-contract |
| Topics | promptaianthropiccost-trackingevalguardrailsruby |
| GitHub | https://github.com/justi/ruby_llm-contract |
| License | MIT |
| 语言 | Ruby |
收录时间:2026-06-12 · 更新时间:2026-06-12 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端