Skip to content

Commit 734a345

Browse files
Merge pull request #579 from SimonB97/patch-1
Update ProgramOfThought.md: Example
2 parents e4e817a + fdef4bd commit 734a345

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/api/modules/ProgramOfThought.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,18 @@ Main method to execute the code generation and refinement process.
8282

8383
```python
8484
#Define a simple signature for basic question answering
85-
generate_answer_signature = dspy.Signature("question -> answer")
86-
generate_answer_signature.attach(question=("Question:", "")).attach(answer=("Answer:", "often between 1 and 5 words"))
85+
class GenerateAnswer(dspy.Signature):
86+
"""Answer questions with short factoid answers."""
87+
question = dspy.InputField()
88+
answer = dspy.OutputField(desc="often between 1 and 5 words")
8789

8890
# Pass signature to ProgramOfThought Module
89-
pot = dspy.ProgramOfThought(generate_answer_signature)
91+
pot = dspy.ProgramOfThought(GenerateAnswer)
9092

9193
#Call the ProgramOfThought module on a particular input
9294
question = 'Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?'
9395
result = pot(question=question)
9496

9597
print(f"Question: {question}")
9698
print(f"Final Predicted Answer (after ProgramOfThought process): {result.answer}")
97-
```
99+
```

0 commit comments

Comments
 (0)