Adding retry code on 429 errors from exteranl providers

This commit is contained in:
Jake Poznanski 2025-09-29 17:26:22 +00:00
parent 9c750903ce
commit 0c6d889863
2 changed files with 4 additions and 0 deletions

View File

@ -260,12 +260,14 @@ export DEEPINFRA_API_KEY="your-api-key-here"
python -m olmocr.pipeline ./localworkspace \
--server https://api.deepinfra.com/v1/openai \
--api_key $DEEPINFRA_API_KEY \
--pages_per_group 100 \
--model allenai/olmOCR-7B-0725-FP8 \
--markdown \
--pdfs path/to/your/*.pdf
```
- `--server`: DeepInfra's OpenAI-compatible endpoint: `https://api.deepinfra.com/v1/openai`
- `--api_key`: Your DeepInfra API key
- `--pages_per_group`: You may want a smaller number of pages per group as many external provides have lower concurrent request limits
- `--model`: The model identifier on DeepInfra: `allenai/olmOCR-7B-0725-FP8`
- Other arguments work the same as with local inference

View File

@ -284,6 +284,8 @@ async def process_page(args, worker_id: int, pdf_orig_path: str, pdf_local_path:
if status_code == 400:
raise ValueError(f"Got BadRequestError from server: {response_body}, skipping this response")
elif status_code == 429:
raise ConnectionError(f"Too many requests, doing exponential backoff")
elif status_code == 500:
raise ValueError(f"Got InternalServerError from server: {response_body}, skipping this response")
elif status_code != 200: