Repository navigation
Add image generation code to Gemini Model Handler - #36177
Conversation
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
assign set of reviewers |
|
precommit failures are likely flakes unrelated to this PR |
|
Assigning reviewers: R: @damccorm for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
| return ( | ||
| pcoll | ||
| | "WriteImageToFile" >> beam.ParDo( | ||
| _WriteImageFn(self._output_dir, self._filename_prefix))) |
There was a problem hiding this comment.
| inference_args: any additional arguments passed to the generate_content | ||
| call. | ||
| """ | ||
| return model.models.generate_content( |
There was a problem hiding this comment.
This call is the exact same as the one to generate text - is the only difference in these apis that one accepts a list and one accepts a single text string? Or are there other things I'm missing?
This is surprisingly subtle IMO
There was a problem hiding this comment.
The type hinting is the major distinction here, the actual generation call to gemini is largely distinguished by the model you're calling (the docstring covers this somewhat.) The API is pretty simple from a user standpoint, the distinguishing request functions are really just to make sure we get reasonable typing in here.
|
Oh, please fix linting issues though |
|
Failures are unrelated, merging |
Adds extra code for generating images based on text prompts and contextual images to the GeminiModelHandler, focused on using the gemini-2.5-flash-image-preview model (AKA Nano Banana.) Based on the example code from https://ai.google.dev/gemini-api/docs/image-generation
Also fixes parsing code in the text example and the core model handler, which had been broken by changes to the Gemini API's return format.
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.