Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions learn/generation/better-rag/00-rerankers-pinecone.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,10 @@
},
"outputs": [],
"source": [
"from pinecone_plugins.inference.core.client.exceptions import PineconeApiException\n",
"from pinecone.exceptions import PineconeApiException\n",
"\n",
"def embed(batch: list[str]) -> list[float]:\n",
" passed = False\n",
" # create embeddings (exponential backoff to avoid RateLimitError)\n",
" for j in range(5): # max 5 retries\n",
" try:\n",
Expand All @@ -532,9 +533,10 @@
" }\n",
" )\n",
" passed = True\n",
" except PineconeApiException:\n",
" break\n",
" except PineconeApiException as e:\n",
" print(f\"Retry {j}: {e}\")\n",
" time.sleep(2**j) # wait 2^j seconds before retrying\n",
" print(\"Retrying...\")\n",
" if not passed:\n",
" raise RuntimeError(\"Failed to create embeddings.\")\n",
" # get embeddings\n",
Expand Down Expand Up @@ -1946,4 +1948,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}