Repository: truera/trulens
Issue: [BUG] OpenAIEndpoint Failing ('cached_property' object has no attribute 'completions')
Root cause: Interface Contract Mismatch

**Bug Description**
Getting this error , tried creating 3 different eval systems on llama index having the same provblem on every eval
`Endpoint OpenAIEndpoint request failed 4 time(s): 
	'cached_property' object has no attribute 'completions'
	'cached_property' object has no attribute 'completions'
	'cached_property' object has no attribute 'completions'
	'cached_property' object has no attribute 'completions'
`

**To Reproduce**
```
from trulens.core import TruSession


session = TruSession()
session.reset_database()



import urllib.request

url = "https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt"
file_path = "sample_data/paul_graham_essay.txt"

if not os.path.exists("sample_data"):
    os.makedirs("sample_data")

if not os.path.exists(file_path):
    urllib.request.urlretrieve(url, file_path)




from llama_index.core import Settings
from llama_index.core import SimpleDirectoryReader
from llama_index.core import VectorStoreIndex
from llama_index.llms.openai import OpenAI

Settings.chunk_size = 128
Settings.chunk_overlap = 16
Settings.llm = OpenAI()

documents = SimpleDirectoryReader("sample_data").load_data()
index = VectorStoreIndex.from_documents(documents)

query_engine = index.as_query_engine(similarity_top_k=3)


response = query_engine.query("What did the author do growing up?")
print(response)




import numpy as np
from trulens.apps.llamaindex import TruLlama
from trulens.core import Feedback
from trulens.providers.openai import OpenAI

# Initialize provider class
provider = OpenAI(model_engine="gpt-4.1-mini")

# select context to be used in feedback. the location of context is app specific.

context = TruLlama.select_context(query_engine)

# Define a groundedness feedback function
f_groundedness = (
    Feedback(
        provider.groundedness_measure_with_cot_reasons, name="Groundedness"
    )
    .on(context.collect())  # collect context chunks into a list
    .on_output()
)

# Question/answer relevance between overall question and answer.
f_answer_relevance = Feedback(
    provider.relevance_with_cot_reasons, name="Answer Relevance"
).on_input_output()
# Question/statement relevance between question and each context chunk.
f_context_relevance = (
    Feedback(
        provider.context_relevance_with_cot_reasons, name="Context Relevance"
    )
    .on_input()
    .on(context)
    .aggregate(np.mean)
)

print(f_answer_relevance("What did the author do growing up?", "The author grew up in a small town in the United States."))
print(f_context_relevance("What did the author do growing up?", "The author, growing up, worked on writing and programming outside of school."))

```

**Expected behavior**
It should be giving some sort number on this , for the score

**Relevant Logs/Tracebacks**
```
Traceback (most recent call last):
  File "/Users/nileshteji/Developer/evals/eval-three.py", line 81, in <module>
    print(f_answer_relevance("What did the author do growing up?", "The author grew up in a small town in the United States."))
          ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nileshteji/Developer/evals/venv/lib/python3.13/site-packages/trulens/core/feedback/feedback.py", line 509, in __call__
    return self.imp(*args, **valid_kwargs)
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nileshteji/Developer/evals/venv/lib/python3.13/site-packages/trulens/feedback/llm_provider.py", line 520, in relevance_with_cot_reasons
    return self.generate_score_and_reasons(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        system_prompt=system_prompt,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        temperature=temperature,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/nileshteji/Developer/evals/venv/lib/python3.13/site-packages/trulens/feedback/llm_provider.py", line 160, in generate_score_and_reasons
    response = self.endpoint.run_in_pace(
        func=self._create_chat_completion,
        messages=llm_messages,
        temperature=temperature,
    )
  File "/Users/nileshteji/Developer/evals/venv/lib/python3.13/site-packages/trulens/core/feedback/endpoint.py", line 336, in run_in_pace
    raise RuntimeError(
    ...<2 lines>...
    )
RuntimeError: Endpoint OpenAIEndpoint request failed 4 time(s): 
	'cached_property' object has no attribute 'completions'
	'cached_property' object has no attribute 'completions'
	'cached_property' object has no attribute 'completions'
	'cached_property' object has no attribute 'completions'
```

**Environment:**

- OS: MacOS
- Python Version  3.13.2
- TruLens version  1.4.9
- Versions of other relevant installed libraries
llama-index  0.12.36

**Additional context**
Add any other context about the problem here.


@sfc-gh-pdharmana , can you look into this the team is blocked on this for making a eval system for our inhouse rag system


Hi @nileshteji - this is an issue with python 3.13 and 3.12. Can you downgrade your python to a supported version [3.9,3.11]?

Added a new issue to track 3.13 support also: https://github.com/truera/trulens/issues/1990

Issue exists in 3.9.22 as well

https://github.com/truera/trulens/blob/9ba2b086e43e4d454912f1ffd6707f5a1403ffaa/src/providers/openai/trulens/providers/openai/provider.py#L99

Here is the issue          
completion = self.endpoint.client.chat.completions.create

The cached object is a wrapper on openai hence it can be accessed using self.endpoint.client.client.chat.completions.create

It should only create issue when we are using openai for inference and openai for evaluation.





Thanks for your patience with this - we're looking into it!

https://github.com/truera/trulens/pull/2005 This PR hopefully should resolve the issue for newer python versions

@tech-project-github @nileshteji were you able to try installing from #2005 (now merged in main) to resolve this issue?

@sfc-gh-jreini will try today