I’m facing a recurring error while using the OpenAI API. After around some minutes of execution, I keep getting this frustrating message:
“APIError: The server had an error while processing your request. Sorry about that! You can retry your request, or contact us at help.openai.com if the error persists. (Request ID: 02dd410798435ad9fec54f15404dbb08)”
I tried implementing error handling and even added delays between requests, but the error keeps popping up.
Im using this function:
‘’’
import time
def add_embeddings_to_dataframe(df, label_column, model, delay=0.5):
embeddings =
for label in df[label_column]:
embedding = openai.Embedding.create(input=label, model=model)[“data”][0][“embedding”]
embeddings.append(embedding)
time.sleep(delay) # Agregar un retraso de tiempo antes de la siguiente solicitud
embedding_columns = [f"embedding_{i}" for i in range(len(embeddings[0]))]
embedding_df = pd.DataFrame(embeddings, columns=embedding_columns)
return pd.concat([df, embedding_df], axis=1)
df_embedings_1 = add_embeddings_to_dataframe(df1,‘clean_categoria’, “text-embedding-ada-002”)
‘’‘’
After a few minutes of execution, this error appears
My dataset has 15k records aprox.