dspy icon indicating copy to clipboard operation
dspy copied to clipboard

ReAct doesn't return actions executed

Open luonist opened this issue 5 months ago • 1 comments

It would be nice to have ReAct returning the actions in the response, to know which tools were used to generate the answer. As now, ReAct only returns the observations, which are the results obtained from the tools. It should be enough to add the following line to the forward() method:

actions = [args[key] for key in args if key.startswith("Action")]

and then to add the actions key in the return, like this:

return dspy.Prediction(observations=observations, actions=actions, **{list(self.output_fields.keys())[0]: action_val or ""})

luonist avatar Sep 13 '24 08:09 luonist