Core Concepts
Understanding DSPy.rb’s core concepts is essential for building reliable LLM applications. This section covers the fundamental building blocks and how they work together.
The Building Blocks
DSPy.rb is built on these main concepts:
Signatures
Define what your LLM operations should do - the inputs and outputs. Think of them as type-safe contracts for AI operations.
Modules
Implement how to achieve what signatures define. Modules are composable units that can be combined to build complex workflows.
Memory
Store and retrieve information across interactions to build stateful agents that remember user preferences and context.
Toolsets
Group related tools in a single class for agent integration. Toolsets provide agents with capabilities like memory operations, file access, and API calls.
Predictors
Connect your modules to language models with different strategies like chain-of-thought reasoning or tool use.
CodeAct
Enable AI agents to dynamically write and execute Ruby code for creative problem-solving.
Examples
Learn from real-world use cases and patterns that demonstrate best practices for common scenarios.
Start Learning
We recommend reading through these concepts in order:
- Start with Signatures to understand input/output contracts
- Move to Modules to learn how to build workflows
- Learn about Memory for stateful agents
- Explore Toolsets for agent capabilities
- Study Predictors for different reasoning strategies
- Learn about CodeAct for dynamic code generation
- Study Examples to see everything in action
Each concept builds on the previous ones, creating a comprehensive framework for LLM development.