Skip to content

Commit a24be77

Browse files
committed
update Pinecone client initialization
1 parent bb081ba commit a24be77

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

integrations/cohere/semantic_search_trec.ipynb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,25 +595,26 @@
595595
},
596596
"outputs": [],
597597
"source": [
598-
"from pinecone import Pinecone\n",
598+
"from pinecone import Pinecone, ServerlessSpec\n",
599599
"\n",
600-
"pinecone.init(\n",
601-
" PINECONE_KEY,\n",
602-
" environment=\"YOUR_ENV\" # find next to API key in console\n",
603-
")\n",
600+
"pc = Pinecone(api_key=PINECONE_KEY)\n",
604601
"\n",
605602
"index_name = 'cohere-pinecone-trec'\n",
606603
"\n",
607604
"# if the index does not exist, we create it\n",
608-
"if index_name not in pinecone.list_indexes().names():\n",
609-
" pinecone.create_index(\n",
610-
" index_name,\n",
605+
"if index_name not in pc.list_indexes().names():\n",
606+
" pc.create_index(\n",
607+
" name=index_name,\n",
611608
" dimension=shape[1],\n",
612-
" metric='cosine'\n",
609+
" metric=\"cosine\",\n",
610+
" spec=ServerlessSpec(\n",
611+
" cloud='aws', \n",
612+
" region='us-east-1'\n",
613+
" ) \n",
613614
" )\n",
614615
"\n",
615616
"# connect to index\n",
616-
"index = pinecone.Index(index_name)"
617+
"index = pc.Index(index_name)"
617618
]
618619
},
619620
{

0 commit comments

Comments
 (0)