DSPy: The framework for programming—not prompting—language models
Python
Refactor exception handling in ReAct class
Tom Dörrdaedd430c9cc
diff --git a/dspy/predict/react.py b/dspy/predict/react.pyindex 5077d7219..feda67aec 100644--- a/dspy/predict/react.py+++ b/dspy/predict/react.py@@ -95,7 +95,7 @@ class ReAct(Module):# Handle the case where 'passages' attribute is missingoutput[f"Observation_{hop+1}"] = getattr(result, "passages", result)- except Exception as e:+ except Exception:output[f"Observation_{hop+1}"] = ("Failed to parse action. Bad formatting or incorrect action name.")