Repository: truera/trulens
Issue: TypeError: Object of type 'OpenAI' is not JSON serializable
Root cause: External Dependency Breakage

Hi, get the following output after running "python L4-Auto-merging_Retrieval.py" locally:

`Dashboard started at http://192.168.0.179:8501 .
  Network URL: http://192.168.0.179:8501

  External URL: http://110.141.4.170:8501



Traceback (most recent call last):
  File "/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/L4-Auto-merging_Retrieval.py", line 396, in <module>
    tru_recorder = get_prebuilt_trulens_recorder(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/utils.py", line 66, in get_prebuilt_trulens_recorder
    tru_recorder = TruLlama(
                   ^^^^^^^^^
  File "/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/rag_venv/lib/python3.11/site-packages/trulens_eval/tru_llama.py", line 250, in __init__
    self.post_init()
  File "/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/rag_venv/lib/python3.11/site-packages/trulens_eval/app.py", line 486, in post_init
    self.db.insert_feedback_definition(f)
  File "/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/rag_venv/lib/python3.11/site-packages/trulens_eval/database/utils.py", line 61, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/rag_venv/lib/python3.11/site-packages/trulens_eval/database/sqlalchemy_db.py", line 195, in insert_feedback_definition
    _fb_def.app_json = feedback_definition.json()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pydantic/main.py", line 504, in pydantic.main.BaseModel.json
  File "/usr/lib/python3.11/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "pydantic/json.py", line 90, in pydantic.json.pydantic_encoder
TypeError: Object of type 'OpenAI' is not JSON serializable
/home/andrew/Documents/deeplearning-ai/building_and_evaluating_advanced_rag_applications/rag_venv/lib/python3.11/site-packages/langchain/__init__.py:34: UserWarning: Importing PromptTemplate from langchain root module is no longer supported. Please use langchain.prompts.PromptTemplate instead.`

Running Ubuntu 22.04.3 LTS, Python 3.11.6, trulens_eval 0.18.1, code from course "https://learn.deeplearning.ai/building-evaluating-advanced-rag/lesson/5/auto-merging-retrieval".

Thanks @wfs ! This was fixed in trulens_eval==0.18.2. Can you try upgrading?

Hi, unfortunately the students have had to downgrade to 0.18.1 as running course scripts locally reveals package dependency issues that can't be resolved when running 0.18.2 - https://community.deeplearning.ai/t/building-and-evaluating-advanced-rag-applications-implementing-it-off-platform/508608

What dependency issues are you having in 0.18.2? Don't think we added any restrictions (in fact we loosened some requirements) in 18.2)

Thanks. Created new venv and installed requirements 1-by-1 as prompted as ran each lesson script. Wasn't able to reproduce dependencies issues using 0.18.2 which is great. Here are the install commands that may assist others:
- 2082  mkdir rag_trulens_eval-0.18.2_venv
- 2088  python3 -m venv rag_trulens_eval-0.18.2_venv/
- 2089  source rag_trulens_eval-0.18.2_venv/bin/activate
- 2090  python L1-Advanced_RAG_Pipeline.py 
-- Python 3.10.12
- 2092  pip install python-dotenv 
- 2093  python L1-Advanced_RAG_Pipeline.py 
- 2095  pip install numpy
- 2096  python L1-Advanced_RAG_Pipeline.py 
- 2097  pip install trulens-eval
-- v 0.18.2
- 2098  python L1-Advanced_RAG_Pipeline.py 
- 2100  pip install pypdf
- 2101  python L1-Advanced_RAG_Pipeline.py 
- 2103  pip install torch
- 2104  python L1-Advanced_RAG_Pipeline.py 
- 2106  pip install torch sentence-transformers
- 2107  python L1-Advanced_RAG_Pipeline.py 
- 2108  python L2-RAG_Triad_of_metrics.py 
- 2109  python L3-Sentence_window_retrieval.py 
- 2110  python L4-Auto-merging_Retrieval.py 

Thanks @wfs !