mirror of
https://github.com/allenai/olmocr.git
synced 2025-11-02 11:04:25 +00:00
Adding retry code on 429 errors from exteranl providers
This commit is contained in:
parent
9c750903ce
commit
0c6d889863
@ -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
|
||||
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user