Repository: truera/trulens
Issue: [BUG] TruLlama quickstart example fails with Pydantic validation error for queue.Queue object.
Root cause: External Dependency Breakage

**Bug Description**
`ValidationError: 1 validation error for TruLlama
records_with_pending_feedback_results
  Input should be an instance of Queue [type=is_instance_of, input_value=<queue.Queue object at 0x7f1cb6dfdeb0>, input_type=Queue]
    For further information visit https://errors.pydantic.dev/2.7/v/is_instance_of`

**To Reproduce**
Requirments:
`
openai==1.17.0
trulens-eval==0.27.2
llama-index==0.10.28
`
Run the example found here: [https://www.trulens.org/trulens_eval/getting_started/quickstarts/llama_index_quickstart/#initialize-feedback-functions](LlamaIndex Quickstart) up to the block:
`from trulens_eval import TruLlama
tru_query_engine_recorder = TruLlama(query_engine,
    app_id='LlamaIndex_App1',
    feedbacks=[f_groundedness, f_answer_relevance, f_context_relevance])`

**Expected behavior**
Value should be assigned to tru_query_engine_recorder

**Relevant Logs/Tracebacks**
`
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[25], [line 2](vscode-notebook-cell:?execution_count=25&line=2)
      [1](vscode-notebook-cell:?execution_count=25&line=1) from trulens_eval import TruLlama
----> [2](vscode-notebook-cell:?execution_count=25&line=2) tru_query_engine_recorder = TruLlama(query_engine,
      [3](vscode-notebook-cell:?execution_count=25&line=3)     app_id='LlamaIndex_App1',
      [4](vscode-notebook-cell:?execution_count=25&line=4)     feedbacks=[f_groundedness, f_answer_relevance, f_context_relevance])

File /inferences/.venv/lib/python3.8/site-packages/trulens_eval/tru_llama.py:303, in TruLlama.__init__(self, app, **kwargs)
    [300](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/tru_llama.py:300) kwargs['root_class'] = Class.of_object(app)  # TODO: make class property
    [301](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/tru_llama.py:301) kwargs['instrument'] = LlamaInstrument(app=self)
--> [303](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/tru_llama.py:303) super().__init__(**kwargs)

File /inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:548, in App.__init__(self, tru, feedbacks, **kwargs)
    [543](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:543) kwargs['feedbacks'] = feedbacks
    [544](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:544) kwargs['recording_contexts'] = contextvars.ContextVar(
    [545](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:545)     "recording_contexts"
    [546](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:546) )
--> [548](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:548) super().__init__(**kwargs)
    [550](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:550) app = kwargs['app']
    [551](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/app.py:551) self.app = app

File /inferences/.venv/lib/python3.8/site-packages/trulens_eval/schema.py:919, in AppDefinition.__init__(self, app_id, tags, metadata, feedback_mode, app_extra_json, **kwargs)
    [916](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/schema.py:916) kwargs['metadata'] = {}
    [917](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/schema.py:917) kwargs['app_extra_json'] = app_extra_json or dict()
--> [919](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/schema.py:919) super().__init__(**kwargs)
    [921](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/schema.py:921) if app_id is None:
    [922](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/schema.py:922)     app_id = obj_id_of_obj(obj=self.model_dump(), prefix="app")

File /inferences/.venv/lib/python3.8/site-packages/trulens_eval/utils/pyschema.py:686, in WithClassInfo.__init__(self, class_info, obj, cls, *args, **kwargs)
    [682](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/utils/pyschema.py:682)     class_info = Class.of_class(cls, with_bases=True)
    [684](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/utils/pyschema.py:684) kwargs[CLASS_INFO] = class_info
--> [686](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/trulens_eval/utils/pyschema.py:686) super().__init__(*args, **kwargs)

File /inferences/.venv/lib/python3.8/site-packages/pydantic/main.py:175, in BaseModel.__init__(self, **data)
    [173](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/pydantic/main.py:173) # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    [174](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/pydantic/main.py:174) __tracebackhide__ = True
--> [175](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e636573222c226c6f63616c446f636b6572223a66616c73652c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f74616e6e65722d7068696c6c6970732f6465762f696e666572656e6365732f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d-0040ssh-002dremote-002bcloudtops-002dtanner-002dphillips-002epluralsight-002eteleport-002esh.vscode-resource.vscode-cdn.net/inferences/.venv/lib/python3.8/site-packages/pydantic/main.py:175) self.__pydantic_validator__.validate_python(data, self_instance=self)

ValidationError: 1 validation error for TruLlama
records_with_pending_feedback_results
  Input should be an instance of Queue [type=is_instance_of, input_value=<queue.Queue object at 0x7f1cb6dfdeb0>, input_type=Queue]
    For further information visit https://errors.pydantic.dev/2.7/v/is_instance_of
`

**Environment:**
 - OS: Ubuntu
 - Python 3.8.16
openai==1.17.0
trulens-eval==0.27.2
llama-index==0.10.28



<!-- Answer -->
The error you're encountering with the `TruLlama` class initialization seems to stem from the `app` parameter not being an instance of either `BaseQueryEngine` or `BaseChatEngine`. This is required as per the `TruLlama` class's `__init__` method signature. Ensure that the `query_engine` object you're passing to `TruLlama` is correctly instantiated and is of a type that either directly is, or inherits from, `BaseQueryEngine` or `BaseChatEngine`.

If you're following the LlamaIndex Quickstart guide, double-check the instantiation of your `query_engine`. It should be something like this, assuming `VectorStoreIndex.from_documents(documents)` correctly returns an instance of `BaseIndex`, and `index.as_query_engine()` returns an instance of `BaseQueryEngine`:

```python
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

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

query_engine = index.as_query_engine()
```

Then, you can pass `query_engine` to `TruLlama` without encountering a Pydantic validation error:

```python
from trulens_eval import TruLlama

# Assuming query_engine is correctly instantiated as an instance of BaseQueryEngine
tru_recorder = TruLlama(query_engine,
    app_id='LlamaIndex_App1',
    feedbacks=[f_lang_match, f_qa_relevance, f_qs_relevance])
```

Please ensure that the `query_engine` complies with the expected types. If the issue persists, verifying the exact type of `query_engine` and ensuring it matches the expected input for `TruLlama` would be the next steps.

## Sources
- [trulens_eval/trulens_eval/tru_llama.py](https://github.com/truera/trulens/blob/main/trulens_eval/trulens_eval/tru_llama.py)

<!-- Dosu Comment Footer -->
<details>
<summary>

#### About Dosu
</summary>

This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.
</details>


Hi; a fix for this was recently merged to main. You can use the github version or wait until next release in the next couple of days. See https://github.com/truera/trulens/pull/1066 .

Hey @tanner-pluralsight - fix for this is released in 0.28.0!

Please upgrade your trulens-eval version `pip install -U trulens-eval`