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)
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.