Skip to content

Conversation

@MengqinShen
Copy link
Contributor

@MengqinShen MengqinShen commented Dec 23, 2025

This PR is to fix the google-genai plugin encoding problem observed during the bug bash of Genkit Python.
CHANGELOG:

  • Update the the PartConverter class to add the Data URI prefix when the model returns an image/media.
  • Support both raw base64 and Data URIs as input.
  • Update the relevant files to enable the revised encoding method.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MengqinShen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue with how media parts are encoded in responses within the google-genai plugin. The core change involves adopting the Data URI scheme for representing inline media data, which standardizes the format and ensures consistent handling and parsing across the plugin's components. This enhancement improves the reliability and correctness of media data processing when interacting with the Gemini API.

Highlights

  • Standardized Media Encoding: Media parts in responses are now consistently encoded using the Data URI scheme (e.g., data:image/png;base64,...) instead of raw base64 strings, improving interoperability and clarity.
  • Consistent Data Handling: Logic has been introduced to correctly parse and extract base64 data from Data URIs when converting to and from Gemini API formats, ensuring accurate data exchange.
  • Test Updates: Existing tests for both Gemini and Imagen models have been updated to correctly handle the new Data URI format for media URLs in responses.
  • Sample Application Model Update: The google-genai-hello sample application has been updated to utilize the googleai/gemini-2.0-flash-exp model for image generation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix the encoding of media parts in responses from the google-genai plugin by using data URIs. The changes correctly format image data into data URIs when creating Media parts in imagen.py and utils.py. The tests are also updated to handle the new data URI format. However, I found an issue in utils.py where a base64-encoded string is passed to a field expecting bytes when converting a MediaPart to a Gemini part. This will likely cause an error. I've provided a suggestion to fix this and make the code more robust by handling unsupported URL formats.

@MengqinShen MengqinShen requested a review from yesudeep December 23, 2025 01:11
@MengqinShen MengqinShen marked this pull request as ready for review December 23, 2025 01:21
@yesudeep yesudeep merged commit a535008 into main Dec 23, 2025
10 checks passed
@yesudeep yesudeep deleted the elisa/fix(py)/updating-google-genai-plugin-encoding branch December 23, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants