Skip to content

Commit

Permalink
Implement argument name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
krypticmouse committed Apr 13, 2024
1 parent bcaf13d commit 8bf4aa8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dspy/functional/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self):
self.__dict__[name] = attr.copy()


def TypedChainOfThought(signature, instructions=None, rationale_type=None, *, max_retries=3) -> dspy.Module: # noqa: N802
def TypedChainOfThought(signature, instructions=None, reasoning=None, *, max_retries=3) -> dspy.Module: # noqa: N802
"""Just like TypedPredictor, but adds a ChainOfThought OutputField."""
signature = ensure_signature(signature, instructions)
output_keys = ", ".join(signature.output_fields.keys())
Expand All @@ -62,12 +62,12 @@ def TypedChainOfThought(signature, instructions=None, rationale_type=None, *, ma
prefix="Reasoning: Let's think step by step in order to",
desc="${produce the " + output_keys + "}. We ...",
)
rationale_type = rationale_type or DEFAULT_RATIONALE
reasoning = reasoning or DEFAULT_RATIONALE

return TypedPredictor(
signature.prepend(
"reasoning",
rationale_type,
reasoning,
),
max_retries=max_retries,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,20 +619,20 @@ class ScoredSignature(dspy.Signature):
Proposed Signature: Output""")


def test_custom_rationale_type():
def test_custom_reasoning_field():
class Question(pydantic.BaseModel):
value: str

class QuestionSignature(dspy.Signature):
topic: str = dspy.InputField()
question: Question = dspy.OutputField()

rationale_type = dspy.OutputField(
reasoning = dspy.OutputField(
prefix="Custom Reasoning: Let's break this down. To generate a question about",
desc="${topic}, we should ...",
)

program = TypedChainOfThought(QuestionSignature, rationale_type=rationale_type)
program = TypedChainOfThought(QuestionSignature, reasoning=reasoning)

expected = "What is the speed of light?"
lm = DummyLM(["Thoughts", f'{{"value": "{expected}"}}'])
Expand Down

0 comments on commit 8bf4aa8

Please sign in to comment.