Skip to content

Commit c33718d

Browse files
authored
Fix example code for Citations (#8868)
1 parent 930632a commit c33718d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dspy/adapters/types/citation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ class Citations(Type):
1616
1717
Example:
1818
```python
19+
import os
1920
import dspy
2021
from dspy.signatures import Signature
2122
from dspy.experimental import Citations, Document
23+
os.environ["ANTHROPIC_API_KEY"] = "YOUR_ANTHROPIC_API_KEY"
2224
2325
class AnswerWithSources(Signature):
2426
'''Answer questions using provided documents with citations.'''
@@ -42,8 +44,8 @@ class AnswerWithSources(Signature):
4244
4345
# Use with a model that supports citations like Claude
4446
lm = dspy.LM("anthropic/claude-opus-4-1-20250805")
45-
predictor = dspy.Predict(AnswerWithSources, lm=lm)
46-
result = predictor(documents=docs, question="What temperature does water boil?")
47+
predictor = dspy.Predict(AnswerWithSources)
48+
result = predictor(documents=docs, question="What temperature does water boil?", lm=lm)
4749
4850
for citation in result.citations.citations:
4951
print(citation.format())

0 commit comments

Comments
 (0)