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
When calling d.to_dict() or d.to_json(), d gets converted through to_pydantic_model() to a PydanticDocument.
The PydanticDocument contains _metadata (which is responsible for enabling multimodal features) as a private attribute, and private attributes are not kept by pydantic (more info (here)[https://pydantic-docs.helpmanual.io/usage/models/#private-model-attributes]).
Possible Solution:
One idea to solve this coild be with a small special logic that converts _metadata to metadata when converting to PydanticDocument.
Something like this:
defto_pydantic_model(self) ->'PydanticDocument':
"""Convert a Document object into a Pydantic model."""from ..pydantic_modelimportPydanticDocumentasDP_p_dict= {}
forfinself.non_empty_fields:
v=getattr(self, f)
...
eliff=='_metadata':
_p_dict['metadata'] =velse:
_p_dict[f] =vreturnDP(**_p_dict)
And the equivalent in from_pydantic_model().
The text was updated successfully, but these errors were encountered:
How to reproduce:
Probable Cause:
When calling
d.to_dict()
ord.to_json()
,d
gets converted throughto_pydantic_model()
to aPydanticDocument
.The
PydanticDocument
contains_metadata
(which is responsible for enabling multimodal features) as a private attribute, and private attributes are not kept by pydantic (more info (here)[https://pydantic-docs.helpmanual.io/usage/models/#private-model-attributes]).Possible Solution:
One idea to solve this coild be with a small special logic that converts
_metadata
tometadata
when converting toPydanticDocument
.Something like this:
And the equivalent in
from_pydantic_model()
.The text was updated successfully, but these errors were encountered: