Repository: truera/trulens
Issue: [BUG]AttributeError when serializing Feedback with Pydantic >=2.10 (TruLens 2.5.0)
Root cause: External Dependency Breakage

**Bug Description**
I run feedback based on the record saved to the database when running the Agent before.
I get this error even though I didn't get it before.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\\trulens_evaluate\run_agent\mock_run_summarizer.py", line 5, in <module>
    from trulens_evaluate.eval.mock_feedback_functions import (
  File "D:\\trulens_evaluate\eval\mock_feedback_functions.py", line 36, in <module>
    f_groundtruth = Feedback(
                    ^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\feedback\feedback.py", line 304, in __init__
    super().__init__(**kwargs)
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\schema\feedback.py", line 431, in __init__
    self.model_dump(), prefix="feedback_definition"
    ^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\serial.py", line 595, in model_dump
    return jsonify(self, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 274, in recur
    return jsonify(
           ^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\tru\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 274, in recur
    return jsonify(
           ^^^^^^^^
\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 274, in recur
\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 329, in jsonify
    k: recur(python_utils.safe_getattr(obj, k))
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 274    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    k: recur(python_utils.safe_getattr(obj, k))
    k: recur(python_utils.safe_getattr(obj, k))
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    k: recur(python_utils.safe_getattr(obj, k))
    k: recur(python_utils.safe_getattr(obj, k))
    k: recur(python_utils.safe_getattr(obj, k))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 274, in recur
    return jsonify(
           ^^^^^^^^
  File "C:\Users\\AppData\Local\pypoetry\Cache\virtualenvs\-SIeRiuXK-py3.12\Lib\site-packages\trulens\core\utils\json.py", line 334, in jsonify
    for k, _ in type(obj).model_computed_fields.items():
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'property' object has no attribute 'items'
Relevant part of stack trace:
File "trulens/core/utils/json.py", line 334, in jsonify
    for k, _ in type(obj).model_computed_fields.items():
AttributeError: 'property' object has no attribute 'items'

ground_truth_collection = GroundTruthAgreement(golden_set, provider=provider)

f_groundtruth = Feedback(
    ground_truth_collection.agreement_measure, name="Similarity (LLM)"
).on_input_output()

f_bert_score = Feedback(ground_truth_collection.bert_score).on_input_output()

f_bleu = Feedback(ground_truth_collection.bleu).on_input_output()

f_rouge = Feedback(ground_truth_collection.rouge).on_input_output()

**Environment:**

- OS: [e.g. MacOS, Windows]
- Python Version: 3.12.0
- TruLens version: 2.5.0
- Versions of other relevant installed libraries: pydantic > 2.10

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


Hi, TruLens team, please help me fix the issue. Thank you so much.

<!-- Answer -->
This error is caused by an incompatibility between TruLens 2.5.0 and Pydantic >=2.10. In newer Pydantic versions, model_computed_fields is a property, not a dictionary, which breaks TruLens serialization code. This is a known issue and has been discussed in several threads, especially around Python 3.12+ and recent Pydantic releases [[1]](https://github.com/truera/trulens/issues/1990).

To resolve this, you have a few options:

- If possible, downgrade Pydantic to a version below 2.10, which is known to work with TruLens 2.5.0.
- Alternatively, check if there is a newer release of TruLens that addresses this compatibility issue. There are ongoing efforts to patch these problems in the main branch [[2]](https://github.com/truera/trulens/issues/1987).
- Manual code patches to property handling in TruLens have been attempted, but they may not fully resolve the issue and could introduce instability [[1]](https://github.com/truera/trulens/issues/1990).

If you need to keep using Python 3.12 and Pydantic >=2.10, upgrading TruLens (if a newer version is available) is the safest path. Otherwise, downgrading Pydantic should unblock you.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0aeefd14-af8e-40a7-a390-c0401d560bfb?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e16d1378-a540-46b6-bd0e-816c493d2aee/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/truera/trulens/issues/2294)

Hi @duonghonglam0805 - this bug is addressed in the latest release. Please upgrade and give it a try, and re-open if the issue persisfs