-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retry mechanism for openai API calls #129
Add retry mechanism for openai API calls #129
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to set up pre-commit
locally. Also, retrying
needs to be added to the dependencies
in pyproject.toml
.
I would advise using https://pypi.org/project/backoff/ instead of retying. Backoff seems to have more stars, and I have seen multiple people using it like the official tree-of-thoughts too |
Is there a technical/functional/support reason one of these libraries should be used over the other? |
Nothing too technical as of my current knowledge. Just some thoughts based on seeing various implementations of I feel using backoff or |
Assuming stars as a proxy for something like quality or maturity of the libraries, and that the changes are trivial, they might as well be made here. |
I've always thought tenacity (a fork of |
eb05fce
to
7cbe400
Compare
7cbe400
to
4b356b7
Compare
I rebased the changes, modified the code to use I used the parameters found in this file in the |
Add retrying mechanism for openai api calls.
Sample use cases
complete = models.text_completion.openai("text-davinci-003", **{"wait_exponential_multiplier":1000, "wait_exponential_max":10000, "stop_max_attempt_number":5})
complete = models.text_completion.openai("text-davinci-003", **{"wait_random_min":1000, "wait_random_max":10000, "stop_max_attempt_number":5})
Closes #115