Skip to content

Commit c435a3f

Browse files
committed
added logic to parse instructions in ReAct signature
1 parent 656b7de commit c435a3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dspy/predict/react.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ def __init__(self, signature, max_iters=5, num_results=3, tools=None):
2828
inputs_ = ", ".join([f"`{k}`" for k in self.input_fields.keys()])
2929
outputs_ = ", ".join([f"`{k}`" for k in self.output_fields.keys()])
3030

31-
instr = [
31+
instr = []
32+
33+
if self.signature.instructions is not None:
34+
instr.append(f"{self.signature.instructions}\n")
35+
36+
instr.extend([
3237
f"You will be given {inputs_} and you will respond with {outputs_}.\n",
3338
"To do this, you will interleave Thought, Action, and Observation steps.\n",
3439
"Thought can reason about the current situation, and Action can be the following types:\n",
35-
]
40+
])
3641

3742
self.tools["Finish"] = dspy.Example(
3843
name="Finish",

0 commit comments

Comments
 (0)