- Home
- Skills
- Omidzamani
- Dspy Skills
- Dspy Signature Designer
dspy-signature-designer_skill
- Python
26
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill omidzamani/dspy-skills --skill dspy-signature-designer- SKILL.md7.5 KB
Overview
This skill helps design clear, type-safe DSPy signatures to define what a DSPy module expects and returns. It guides creation of inline and class-based signatures, adding InputField/OutputField definitions, type hints, and optional Pydantic models for structured validation.
How this skill works
It inspects a task description and lists of input/output fields and type constraints, then generates a dspy.Signature class (or inline signature) with InputField and OutputField annotations. The skill can include Literal constraints, Optional types, collection hints, Pydantic models for nested structures, and validation constraints like min/max or ge/le. It also produces docstrings and field descriptions to guide model behavior.
When to use it
- Defining a new DSPy module or wrapping an LLM task with a signature
- When outputs must be structured, validated, or type-safe
- Designing multi-field responses or complex input/output relationships
- Adding Pydantic models to represent nested or record-like outputs
- Converting informal task descriptions into explicit DSPy inputs/outputs
Best practices
- Write a descriptive class docstring — it becomes the task instruction
- Use dspy.InputField.desc and OutputField.desc to guide the model
- Constrain categorical outputs with typing.Literal for safety
- Provide sensible defaults for optional inputs; validate outputs in forward()
- Use Pydantic models for complex nested types and post-run validation
Example use cases
- Summarization signature: document -> list[str] summary + word_count
- Entity extraction: text -> List[Entity] where Entity is a Pydantic model
- Sentiment analysis: text -> sentiment (Literal) + score + aspects + reasoning
- RAG answer module: context:list[str], question -> answer, confidence, source_passage
- Multi-label classifier returning categories list and a primary_category
FAQ
Use inline signatures for simple inputs/outputs and quick prototypes. Choose class-based signatures when you need multiple fields, type constraints, descriptions, defaults, or Pydantic models for nested structures.
How do I enforce categorical outputs?
Annotate the output with typing.Literal and dspy.OutputField. Literal restricts possible values and helps the model produce constrained categories.