Skip to content

Commit

Permalink
Merge branch 'add_pinecone' into pinecone-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 authored Dec 21, 2023
2 parents a5c3f18 + a12a31c commit d8a6968
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions integrations/pinecone/src/pinecone_haystack/document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io
import logging
import os
from copy import deepcopy
from typing import Any, Dict, List, Optional

import pandas as pd
Expand Down Expand Up @@ -121,12 +122,9 @@ def write_documents(self, documents: List[Document], policy: DuplicatePolicy = D
:return: The number of documents written to the document store.
"""
try:
if not isinstance(documents[0], Document):
raise TypeError()
except (TypeError, KeyError) as e:
if len(documents) > 0 and not isinstance(documents[0], Document):
msg = "param 'documents' must contain a list of objects of type Document"
raise TypeError(msg) from e
raise ValueError(msg)

if policy not in [DuplicatePolicy.NONE, DuplicatePolicy.OVERWRITE]:
logger.warning(
Expand All @@ -135,7 +133,7 @@ def write_documents(self, documents: List[Document], policy: DuplicatePolicy = D
)

documents_for_pinecone = []
for document in documents:
for document in deepcopy(documents):
if document.embedding is None:
logger.warning(
f"Document {document.id} has no embedding. Pinecone is a purely vector database. "
Expand Down

0 comments on commit d8a6968

Please sign in to comment.