mirror of
https://github.com/james-m-jordan/openai-cookbook.git
synced 2025-05-09 19:32:38 +00:00
consolidate Embedding.create calls into one (#543)
This commit is contained in:
parent
4fd2b1a6d2
commit
b5ea5f3b0e
@ -673,17 +673,13 @@
|
||||
" # get texts to encode\n",
|
||||
" texts = [x['text'] for x in meta_batch]\n",
|
||||
" # create embeddings (try-except added to avoid RateLimitError)\n",
|
||||
" try:\n",
|
||||
" res = openai.Embedding.create(input=texts, engine=embed_model)\n",
|
||||
" except:\n",
|
||||
" done = False\n",
|
||||
" while not done:\n",
|
||||
" sleep(5)\n",
|
||||
" try:\n",
|
||||
" res = openai.Embedding.create(input=texts, engine=embed_model)\n",
|
||||
" done = True\n",
|
||||
" except:\n",
|
||||
" pass\n",
|
||||
" sleep(5)\n",
|
||||
" embeds = [record['embedding'] for record in res['data']]\n",
|
||||
" # cleanup metadata\n",
|
||||
" meta_batch = [{\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user