This is what I'm aiming for,
index
should be called once at the start, to initially index the data into pinecone
query
should use pinecone directly without attempting to load the data or re-indexing.
What am I doing wrong?
from llama_index import SimpleDirectoryReader, GPTPineconeIndex
import pinecone
def index():
existing_indexes = pinecone.list_indexes()
if "paul-graham-essay" not in existing_indexes:
pinecone.create_index(
"paul-graham-essay",
dimension=1536,
metric="euclidean",
pod_type="p1"
)
pinecone_index = pinecone.Index("paul-graham-essay")
documents = SimpleDirectoryReader('./hcaa/static').load_data()
GPTPineconeIndex(documents, pinecone_index=pinecone_index)
def query(q):
pinecone_index = pinecone.Index("paul-graham-essay")
documents = SimpleDirectoryReader('./hcaa/static').load_data()
index = GPTPineconeIndex(documents=documents, pinecone_index=pinecone_index)
response = index.query(q)
return response