Find answers from the community

Updated 3 months ago

Option 1 Error AttributeError FieldInfo

Option 1 Error: AttributeError: 'FieldInfo' object has no attribute 'as_trace'

This has to do with the callback_manager

Option 2 Error: AttributeError: 'FieldInfo' object has no attribute 'as_trace' and TypeError: BaseModel.validate() takes 2 positional arguments but 3 were given
L
j
27 comments
I just ran the notebook, both option 1 and option 2 work
Do you have the latest version of llama-index? Whats the full error, maybe it's related to a dependency version?
I do have the latest version. Let me run again and send the logs.
Plain Text
# Option 1
"""
Traceback (most recent call last):
  File "/Users/jayanta/Work/quick-reference-llm/llamaindex/examples-python/10- hello-query-engine/hello-custom-qe.py", line 49, in <module>
    response = query_engine.query("Who are the people mentioned")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jayanta/.local/share/virtualenvs/10-_hello-query-engine-QsvNZDng/lib/python3.11/site-packages/llama_index/query_engine/custom.py", line 36, in query
    with self.callback_manager.as_trace("query"):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FieldInfo' object has no attribute 'as_trace'
"""

# Option 2
"""
Traceback (most recent call last):
  File "/Users/jayanta/Work/quick-reference-llm/llamaindex/examples-python/10- hello-query-engine/hello-custom-qe.py", line 38, in <module>
    query_engine = RAGStringQueryEngine(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jayanta/.local/share/virtualenvs/10-_hello-query-engine-QsvNZDng/lib/python3.11/site-packages/pydantic/main.py", line 165, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
TypeError: BaseModel.validate() takes 2 positional arguments but 3 were given
"""
What is your pydantic version? pip show pydantic
LlamaIndex version:0.8.29.post1
Hmm, try pip install pydantic==1.10.12
The backward compat layer may not be perfect
same result sadly
Can you send the exact file you ran to test
Maybe restart the notebook kernel after changing versions?

I ran the exact example notebook here
https://github.com/jerryjliu/llama_index/blob/main/docs/examples/query_engine/custom_query_engine.ipynb
Really seems like a pydantic issue to me, 1.10.12 should have solved it πŸ˜…
yeah it's not working sadly
I haven't rebooted in a while. Will do and try.
Yea. Like even starting with a fresh venv might help lol
Will just extend BaseQueryEngine
instead of CustomQueryEngine
actually I'm working to and fro Python and TS version
At work we are using TS, where we have successfully extended the BaseQueryEngine
in Python version, there's this CustomQueryEngine which is what is given here
Yea, the custom query engine allows you to skip the annoying setup parts for the callback manager (or at least it does for me lol)
Still super confused why it works for me, but oh well I guess. If you are comfortable extending the base class go for it
I'll try it in another environment
Add a reply
Sign up and join the conversation on Discord