Skip to content

[Jules] Add OpenAI Remote Model Handler implementation#35498

Closed
jrmccluskey wants to merge 11 commits intoapache:masterfrom
jrmccluskey:jules/add-openai-model-handler
Closed

[Jules] Add OpenAI Remote Model Handler implementation#35498
jrmccluskey wants to merge 11 commits intoapache:masterfrom
jrmccluskey:jules/add-openai-model-handler

Conversation

@jrmccluskey
Copy link
Copy Markdown
Contributor

Change 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

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:

  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

google-labs-jules Bot and others added 8 commits July 1, 2025 16:36
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`.
@jrmccluskey jrmccluskey force-pushed the jules/add-openai-model-handler branch from a03ca08 to f118195 Compare July 1, 2025 20:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 1, 2025

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.

@github-actions github-actions Bot added the stale label Sep 1, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 9, 2025

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.

@github-actions github-actions Bot closed this Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant