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
feat: allow setting retry delay #1167
Comments
Thanks for the report! Ooc, what's your use-case for wanting to adjust those values? |
I also need this, I am using celery scheduling to implement it since the openai lib does not have this. My use-case is that openai api retries most of the time fail and fail and fail...so we dont like the idea to hit and hit and hit openai again again failing and failing, at least We would like to have a retry exponential/fibonacci or something like that to avoid hitting openai apis when they are slow/buggy/ which is a very very often state of the openai api state.. |
Does it fail with 429 repeatedly? Or another error message? What kind of rate limit are you hitting? (I ask because the client should be waiting long enough that you wouldn't hit a second 429, so if that's not happening, we need to adjust something). |
There are rate limits on Azure OpenAI that are based on the service tier that you are using. My specific scenario is using AOAI APIs in offline evaluation. Here's the error:
This is where those constants are used: _base_client.py:672: # Apply exponential backoff, but not more than the max.
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY) |
@kristapratico in this scenario, can you confirm whether AOAI will respond with |
no it isn't. I eventually figured out that I needed to use the with_retry() method on the LLM to configure this behavior correctly. Since I did this I don't think that this is a problem anymore. I blame the docs for not making this clear. :) |
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
Describe the feature or improvement you're requesting
Currently, setting the retry delay for the _base client is not easily exposed. End-users have easy control over the max number of retries but not the max_retry_delay and initial retry delay.
openai-python/src/openai/_base_client.py
Lines 76 to 78 in 8ee5f33
Preferably these are exposed and easily settable similar to max_retries in the OpenAI class:
openai-python/src/openai/_client.py
Lines 49 to 74 in 8ee5f33
Additional context
No response
The text was updated successfully, but these errors were encountered: