Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Everything seems to be correct but yet getting "AttributeError: id" when trulens is instrumenting the classes #1704

Open
masdeval opened this issue Dec 22, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@masdeval
Copy link

Bug Description

getattr_static method of python3.10/inspect.py raising exception: AttributeError: id

This method in turn is called by the method trulens//core/utils/python -> safe_getattr()

To Reproduce
Which steps should someone take to run into the same error? A small, reproducible code example is useful here.

It looks like the problem is with the retriever. I am using langchain_community.embeddings.HuggingFaceEmbeddings as a wrapper for a local SentenceTransformer downloaded in my machine.

I am using langchain_community.vectorstores.FAISS initialized with this embedding as the retriever.

I am running a common langchain chain:

rag_chain = ( {"context": self.retriever | self.format_docs, "question": RunnablePassthrough()} | prompt | llm | StrOutputParser() )

If I run the trulens quickstart example for langchain in this same environment it works fine.

Expected behavior

It should run the chain, collect the metrics and start the dashboard.

Relevant Logs/Tracebacks

calling <function RunnableSequence.invoke at 0x7ff8c2e82f80> with ({
context: VectorStoreRetriever(tags=['FAISS', 'HuggingFaceEmbeddings'], vectorstore=<langchain_community.vectorstores.faiss.FAISS object at 0x7ff7628302e0>, search_kwargs={'k': 20})
| RunnableLambda(format_docs),
question: RunnablePassthrough()
}
| PromptTemplate(input_variables=['context', 'question'], input_types={}, partial_variables={}, template="Use the following pieces of context to answer the question at the end.\n If you don't know the answer, just say that you don't know, don't try to make up an answer.\n Keep the answer as concise as possible. The language is brazilian portuguese. \n {context}\n Question: {question}\n Helpful Answer:")
| ChatOpenAI(client=<openai.resources.chat.completions.Completions object at 0x7ff762832a40>, async_client=<openai.resources.chat.completions.AsyncCompletions object at 0x7ff7627f6920>, root_client=<openai.OpenAI object at 0x7ff762830070>, root_async_client=<openai.AsyncOpenAI object at 0x7ff762832a10>, model_name='gpt-3.5-turbo-1106', temperature=0.0, model_kwargs={}, openai_api_key=SecretStr('**********'))
| StrOutputParser(), 'Qual o problema relacionado com o aumento da contrucao de edificios?')
calling <function RunnableParallel.invoke at 0x7ff8c2e83d00> with ({
context: VectorStoreRetriever(tags=['FAISS', 'HuggingFaceEmbeddings'], vectorstore=<langchain_community.vectorstores.faiss.FAISS object at 0x7ff7628302e0>, search_kwargs={'k': 20})
| RunnableLambda(format_docs),
question: RunnablePassthrough()
}, 'Qual o problema relacionado com o aumento da contrucao de edificios?', {'tags': [], 'metadata': {}, 'callbacks': <langchain_core.callbacks.manager.CallbackManager object at 0x7ff763c0c4f0>, 'recursion_limit': 25, 'configurable': {}})
calling <function RunnableSequence.invoke at 0x7ff8c2e82f80> with (VectorStoreRetriever(tags=['FAISS', 'HuggingFaceEmbeddings'], vectorstore=<langchain_community.vectorstores.faiss.FAISS object at 0x7ff7628302e0>, search_kwargs={'k': 20})
| RunnableLambda(format_docs), 'Qual o problema relacionado com o aumento da contrucao de edificios?', {'tags': [], 'metadata': {}, 'callbacks': <langchain_core.callbacks.manager.CallbackManager object at 0x7ff763c0c220>, 'recursion_limit': 25, 'configurable': {}})
calling <function BaseRetriever.invoke at 0x7ff8c229c790> with (VectorStoreRetriever(tags=['FAISS', 'HuggingFaceEmbeddings'], vectorstore=<langchain_community.vectorstores.faiss.FAISS object at 0x7ff7628302e0>, search_kwargs={'k': 20}), 'Qual o problema relacionado com o aumento da contrucao de edificios?', {'tags': [], 'metadata': {}, 'callbacks': <langchain_core.callbacks.manager.CallbackManager object at 0x7ff763c0ded0>, 'recursion_limit': 25, 'configurable': {}})
calling <function VectorStoreRetriever._get_relevant_documents at 0x7ff8c229e560> with (VectorStoreRetriever(tags=['FAISS', 'HuggingFaceEmbeddings'], vectorstore=<langchain_community.vectorstores.faiss.FAISS object at 0x7ff7628302e0>, search_kwargs={'k': 20}), 'Qual o problema relacionado com o aumento da contrucao de edificios?')
calling <function RunnablePassthrough.invoke at 0x7ff8c2d89fc0> with (RunnablePassthrough(), 'Qual o problema relacionado com o aumento da contrucao de edificios?', {'tags': [], 'metadata': {}, 'callbacks': <langchain_core.callbacks.manager.CallbackManager object at 0x7ff763c0ee60>, 'recursion_limit': 25, 'configurable': {}})
Traceback (most recent call last):
File "/home/chris/ml_projects/RAG Langchain/rag_evaluation.py", line 105, in
llm_response = chain.invoke(question)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 858, in update_call_info
records[ctx] = ctx.app.on_add_record(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/app.py", line 1237, in on_add_record
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
input = context.run(step.invoke, input, config, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3727, in invoke
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3727, in
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/_base.py", line 458, in result
return self.__get_result()
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3711, in _invoke_step
return context.run(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
input = context.run(step.invoke, input, config, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/retrievers.py", line 266, in invoke
raise e
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/retrievers.py", line 259, in invoke
result = self._get_relevant_documents(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 830, in update_call_info
rets=json_utils.jsonify(rets),
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 306, in jsonify
for x in (recur(v) for v in obj):
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 306, in
for x in (recur(v) for v in obj):
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 273, in recur
return jsonify(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 327, in jsonify
forward_value.update({
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 328, in
k: recur(python_utils.safe_getattr(obj, k))
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/python.py", line 180, in safe_getattr
v = inspect.getattr_static(obj, k)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/inspect.py", line 1769, in getattr_static
raise AttributeError(attr)
AttributeError: id
python-BaseException
Traceback (most recent call last):
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 2270, in
main()
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 2252, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 1563, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/chris/ml_projects/RAG Langchain/rag_evaluation.py", line 104, in
with tru_recorder as recording:
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/app.py", line 1079, in exit
raise exc_value
File "/home/chris/ml_projects/RAG Langchain/rag_evaluation.py", line 105, in
llm_response = chain.invoke(question)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 858, in update_call_info
records[ctx] = ctx.app.on_add_record(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/app.py", line 1237, in on_add_record
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
input = context.run(step.invoke, input, config, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3727, in invoke
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3727, in
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/_base.py", line 458, in result
return self.__get_result()
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3711, in _invoke_step
return context.run(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
input = context.run(step.invoke, input, config, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/retrievers.py", line 266, in invoke
raise e
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/retrievers.py", line 259, in invoke
result = self._get_relevant_documents(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 830, in update_call_info
rets=json_utils.jsonify(rets),
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 306, in jsonify
for x in (recur(v) for v in obj):
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 306, in
for x in (recur(v) for v in obj):
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 273, in recur
return jsonify(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 327, in jsonify
forward_value.update({
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 328, in
k: recur(python_utils.safe_getattr(obj, k))
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/python.py", line 180, in safe_getattr
v = inspect.getattr_static(obj, k)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/inspect.py", line 1769, in getattr_static
raise AttributeError(attr)
AttributeError: id
python-BaseException
Traceback (most recent call last):
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 2270, in
main()
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 2252, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 1563, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/chris/pycharm-community-2024.3.1.1/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/chris/ml_projects/RAG Langchain/rag_evaluation.py", line 104, in
with tru_recorder as recording:
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/app.py", line 1079, in exit
raise exc_value
File "/home/chris/ml_projects/RAG Langchain/rag_evaluation.py", line 105, in
llm_response = chain.invoke(question)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 858, in update_call_info
records[ctx] = ctx.app.on_add_record(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/app.py", line 1237, in on_add_record
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
input = context.run(step.invoke, input, config, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3727, in invoke
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3727, in
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/_base.py", line 458, in result
return self.__get_result()
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3711, in _invoke_step
return context.run(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
input = context.run(step.invoke, input, config, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 874, in update_call_info
raise error
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 772, in tru_wrapper
rets, tally = core_endpoint.Endpoint.track_all_costs_tally(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 589, in track_all_costs_tally
result, cbs = Endpoint.track_all_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 551, in track_all_costs
return Endpoint._track_costs(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/feedback/endpoint.py", line 666, in _track_costs
result: T = __func(*args, **kwargs)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/retrievers.py", line 266, in invoke
raise e
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/langchain_core/retrievers.py", line 259, in invoke
result = self._get_relevant_documents(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 930, in tru_wrapper
return rewrap(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 914, in rewrap
rets = ctx.app.wrap_lazy_values(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 150, in wrap_lazy_values
return on_done(rets)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/instruments.py", line 830, in update_call_info
rets=json_utils.jsonify(rets),
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 306, in jsonify
for x in (recur(v) for v in obj):
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 306, in
for x in (recur(v) for v in obj):
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 273, in recur
return jsonify(
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 327, in jsonify
forward_value.update({
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/json.py", line 328, in
k: recur(python_utils.safe_getattr(obj, k))
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/site-packages/trulens/core/utils/python.py", line 180, in safe_getattr
v = inspect.getattr_static(obj, k)
File "/home/chris/anaconda3/envs/trulens-env/lib/python3.10/inspect.py", line 1769, in getattr_static
raise AttributeError(attr)
AttributeError: id

Environment:

  • OS: Ubuntu
  • Python Version: 3.10
  • TruLens version: 1.2.11
  • Versions of other relevant installed libraries

Additional context
Add any other context about the problem here.

@masdeval masdeval added the bug Something isn't working label Dec 22, 2024
@masdeval masdeval changed the title [BUG] Everything seems to be correct but yet getting "AttributeError: id" when trulens is instrumenting the classes Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants