DSPy: The framework for programming—not prompting—language models
Python
fix(dspy) fix issue 804
Lawrence Pang4d8178f3dced
diff --git a/dspy/predict/react.py b/dspy/predict/react.pyindex a465ee710..cedd49c77 100644--- a/dspy/predict/react.py+++ b/dspy/predict/react.py@@ -91,12 +91,9 @@ class ReAct(Module):if action_name == "Finish":return action_val- try:- output[f"Observation_{hop+1}"] = self.tools[action_name](action_val).passages- except AttributeError:- # Handle the case where 'passages' attribute is missing- # TODO: This is a hacky way to handle this. Need to fix this.- output[f"Observation_{hop+1}"] = self.tools[action_name](action_val)+ result = self.tools[action_name](action_val)+ # Handle the case where 'passages' attribute is missing+ output[f"Observation_{hop+1}"] = getattr(result, "passages", result)except Exception as e:output[f"Observation_{hop+1}"] = (