Skip to content

Commit

Permalink
fix the initialization of Pinecone in the low-level ingestion noteboo…
Browse files Browse the repository at this point in the history
…k. (#14919)
  • Loading branch information
MatinKhajavi authored Jul 24, 2024
1 parent 3d80b3e commit 2dca097
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions docs/docs/examples/low_level/ingestion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
")\n",
"with open(dotenv_path, \"w\") as f:\n",
" f.write('PINECONE_API_KEY=\"<your api key>\"\\n')\n",
" f.write('PINECONE_ENVIRONMENT=\"gcp-starter\"\\n')\n",
" f.write('OPENAI_API_KEY=\"<your api key>\"\\n')"
]
},
Expand Down Expand Up @@ -181,7 +180,7 @@
"metadata": {},
"outputs": [],
"source": [
"import pinecone"
"from pinecone import Pinecone, Index, ServerlessSpec"
]
},
{
Expand All @@ -192,8 +191,7 @@
"outputs": [],
"source": [
"api_key = os.environ[\"PINECONE_API_KEY\"]\n",
"environment = os.environ[\"PINECONE_ENVIRONMENT\"]\n",
"pinecone.init(api_key=api_key, environment=environment)"
"pc = Pinecone(api_key=api_key)"
]
},
{
Expand Down Expand Up @@ -225,9 +223,13 @@
"outputs": [],
"source": [
"# dimensions are for text-embedding-ada-002\n",
"pinecone.create_index(\n",
" index_name, dimension=1536, metric=\"euclidean\", pod_type=\"p1\"\n",
")"
"if index_name not in pc.list_indexes().names():\n",
" pc.create_index(\n",
" index_name,\n",
" dimension=1536,\n",
" metric=\"euclidean\",\n",
" spec=ServerlessSpec(cloud=\"aws\", region=\"us-east-1\"),\n",
" )"
]
},
{
Expand All @@ -237,7 +239,7 @@
"metadata": {},
"outputs": [],
"source": [
"pinecone_index = pinecone.Index(index_name)"
"pinecone_index = pc.Index(index_name)"
]
},
{
Expand Down

0 comments on commit 2dca097

Please sign in to comment.