[Jules] Add OpenAI Remote Model Handler implementation#35498
Closed
jrmccluskey wants to merge 11 commits intoapache:masterfrom
Closed
[Jules] Add OpenAI Remote Model Handler implementation#35498jrmccluskey wants to merge 11 commits intoapache:masterfrom
jrmccluskey wants to merge 11 commits intoapache:masterfrom
Conversation
f00680c to
a03ca08
Compare
This commit introduces an OpenAIModelHandler to enable sending inference requests to OpenAI's API (e.g., GPT models) via the RunInference transform. Key changes: - Added `OpenAIModelHandler` in `sdks/python/apache_beam/ml/inference/openai_inference.py`. - Implemented request generation and response parsing for both completion and chat-based OpenAI models within the `generate_completion` helper function. - Included retry logic for common OpenAI API errors (rate limits, server errors). - Added comprehensive unit tests in `sdks/python/apache_beam/ml/inference/openai_inference_test.py`, mocking the OpenAI client and testing various scenarios. All unit tests pass. - Created integration tests in `sdks/python/apache_beam/ml/inference/openai_inference_it_test.py` (requires `OPENAI_API_KEY` to run). - Defined dependencies in `sdks/python/apache_beam/ml/inference/openai_tests_requirements.txt`, now with Apache license header. This handler follows the pattern of other remote model handlers like those for Gemini and Vertex AI. The handler is not exported by default from `apache_beam.ml.inference`.
a03ca08 to
f118195
Compare
Contributor
|
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@beam.apache.org list. Thank you for your contributions. |
Contributor
|
This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change introduces an OpenAIModelHandler to enable sending inference requests to OpenAI's API (e.g., GPT models) via the RunInference transform.
Key changes:
OpenAIModelHandlerinsdks/python/apache_beam/ml/inference/openai_inference.py.generate_completionhelper function.sdks/python/apache_beam/ml/inference/openai_inference_test.py, mocking the OpenAI client and testing various scenarios. All unit tests pass.sdks/python/apache_beam/ml/inference/openai_inference_it_test.py(requiresOPENAI_API_KEYto run).This PR was initially generated by Jules then manually cleaned up (removing unused imports, unnecessary code comments, formatting changes.)
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.