← ClaudeAtlas

dspy-rubylisted

Build type-safe LLM applications with DSPy.rb — Ruby's programmatic prompt framework with signatures, modules, agents, and optimization. Use when implementing predictable AI features, creating LLM signatures and modules, configuring language model providers, building agent systems with tools, optimizing prompts, or testing LLM-powered functionality in Ruby applications.
CodeWithBehnam/cc-docs · ★ 0 · AI & Automation · score 70
Install: claude install-skill CodeWithBehnam/cc-docs
# DSPy.rb > Build LLM apps like you build software. Type-safe, modular, testable. DSPy.rb brings software engineering best practices to LLM development. Instead of tweaking prompts, define what you want with Ruby types and let DSPy handle the rest. ## Overview DSPy.rb is a Ruby framework for building language model applications with programmatic prompts. It provides: - **Type-safe signatures** — Define inputs/outputs with Sorbet types - **Modular components** — Compose and reuse LLM logic - **Automatic optimization** — Use data to improve prompts, not guesswork - **Production-ready** — Built-in observability, testing, and error handling ## Core Concepts ### 1. Signatures Define interfaces between your app and LLMs using Ruby types: ```ruby class EmailClassifier < DSPy::Signature description "Classify customer support emails by category and priority" class Priority < T::Enum enums do Low = new('low') Medium = new('medium') High = new('high') Urgent = new('urgent') end end input do const :email_content, String const :sender, String end output do const :category, String const :priority, Priority # Type-safe enum with defined values const :confidence, Float end end ``` ### 2. Modules Build complex workflows from simple building blocks: - **Predict** — Basic LLM calls with signatures - **ChainOfThought** — Step-by-step reasoning - **ReAct** — Tool-using agents - **CodeAct** — Dynamic code generation