-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
Added Retrying Mechanism in case of Request Rate Limit Error for MistralAIEmbeddings
#27818
base: master
Are you sure you want to change the base?
Conversation
keenborder786
commented
Nov 1, 2024
- Description:: In the event of a Rate Limit Error from the MistralAI server, the response JSON raises a KeyError. To address this, a simple retry mechanism has been implemented to handle cases where the request limit is exceeded.
- Issue: Cannot create MistralAI embeddings from pdf or urls #27790
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
batch_responses = [] | ||
|
||
@retry( | ||
retry=retry_if_exception_type(Exception), |
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.
Generally, retries should never be implemented on 4xx errors (except for 408 and 429). e.g., 403 should not be retried by default
- What do we do in other parts of the code? Perhaps there's a better example that can be adopted?
- What do other models do in the code base in terms of exposing the retry parameters so users can adjust? (e.g.,what if someone wants to have the first retry after 1 second rather than 30 seconds?)
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.
- @eyurtsev it is a 429 error therefore retrying makes sense.
- I was not able to find any related example.
- Yes I can make the wait and stop seconds as parameters.
for batch in self._get_batches(texts) | ||
) | ||
if response.status_code == 429: | ||
raise Exception("Requests rate limit exceeded") |
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.
This code takes an exception that was good and informative and turns it into one that's a broad Exception of type Exception -- this is usually not a good pattern for exception handling. Stack trace will be partially lost, the exception type is less specific etc.
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.
- Their were no specific exception being raised to being with. But I can change it from a general Exception.
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.
Makes sense to add retry mechanism. Added a few questions to see if we can improve how it's configured
@eyurtsev please check now |