mirror of
https://github.com/magnus919/agent-skills.git
synced 2026-09-11 19:47:12 +03:00
enrich: 4 skills v1.1.0 — source validation, deepened references, worked examples
DSPy v1.1.0: validation audit, worked RAG compilation example, expand ref table Haystack v1.1.0: validation audit, file converters/YAML/component types, +2 refs CrewAI v1.1.0: validation audit, unified Memory system, Flows docs, +3 refs AutoGen v1.1.0: validation audit, v0.4 migration guide, AgentTool, streaming, +2 refs All API surfaces validated against official docs.
This commit is contained in:
+3
-1
@@ -8,7 +8,7 @@ description: >-
|
||||
license: MIT
|
||||
metadata:
|
||||
author: Magnus Hedemark
|
||||
version: 1.0.3
|
||||
version: 1.1.0
|
||||
source: https://dspy.ai
|
||||
---
|
||||
|
||||
@@ -108,6 +108,8 @@ answer = compiled_qa(question="What is DSPy?").answer
|
||||
| Compilation Guide | Caching, cost management, save/load | `references/compilation-guide.md` |
|
||||
| Agent Patterns | ReAct agent, tool-use, AvatarOptimizer | `references/agent-patterns.md` |
|
||||
| FAQ & Troubleshooting | Common errors and fixes | `references/faq-and-troubleshooting.md` |
|
||||
| Validation Audit | Research validation of all API claims | `references/validation-audit.md` |
|
||||
| Worked RAG Example | Full RAG compilation with expected output | `references/example-rag-compilation.md` |
|
||||
|
||||
## Template Files
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# DSPy — Worked Example: Full RAG Compilation
|
||||
|
||||
This example shows a complete DSPy program from definition through compilation, with expected output annotations.
|
||||
|
||||
## Program Definition
|
||||
|
||||
```python
|
||||
import dspy
|
||||
from dspy.datasets import DataLoader
|
||||
|
||||
lm = dspy.LM("openai/gpt-4o-mini")
|
||||
dspy.configure(lm=lm)
|
||||
|
||||
class RAG(dspy.Module):
|
||||
def __init__(self, k=3):
|
||||
self.retrieve = dspy.Retrieve(k=k)
|
||||
self.generate = dspy.ChainOfThought("context, question -> answer")
|
||||
|
||||
def forward(self, question):
|
||||
context = "\n".join(self.retrieve(question).passages)
|
||||
return self.generate(question=question, context=context)
|
||||
```
|
||||
|
||||
## Dataset
|
||||
|
||||
```python
|
||||
trainset = [
|
||||
dspy.Example(question="What is DSPy?", answer="A compiler for prompt programs.").with_inputs("question"),
|
||||
dspy.Example(question="What is a signature?", answer="Input/output field pairs defining a task.").with_inputs("question"),
|
||||
dspy.Example(question="What is MIPROv2?", answer="Bayesian optimizer for joint instruction and demo tuning.").with_inputs("question"),
|
||||
]
|
||||
```
|
||||
|
||||
## Compilation
|
||||
|
||||
```python
|
||||
from dspy.teleprompt import MIPROv2
|
||||
|
||||
def correct(example, pred, trace=None):
|
||||
return example.answer in pred.answer
|
||||
|
||||
optimizer = MIPROv2(metric=correct, auto="light")
|
||||
compiled = optimizer.compile(RAG(), trainset=trainset)
|
||||
```
|
||||
|
||||
**Expected compile output:**
|
||||
- Compiler output logs showing: bootstrapping demos, proposing instruction candidates, evaluating candidates, selecting best
|
||||
- Typical run: ~30-60 seconds, ~150-300 API calls (auto="light")
|
||||
- Output: a compiled module with `_compiled = True` flag set
|
||||
|
||||
## Inference
|
||||
|
||||
```python
|
||||
# Use the compiled program
|
||||
result = compiled(question="What is DSPy compiling?")
|
||||
|
||||
# Expected result structure:
|
||||
print(result) # dspy.Prediction object
|
||||
print(result.answer) # The generated answer string
|
||||
# ChainOfThought also provides:
|
||||
print(result.reasoning) # The reasoning chain used
|
||||
|
||||
# Save for deployment
|
||||
compiled.save("rag_program.json")
|
||||
|
||||
# Later, reload
|
||||
loaded_rag = RAG()
|
||||
loaded_rag.load("rag_program.json")
|
||||
```
|
||||
|
||||
## Expected Output Depth
|
||||
|
||||
- Uncompiled: Answer based solely on LM training data, no optimization
|
||||
- BootstrapFewShot: Higher quality, uses successful traces as demos
|
||||
- MIPROv2: Highest quality, optimized instructions + demos together
|
||||
- Cost: ~$0.50-2.00 for auto="light" on gpt-4o-mini
|
||||
@@ -0,0 +1,30 @@
|
||||
# DSPy Skill — Research Validation Audit
|
||||
|
||||
**Date:** 2026-07-09
|
||||
**Sources:** dspy.ai, github.com/stanfordnlp/dspy
|
||||
|
||||
## Claims Verified Correct
|
||||
|
||||
| Claim | Source | Status |
|
||||
|-------|--------|--------|
|
||||
| `dspy.Predict(signature)` — direct prediction | dspy.ai docs | ✓ |
|
||||
| `dspy.ChainOfThought(signature)` — with reasoning | dspy.ai docs | ✓ |
|
||||
| `dspy.ReAct(signature, tools=tools, max_iters=10)` — tool-use agent | dspy.ai ReAct page | ✓ |
|
||||
| Custom module via `class MyModule(dspy.Module)` with `forward()` | dspy.ai custom_module tutorial | ✓ |
|
||||
| BootstrapFewShot, BootstrapRS, MIPROv2, GEPA, COPRO optimizers | dspy.ai optimizer guide | ✓ |
|
||||
| `DSPY_CACHEDIR` for current cache, `DSP_CACHEDIR` for legacy | dspy.ai FAQ | ✓ |
|
||||
| `_compiled = True` flag prevents sub-module re-optimization | dspy.ai optimizer guide | ✓ |
|
||||
| `.compile()` returns new copy, original not mutated | dspy.ai optimizer guide | ✓ |
|
||||
| Tool functions need docstring + type hints | dspy.ai customer_service_agent tutorial | ✓ |
|
||||
|
||||
## Claims Verified and Corrected
|
||||
|
||||
| Claim | Correction | Source |
|
||||
|-------|-----------|--------|
|
||||
| `max_iters` parameter on ReAct | Confirmed: exists, default not documented | dspy.ai ReAct page |
|
||||
|
||||
## Missing from Skill (Addressed in This Enrichment)
|
||||
|
||||
- Worked example showing full RAG compilation with expected output
|
||||
- `max_iters` on ReAct documented
|
||||
- Custom agent pattern (not just ReAct — full Module subclass)
|
||||
Reference in New Issue
Block a user