:mag: AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.
This PR addresses the TypeError that occurs when trying to insert DocX converted document objects into PGVector or when using json.dumps() on docs.to_dict() output. The issue is caused by datetime objects not being JSON serializable.
Changes made:
Modified the to_dict() method in the Document class to handle datetime serialization.
Implemented a custom JSON encoder to convert datetime objects to ISO format strings during serialization.
Updated the from_dict() method to properly deserialize the ISO format strings back to datetime objects.
How did you test it?
Verified that json.dumps() works correctly on the output of docs.to_dict() from DocXToDocument Converter.
Notes for the reviewer
My thoughts are to fix this in a two PR effort. This being the first and a separate PR in haystack-core-integrations to address the problem there. Potentially the default_to_dict() function.
Related Issues
Proposed Changes:
This PR addresses the TypeError that occurs when trying to insert DocX converted document objects into PGVector or when using
json.dumps()
ondocs.to_dict()
output. The issue is caused by datetime objects not being JSON serializable.Changes made:
to_dict()
method in the Document class to handle datetime serialization.from_dict()
method to properly deserialize the ISO format strings back to datetime objects.How did you test it?
json.dumps()
works correctly on the output ofdocs.to_dict()
from DocXToDocument Converter.Notes for the reviewer
My thoughts are to fix this in a two PR effort. This being the first and a separate PR in haystack-core-integrations to address the problem there. Potentially the default_to_dict() function.
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.