Skip to content

Commit 997b1d8

Browse files
committed
Add note: Thoughts and Planned Improvements for dspy.ReAct
1 parent 28dea46 commit 997b1d8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

dspy/predict/react.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,39 @@ def format(trajectory_: dict[str, Any], last_iteration: bool):
9797

9898
extract = self.extract(**input_args, trajectory=format(trajectory, last_iteration=False))
9999
return dspy.Prediction(trajectory=trajectory, **extract)
100+
101+
102+
"""
103+
Thoughts and Planned Improvements for dspy.ReAct.
104+
105+
TOPIC 01: How Trajectories are Formatted, or rather when they are formatted.
106+
107+
Right now, both sub-modules are invoked with a `trajectory` argument, which is a string formatted in `forward`. Though
108+
the formatter uses a general adapter.format_fields, the tracing of DSPy only sees the string, not the formatting logic.
109+
110+
What this means is that, in demonstrations, even if the user adjusts the adapter for a fixed program, the demos' format
111+
will not update accordingly, but the inference-time trajectories will.
112+
113+
One way to fix this is to support `format=fn` in the dspy.InputField() for "trajectory" in the signatures. But this
114+
means that care must be taken that the adapter is accessed at `forward` runtime, not signature definition time.
115+
116+
Another potential fix is to more natively support a "variadic" input field, where the input is a list of dictionaries,
117+
or a big dictionary, and have each adatper format it accordingly.
118+
119+
120+
TOPIC 02: Handling default arguments in the Tool class.
121+
122+
123+
TOPIC 03: Simplifying ReAct's __init__ by moving modular logic to the Tool class.
124+
* Handling descriptions and casting.
125+
* Handling exceptions and error messages.
126+
* More cleanly defining the "finish" tool, perhaps as a runtime-defined function?
127+
128+
129+
TOPIC 04: Default behavior when the trajectory gets too long.
130+
131+
132+
TOPIC 05: Adding more structure around how the instruction is formatted.
133+
* Concretely, it's now a string, so an optimizer can and does rewrite it freely.
134+
* An alternative would be to add more structure, such that a certain template is fixed but values are variable?
135+
"""

0 commit comments

Comments
 (0)