What problem does it solve?
DSPy.rb prevents brittle prompt experimentation by letting Ruby developers define LLM interactions through type-safe signatures, modular components, and deterministic configurations so every output is predictable and testable.
Core Features & Use Cases
- Type-safe Signatures: Declare inputs and outputs with Sorbet types, enums, and structs so LLM responses deserialize into strongly typed Ruby objects.
- Modular Workflows: Compose Predict, ChainOfThought, ReAct, and CodeAct modules with lifecycle callbacks, fiber-local LM overrides, and configurable toolsets for complex agent scenarios.
- Optimization & Observability: Integrate MIPROv2, GEPA, and Langfuse-ready telemetry plus structured evaluation metrics to improve prompts, trace runs, and report scores.
- Use Case: Embed DSPy into a Rails app to classify support emails, route actions, rerank results, and optimize each predictor with real data and feature-flagged model selection.
Quick Start
Connect your Ruby project to DSPy by installing the gem, configuring DSPy::LM with RubyLLM or provider adapters, and invoking the predictor with DSPy::Predict to classify text.