dspy-primitives
Installation
SKILL.md
DSPy Primitives
Guide the user through DSPy's built-in primitive types for multimodal inputs, code handling, and conversation history.
Step 1: Understand the task
Before using primitives, clarify:
- What kind of non-text data? Images, audio, code, or conversation history — each has its own primitive type.
- Does the LM support it natively?
dspy.Imageneeds a vision model (GPT-4o, Claude 3+, Gemini).dspy.Audioneeds an audio model (GPT-4o-audio-preview, Gemini).dspy.Codeanddspy.Historywork with any LM. - Is the data an input, output, or both? All primitives work as both input and output fields, but some patterns are more natural (e.g.,
dspy.Codefor code generation output,dspy.Imagefor image analysis input).
What are primitives
Primitives are DSPy's custom types that go beyond plain strings. They let you pass images, audio, code, files, and conversation history directly into signatures, and capture structured outputs like native reasoning traces. DSPy handles the formatting, encoding, and adapter logic so the LM receives the data in the right format for its provider.
The core primitives: