Add OpenAI Batch API support and batch_size passthrough#424
Add OpenAI Batch API support and batch_size passthrough#424m7mdhka wants to merge 4 commits intogoogle:mainfrom
Conversation
- Pass batch_size through BaseLanguageModel.infer_batch() as a provider hint\n- Add OpenAI Batch API helper and wire it into OpenAI provider\n- Prevent batch_size leaking into Gemini/Ollama payload kwargs\n- Add OpenAI batch helper unit tests
- Refactor helper to satisfy pylint return-statement limit\n- Fix test fakes so pylint passes under tests/.pylintrc\n- Record verified test/lint commands in PR_openai_batch.md
|
No linked issues found. Please link an issue in your pull request description or title. Per our Contributing Guidelines, all PRs must:
You can also use cross-repo references like |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
|
|
Your branch is 4 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
Description
This PR adds true provider-native batching support for OpenAI via the OpenAI Batch API, and makes
BaseLanguageModel.infer_batch()respectbatch_sizeby passing it through to provider implementations as a hint.Choose one: Feature
Key changes
BaseLanguageModel.infer_batch()now validatesbatch_size > 0and forwards it intoinfer(..., batch_size=...)as a provider hint.batch_sizefrom runtime kwargs to avoid it leaking into provider payload/options.Files
langextract/core/base_model.pylangextract/providers/openai.pylangextract/providers/openai_batch.pylangextract/providers/gemini.py,langextract/providers/ollama.pytests/openai_batch_test.py,tests/inference_test.pyRisks / notes
custom_id.How Has This Been Tested?
pytest -q./autoformat.shpylint --rcfile=.pylintrc langextract/providers/openai_batch.py langextract/providers/openai.py langextract/core/base_model.py langextract/providers/gemini.py langextract/providers/ollama.pypylint --rcfile=tests/.pylintrc tests/openai_batch_test.py tests/inference_test.pypre-commit run --files langextract/core/base_model.py langextract/providers/openai.py langextract/providers/openai_batch.py langextract/providers/gemini.py langextract/providers/ollama.py tests/inference_test.py tests/openai_batch_test.pyChecklist
pylintover the affected code.