From 54646e889d2bf3dcce15a41f8d05435bb1a38de0 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Fri, 22 Dec 2023 14:26:37 +0100 Subject: [PATCH] copy metadata --- .../pinecone/src/pinecone_haystack/document_store.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integrations/pinecone/src/pinecone_haystack/document_store.py b/integrations/pinecone/src/pinecone_haystack/document_store.py index 5b4afb39c..96415b306 100644 --- a/integrations/pinecone/src/pinecone_haystack/document_store.py +++ b/integrations/pinecone/src/pinecone_haystack/document_store.py @@ -5,6 +5,7 @@ import logging import os from typing import Any, Dict, List, Optional +from copy import copy import pandas as pd import pinecone @@ -241,14 +242,14 @@ def _convert_query_result_to_documents(self, query_result: Dict[str, Any]) -> Li def _convert_documents_to_pinecone_format(self, documents: List[Document]) -> List[Dict[str, Any]]: documents_for_pinecone = [] for document in documents: - embedding = document.embedding + embedding = copy(document.embedding) if embedding is None: logger.warning( f"Document {document.id} has no embedding. Pinecone is a purely vector database. " "A dummy embedding will be used, but this can affect the search results. " ) embedding = self._dummy_vector - doc_for_pinecone = {"id": document.id, "values": embedding, "metadata": document.meta} + doc_for_pinecone = {"id": document.id, "values": embedding, "metadata": dict(document.meta)} # we save content/dataframe as metadata # currently, storing blob in Pinecone is not supported