From 0621b9baffaa19e6d5142bcaa53b707a79d1266b Mon Sep 17 00:00:00 2001 From: Amogh Tantradi Date: Wed, 15 Jan 2025 22:46:15 -0800 Subject: [PATCH] fixed pinecone type errors --- lotus/vector_store/pinecone_vs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lotus/vector_store/pinecone_vs.py b/lotus/vector_store/pinecone_vs.py index 3486701..892faaa 100644 --- a/lotus/vector_store/pinecone_vs.py +++ b/lotus/vector_store/pinecone_vs.py @@ -10,7 +10,7 @@ from lotus.vector_store.vs import VS try: - from pinecone import Pinecone + from pinecone import Index, Pinecone except ImportError as err: raise ImportError( "The pinecone library is required to use PineconeVS. Install it with `pip install pinecone`", @@ -21,7 +21,7 @@ def __init__(self, api_key: str, embedding_model: Callable[[pd.Series | list], N """Initialize Pinecone client with API key and environment""" super().__init__(embedding_model) self.pinecone = Pinecone(api_key=api_key) - self.pc_index = None + self.pc_index:Index | None = None self.max_batch_size = max_batch_size @@ -140,6 +140,11 @@ def get_vectors_from_index(self, collection_name: str, ids: list[int]) -> NDArra if self.pc_index is None or self.collection_name != collection_name: self.load_index(collection_name) + if self.pc_index is None: # Add this check after load_index + raise ValueError("Failed to initialize Pinecone index") + + + # Fetch vectors from Pinecone vectors = [] for doc_id in ids: