I’m trying a very simple excercise, create an index, check availability and upsert, still; I’m receiving 403 errors due to a “Wrong API key” (It isn’t!! It belongs to the project in working in).
Here is my code:
load_dotenv('.env', override=True)
pinecone_api_key = os.getenv("PINECONE_API_KEY")
pc = Pinecone(api_key=pinecone_api_key, environment='gcp-starter')
print(pc.list_indexes()) # Check availability
index_name = "project-chunks-2"
if index_name not in pc.list_indexes().names():
pc.create_index(
name=index_name,
dimension=1536,
metric="cosine",
spec=PodSpec(
environment="gcp-starter",
pod_type="starter",
pods=1
)
)
print(pc.list_indexes()) # Check availability
index = pinecone.Index(index_name, host="host_shown_in_print(pc.list_indexes())")
# Load and chunk it up
loader = TextLoader('masterwallet_doc.txt')
documents = loader.load()
context = " ".join([doc.page_content for doc in documents])
text_splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=50)
chunks = text_splitter.split_text(context)
embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")
chunk_embeddings = [embeddings.embed_query(chunk) for chunk in chunks]
my_vectors = [(str(i), chunk_embeddings[i]) for i in range(len(chunk_embeddings))]
index.upsert(vectors=my_vectors) # Error happens here!!
Here’s the error I’m currently getting:
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({‘x-pinecone-auth-rejected-reason’: ‘Wrong API key’, ‘www-authenticate’: ‘Wrong API key’, ‘Content-Length’: ‘9’, ‘content-type’: ‘text/plain’, ‘date’: ‘Wed, 22 May 2024 16:53:14 GMT’, ‘server’: ‘envoy’, ‘Via’: ‘1.1 google’, ‘Alt-Svc’: ‘h3=“:443”; ma=2592000,h3-29=“:443”; ma=2592000’, ‘Connection’: ‘close’})
HTTP response body: Forbidden