Reputation: 1
I'm not sure what the alternative to .get() is for PineCone and Langchain. I want this code to run, but I keep getting an error that .get is not an attribute for Pinecone. I'm not sure what the alternative is to replace it.
def add_to_pinecone(chunks: list[Document]):
VectorStore = Pinecone(index='portfolio-assistant', embedding=get_embeddings() ,pinecone_api_key=pc_api_key) # Connecting to Pinecone
chunks_with_ids = calculate_chunk_ids(chunks)
existing_items = **VectorStore.get(include=[])**
existing_ids = set(existing_items["ids"])
print(f'Number of existing documents in VectorStore: {len(existing_ids)}')
new_chunks = []
for chunk in chunks_with_ids:
if chunk.metadata["id"] not in existing_ids:
new_chunks.append(chunk)
if len(new_chunks):
print(f"Adding new documents: {len(new_chunks)}")
new_chunk_ids = [chunk.metadata["id"] for chunk in new_chunks]
VectorStore.add_document(new_chunks, ids=new_chunk_ids)
else:
print("No new documents to add")
Upvotes: 0
Views: 77