From c26988cc04b68343d20a4a3e8c5dc4f797bf2c8e Mon Sep 17 00:00:00 2001 From: Piotr Mardziel Date: Fri, 22 Dec 2023 16:26:07 -0500 Subject: [PATCH] first (#720) --- trulens_eval/trulens_eval/instruments.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/trulens_eval/trulens_eval/instruments.py b/trulens_eval/trulens_eval/instruments.py index 227c4097a..87d0d67f1 100644 --- a/trulens_eval/trulens_eval/instruments.py +++ b/trulens_eval/trulens_eval/instruments.py @@ -807,6 +807,13 @@ def find_instrumented(f): # instrumented app gets unloaded, it will be evicted from this set. setattr(w, Instrument.APPS, weakref.WeakSet([self.app])) + # Hack for llama_index trace_method not preserving wrapped method signature. + if "trace_method..decorator..wrapper" == func.__qualname__: + actual_func = func.__closure__[1].cell_contents + func_sig = inspect.signature(actual_func) + func.__signature__ = func_sig + func.__name__ = actual_func.__name__ + w.__name__ = func.__name__ # NOTE(piotrm): This is important; langchain checks signatures to adjust