You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stored image documents can never be retrieved as ImageDocument from any document store due to the incorrect deserialization logic of json_to_doc helper function in llama_index.core.storage.docstore.utils module.
As the document is going to be retrieved as Document object we can't access image_url and will result in a AttributeError Exception
Relevant Logs/Tracbacks
Traceback (most recent call last):
File "/server_code/playground.py", line 15, in<module>
print(doc_from_store .image_url)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pydantic/main.py", line 811, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'Document' object has no attribute 'image_url'
The text was updated successfully, but these errors were encountered:
The json_to_doc helper function in the llama_index.core.storage.docstore.utils module already includes the necessary logic to handle ImageDocument objects correctly. Here is the relevant part of the function:
This function checks the doc_type and correctly calls ImageDocument.parse_obj(data_dict) when the doc_type matches ImageDocument.get_type(). This ensures that ImageDocument objects are deserialized correctly from the document store [1][2].
Therefore, the existing code should handle the deserialization of ImageDocument objects correctly. If you are still encountering issues, please ensure that the doc_type is being set correctly when storing the document.
Bug Description
Stored image documents can never be retrieved as
ImageDocument
from any document store due to the incorrect deserialization logic ofjson_to_doc
helper function inllama_index.core.storage.docstore.utils
module.Version
0.11.2
Steps to Reproduce
As the document is going to be retrieved as
Document
object we can't accessimage_url
and will result in aAttributeError
ExceptionRelevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: