-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add retry mechanism for transient API errors (503, 429, timeouts) #257
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
base: main
Are you sure you want to change the base?
Conversation
❌ Infrastructure File Protection This PR modifies protected infrastructure files:
Only repository maintainers are allowed to modify infrastructure files (including Note: If these are only formatting changes, please:
If structural changes are necessary:
For more information, see our Contributing Guidelines. |
ec7be58
to
7cd5951
Compare
Fixed the issues! |
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git push Note: Enable "Allow edits by maintainers" to allow automatic updates. |
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git push Note: Enable "Allow edits by maintainers" to allow automatic updates. |
1 similar comment
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git push Note: Enable "Allow edits by maintainers" to allow automatic updates. |
Description
Implements a retry mechanism to handle transient API errors like 503 "The model is overloaded", 429 rate limits, and timeouts. This prevents the loss of all processing work when encountering temporary service issues.
Changes Involved
API Changes
New optional parameters in
extract()
function:retry_transient_errors: bool = True
max_retries: int = 3
retry_initial_delay: float = 1.0
retry_backoff_factor: float = 2.0
retry_max_delay: float = 60.0
Files Changed
langextract/retry_utils.py
- New retry utility modulelangextract/extraction.py
- Added retry parameters toextract()
langextract/annotation.py
- Integrated retry logic in processinglangextract/providers/gemini.py
- Applied retry decoratortests/retry_utils_test.py
- New test suitetests/annotation_test.py
- Added retry integration testsHow Has This Been Tested?
Checklist
Fixes #240