Find answers from the community

Updated 2 years ago

hey

hey

what is the latest method of inserting nodes in pinecone for 0.6.0
Plain Text
from llama_index.vector_stores import PineconeVectorStore
from llama_index.storage.storage_context import StorageContext

#"Insert"ing
vector_store = PineconeVectorStore(
    pinecone_index=index,
    add_sparse_vector=True,
)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = pinecone.Index("dobby-springworks-be-dev")
pcv_index = GPTVectorStoreIndex.from_documents(documents,pinecone_index=index, metadata_filters ={'doc_name': 'Handbook', 'admin_name': 'Siddhant', 'user_name': 'Siddhant'}, namespace='temp')
# for doc_chunk in documents:
#     pcv_index.insert(doc_chunk)
print(index.describe_index_stats())

from above the before no. of total vector and after vector remains same, the above also does not give any error, but the before no. of total vector and after vector remains same πŸ€”
@ravitheja @Logan M
S
r
3 comments
and is the below method for query in pinecone is correct ?
Plain Text
#query
index = pinecone.Index("dobby-springworks-be-dev")
vector_store = PineconeVectorStore(
    pinecone_index=index,
    add_sparse_vector=True,
)

storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = GPTVectorStoreIndex.from_documents([],pinecone_index=index, metadata_filters ={'doc_name': 'Handbook', 'admin_name': 'Siddhant', 'user_name': 'Siddhant'}, namespace='temp')
# pc_index = index.as_query_engine(vector_store_query_mode="hybrid") does not work
pc_index = index.as_query_engine()
response = pc_index.query("Tell me about leave policy?")
print(response)

but I am not able to receive any response (many be because I was not able to insert in pine cone
@Siddhant Saurabh the syntax is wrong. You need to use metadata_filters in PineconeVectorStore. Please go through example notebooks here - https://github.com/jerryjliu/llama_index/blob/main/examples/vector_indices/PineconeIndexDemo.ipynb .
as @ravitheja mentioned to include storage_context=storage_context
in GPTVectorStoreIndex.from_documents()
Plain Text
from llama_index.vector_stores import PineconeVectorStore
from llama_index.storage.storage_context import StorageContext

#inserting
vector_store = PineconeVectorStore(
    pinecone_index=index
)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = pinecone.Index("dobby-springworks-be-dev")
# index = GPTVectorStoreIndex.from_documents(documents, storage_context=storage_context)
pcv_index = GPTVectorStoreIndex.from_documents(documents,pinecone_index=index, metadata_filters ={'doc_name': 'Handbook', 'admin_name': 'Siddhant', 'user_name': 'Siddhant'}, namespace='temp', storage_context=storage_context)
# for doc_chunk in documents:
#     pcv_index.insert(doc_chunk)
print(index.describe_index_stats())

above now works
Add a reply
Sign up and join the conversation on Discord