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
I run into Object of type PosixPath is not JSON serializable when I run index = VectorStoreIndex.from_documents(documents), so I had to convert PosixPath in metadata to string first. Below is the solution.
documents = loader.load(file_path=Path('./data/annualreport.pdf'), metadata=True)
# Convert PosixPath in metadata to string
for document in documents:
if 'file_path' in document.metadata and isinstance(document.metadata['file_path'], Path):
document.metadata['file_path'] = str(document.metadata['file_path'])
# Create an index with the converted documents
index = VectorStoreIndex.from_documents(documents)
The text was updated successfully, but these errors were encountered:
I run into
Object of type PosixPath is not JSON serializable
when I runindex = VectorStoreIndex.from_documents(documents)
, so I had to convert PosixPath in metadata to string first. Below is the solution.The text was updated successfully, but these errors were encountered: