我一直在尝试,但索引不存在,即使我的松果帐户中有相同的索引,但仍然面临同样的问题
import os
from langchain.vectorstores import Pinecone as PineconeVectorStore
pc=Pinecone( api_key=PINECONE_API_KEY)
# pc.list_indexes()
index_name =pc.Index("medical-chatbot")
#Creating Embeddings for Each of The Text Chunks & storing
if index_name not in pc.list_indexes().names():
print(f"Index {index_name} does not exist.")
else:
docsearch=PineconeVectorStore.from_texts([t.page_content for t in text_chunks],
embeddings,
index_name=index_name)
导入 Pinecone 创建索引。
(你忘了添加松果的导入语句。)
根据文档,它是这样的。
from pinecone import Pinecone
# initialize connection to pinecone (get API key at app.pinecone.io)
api_key = 'PINECONE_API_KEY'
# configure client
pc = Pinecone(api_key=api_key)
假设您已经有了 text_chunks 和嵌入,它应该可以工作。