dspy-ruby

Build type-safe LLM applications in Ruby with DSPy.rb.

24.1k|2.0k|Updated Oct 9, 2025
One-click install
npx skills add https://github.com/EveryInc/compound-engineering-plugin --skill dspy-ruby
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy-ruby
Source: https://github.com/EveryInc/compound-engineering-plugin/tree/main/plugins/compound-engineering/skills/dspy-ruby
Command: npx skills add https://github.com/EveryInc/compound-engineering-plugin --skill dspy-ruby

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

DSPy.rb enables developers to program LLMs, not prompt them. Instead, you define application requirements through type-safe, composable modules that can be tested, optimized, and version-controlled like regular code. It provides guidance on creating type-safe signatures, building modules, configuring multiple LLM providers, and deploying robust AI features in Ruby applications.

Core Features & Use Cases

  • Type-safe Signatures: Input/output contracts with runtime type checking
  • Composable Modules: Reusable, chainable workflows for LLM tasks
  • Multiple Providers: Unified configuration for OpenAI, Anthropic, Gemini, Ollama, and OpenRouter
  • Agents with Tools & Testing: Tool-enabled agents, testing patterns with RSpec, and observability
  • Production Best Practices: Deployment patterns and observability for production AI

Quick Start

  • Install the DSPy Ruby gem and require it in your Ruby project
  • Configure a provider (e.g., OpenAI) with your API key
  • Create a simple Signature and Module, then run a basic forward call in Ruby to validate the workflow

Frequently Asked Questions about dspy-ruby

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build type-safe LLM applications in Ruby?

Type-safe LLM applications in Ruby use DSPy.rb to define input/output contracts through signatures with runtime type checking, compose reusable modules, and test workflows like regular code. Install the gem, configure a provider like OpenAI, create a signature, and validate with a forward call.

Can I use multiple LLM providers in a single Ruby application?

Yes, DSPy.rb supports unified configuration for OpenAI, Anthropic, Gemini, Ollama, and OpenRouter. Switch providers by configuring credentials and selecting the predictor, enabling multi-provider testing and production flexibility without rewriting application logic.

How do I test LLM modules in Ruby with RSpec?

DSPy.rb provides testing patterns and observability tools that integrate with RSpec. Write tests for signatures and modules as you would regular Ruby code, validate type contracts at runtime, and use observability patterns to monitor LLM behavior across multi-step workflows.

What are the different predictor types available for LLM tasks?

DSPy.rb supports multiple predictor types—Predict, ChainOfThought, ReAct, and CodeAct—each suited to different task complexities. Choose based on reasoning requirements: Predict for simple queries, ChainOfThought for multi-step logic, ReAct for tool use, and CodeAct for code generation.

How do I build agents with tools in Ruby?

Tool-enabled agents in DSPy.rb compose modules with tool definitions, allowing LLMs to select and execute actions. Define tool signatures, integrate them into modules, and deploy with error handling and observability patterns for production Ruby applications.

Does DSPy.rb support multimodal inputs?

Yes, DSPy.rb supports multimodal inputs alongside text-based signatures. Configure providers like OpenAI or Claude that handle images and other media types within your type-safe modules and apply the same composability and testing patterns.