Hi I am running this code from the provided notebook.
documents =
for element in elements:
metadata = element.metadata.to_dict()
del metadata[“languages”]
metadata[“source”] = metadata[“filename”]
documents.append(Document(page_content=element.text, metadata=metadata))
embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_documents(documents, embeddings)
Running the vectorstore cell gives out the following error,
I am unsure what will be the accurate solution to it.
Error:
ValueError: Expected metadata value to be a str, int, float or bool, got [{‘x’: 0, ‘y’: 0, ‘w’: 1, ‘h’: 1, ‘content’: ‘NAVER CLOVA’}, {‘x’: 1, ‘y’: 0, ‘w’: 1, ‘h’: 1, ‘content’: ‘2NAVER Search’}, {‘x’: 2, ‘y’: 0, ‘w’: 1, ‘h’: 1, ‘content’: ‘3SNAVER AI Lal’}] which is a <class ‘list’>
Try filtering complex metadata from the document using langchain_community.vectorstores.utils.filter_complex_metadata.