Find answers from the community

Updated 2 years ago

If I've already created an index using GTPineconeIndex and saved to pinecone -- how do I l

At a glance
@kapa.ai If I've already created an index using GTPineconeIndex and saved to pinecone -- how do I load it in next time so I don't have to recreate the index each time?
k
2 comments
Please stand by @LawSnap as I search the knowledge base. We are experiencing especially high traffic right now and might take longer than usual. :wave:
----------------------
To load an existing Pinecone index, you can follow these steps:

  1. Import the necessary libraries and initialize Pinecone with your API key:
Plain Text
from gpt_index import GPTPineconeIndex, SimpleDirectoryReader
import pinecone

api_key = "<api_key>"
pinecone.init(api_key=api_key, environment="us-west1-gcp")


  1. Load the existing Pinecone index:
Plain Text
index_name = "quickstart"  # Replace with your index name
pinecone_index = pinecone.Index(index_name)


  1. Load your documents using SimpleDirectoryReader:
Plain Text
documents = SimpleDirectoryReader('../paul_graham_essay/data').load_data()


  1. Create a GPTPineconeIndex instance using the loaded Pinecone index:
Plain Text
index = GPTPineconeIndex(documents, pinecone_index=pinecone_index)


Now you can use the index object to query the existing Pinecone index without recreating it each time.

Source: Pinecone Index Construction/Querying (https://gpt-index.readthedocs.io/en/latest/how_to/integrations/vector_stores.html#using-a-vector-store-as-an-index)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord