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