What problem does it solve?
DSPy Ruby helps you replace fragile, hand-written prompts with type-safe, composable LLM modules that are easier to build, test, and optimize in real Ruby applications.
Core Features & Use Cases
- Type-safe signatures: Define explicit input/output contracts (including enums) so outputs are validated and predictable for tasks like classification, extraction, and structured analysis.
- Composable modules & pipelines: Build reusable DSPy::Module components that chain together for multi-step workflows such as extract → analyze → respond.
- Predictors and agent patterns: Use DSPy::Predict, ChainOfThought, ReAct tool-using agents, and CodeAct-style code generation patterns when tasks require reasoning, tools, or dynamic execution.
- Provider configuration + multimodal support: Configure OpenAI, Anthropic, Gemini, Ollama, and OpenRouter providers and handle vision inputs via DSPy::Image.
- Testing and optimization: Write RSpec tests for LLM logic, then improve quality using optimization techniques like MIPROv2 and few-shot bootstrapping.
Quick Start
Tell the AI: "Show me how to implement a Ruby DSPy signature and module that classifies customer support emails into category and priority, including an RSpec test and an example DSPy provider configuration."