DSPy: The framework for programming—not prompting—language models
Python
Change how `forward` is patched to avoid warning on explicit `forward` call (#8700)
Chen Qian8388495d8809
diff --git a/dspy/teleprompt/bootstrap_trace.py b/dspy/teleprompt/bootstrap_trace.pyindex 9f1eff5db..5af24223c 100644--- a/dspy/teleprompt/bootstrap_trace.py+++ b/dspy/teleprompt/bootstrap_trace.py@@ -55,7 +55,9 @@ def bootstrap_trace_data(return prediction.format_reward or format_failure_scorereturn metric(example, prediction, trace) if metric else True- original_forward = program.forward+ # Use `object.__getattribute__` to bypass the custom hook `Module.__getattribute__` so that we avoid+ # the warning that `forward` is not accessed through `__call__`.+ original_forward = object.__getattribute__(program, "forward")def patched_forward(program_to_use: Module, **kwargs):with dspy.context(trace=[]):