I don’t know why this is happening. It was working fine for the last 2 weeks. Suddenly it broke the code and I am facing issues here.
Here is a code snippet.
from tqdm.auto import tqdm
import http
MODEL = "text-embedding-ada-002"
count = 0 # we'll use the count to create unique IDs
batch_size = 25 # process everything in batches of 32
for i in tqdm(range(0, len(trec['content']), batch_size)):
# set end position of batch
i_end = min(i+batch_size, len(trec['content']))
# get batch of lines and IDs
lines_batch = trec['content'][i: i+i_end]
#print(lines_batch)
#ids_batch = [str(n) for n in range(i, i_end)]
ids_batch = generate_ids(i_end)
# create embeddings
res = openai.Embedding.create(input=list(lines_batch), engine=MODEL)
embeds = [record['embedding'] for record in res['data']]
#print(res)
# prep metadata and upsert batch
meta = [{'Content': line} for line in lines_batch]
to_upsert = zip(ids_batch, embeds, meta)
# upsert to Pinecone
index.upsert(vectors=list(to_upsert))
Here is the error:
ApiException: (429)
Reason: Too Many Requests
HTTP response headers: HTTPHeaderDict({'content-type': 'application/json', 'date': 'Tue, 14 Mar 2023 15:44:45 GMT', 'x-envoy-upstream-service-time': '16', 'content-length': '135', 'server': 'envoy'})
HTTP response body: {"code":8,"message":"Your request is larger than the maximum supported size - 2MB. Please try to reduce your batch size.","details":[]}
Iterations completed before error : 11/39 [00:19<00:55, 1.97s/it]
And it barely has a lot of text. Can anyone please assist me with this?