Added retry decorator to embeddings

pull/1077/head
Colin Jarvis 1 year ago
parent eb669367af
commit da802af763

@ -1084,13 +1084,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 12,
"id": "ca7e7eb1", "id": "eb5848f3",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"## Batch Embedding Logic\n", "## Batch Embedding Logic\n",
"\n", "\n",
"# Simple function to take in a list of text objects and return them as a list of embeddings\n", "# Simple function to take in a list of text objects and return them as a list of embeddings\n",
"@retry(wait=wait_random_exponential(min=1, max=40), stop=stop_after_attempt(10))\n",
"def get_embeddings(input: List):\n", "def get_embeddings(input: List):\n",
" response = openai.Embedding.create(\n", " response = openai.Embedding.create(\n",
" input=input,\n", " input=input,\n",
@ -1197,7 +1198,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 14,
"id": "9e49c881", "id": "e3a6fb12",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1222,7 +1223,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 15,
"id": "2e6ff2f4", "id": "83f0231c",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1248,7 +1249,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 16,
"id": "963170f9", "id": "61c204c8",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -2649,7 +2650,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 24, "execution_count": 24,
"id": "c1b5fad4", "id": "ba73ffab",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -2953,7 +2954,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 34,
"id": "99072e4c", "id": "4ee414f1",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {

Loading…
Cancel
Save