In my situation I am trying to pass a prompt using a helper function to the actual GPT3 models, in my case text-ada-001 and then eventually applying it on a pandas column using the following code. but I am recovering the following error:
def sentiment_prompt(text):
return """Is the sentiment Positive, Negative or Neutral for the following text:
"{}"
""".format(text)
def sentiment_text(text):
response = openai.Completion.create(
engine="text-ada-001",
prompt=sentiment_prompt(text),
max_tokens=1000,
temperature=0,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
sentiment = response.choices[0].text
return sentiment
and then eventually applying to my pandas column:
df['sentiment'] = df['text'].apply(lambda x :sentiment_text(x))
And the error;
RateLimitError: Rate limit reached for default-global-with-image-limits in organization org-XXXX on requests per min. Limit: 60 / min. Please try again in 1s. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.
To overcome this error I was looking into this link and found that tenacity could help resolve my issue. But I am not sure how to structure my code. I am doing the following at the moment
How do I use the code suggested in the link to overcome the Rate Limit error?