Skip to content

feat(js/plugins/google-genai): Support for googleai multimodal embedder#4905

Merged
ifielker merged 1 commit intomainfrom
if-embedder2
Mar 13, 2026
Merged

feat(js/plugins/google-genai): Support for googleai multimodal embedder#4905
ifielker merged 1 commit intomainfrom
if-embedder2

Conversation

@ifielker
Copy link
Collaborator

Checklist (if applicable):

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 significantly enhances the GoogleAI plugin by integrating support for multimodal embedding, enabling the processing of content that combines text and various media types. The changes involve extending the Document class to handle complex content structures, updating the embedder service to recognize and configure new multimodal models like gemini-embedding-2-preview, and ensuring that existing and new functionalities are properly tested and demonstrated in sample applications. This update broadens the capabilities of the embedding service to cater to more diverse data inputs.

Highlights

  • Multimodal Embedder Support: Introduced support for GoogleAI's multimodal embedder, specifically for the gemini-embedding-2-preview model, allowing embedding of content with both text and media parts.
  • Document Class Enhancement: Added a new static method Document.fromParts to facilitate the creation of documents from an array of content parts, essential for multimodal input.
  • Embedder Model Configuration: Updated the embedder configuration logic to dynamically retrieve schema and information based on the specific model name, improving flexibility for different embedding models.
  • Model Name Standardization: Replaced the deprecated text-embedding-004 model name with gemini-embedding-001 across various test applications and samples for consistency.
  • Multimodal Testing: Added dedicated test cases to verify the correct functionality of multimodal input embedding with the new gemini-embedding-2-preview model.

🧠 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.

Changelog
  • js/ai/src/document.ts
    • Added a static fromParts method to create a Document from an array of content parts.
  • js/plugins/google-genai/src/googleai/embedder.ts
    • Imported toGeminiMessage for content conversion.
    • Registered gemini-embedding-2-preview as a known multimodal embedder model with specific dimensions and supported input types.
    • Introduced EmbedderModelName type and isEmbedderName utility function.
    • Updated the model function to use model-specific configSchema and info when available.
    • Refactored content conversion in embedding requests to utilize toGeminiMessage.
  • js/plugins/google-genai/src/googleai/index.ts
    • Updated the embedder function signature to accept embedder.KnownModels or embedder.EmbedderModelName types.
  • js/plugins/google-genai/src/vertexai/embedder.ts
    • Introduced KnownModels, EmbedderModelName, and isEmbedderName type definitions for Vertex AI embedders.
  • js/plugins/google-genai/src/vertexai/index.ts
    • Updated the embedder function signature to accept embedder.KnownModels or embedder.EmbedderModelName types.
  • js/plugins/google-genai/tests/googleai/embedder_test.ts
    • Updated the role field in existing embedding request tests from an empty string to 'user'.
    • Added a new test case to verify multimodal input embedding using gemini-embedding-2-preview.
  • js/testapps/basic-gemini/src/index.ts
    • Imported the Document class.
    • Added a new flow embed-text to demonstrate text embedding with gemini-embedding-001.
    • Added a new flow embed-multimodal to demonstrate multimodal embedding with gemini-embedding-2-preview and Document.fromParts.
  • js/testapps/flow-simple-ai/src/index.ts
    • Updated embedder model names from text-embedding-004 to gemini-embedding-001 for both Google AI and Vertex AI embedders.
  • js/testapps/rag/src/pdf-rag-firebase.ts
    • Updated the embedder model name from text-embedding-004 to gemini-embedding-001.
  • samples/js-menu/src/genkit.ts
    • Updated the embedder model name from text-embedding-004 to gemini-embedding-001.
Activity
  • The author, ifielker, has marked the PR title as conforming to conventional commits and confirmed that the changes have been tested.
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 introduces support for the Google AI multimodal embedder, specifically gemini-embedding-2-preview. Key changes include adding a fromParts static method to the Document class, updating the embedder.ts to recognize the new multimodal model and handle its configuration, and modifying the EmbedContentRequest to correctly convert document content into the Gemini message format with a 'user' role. The changes also include necessary type updates for embedder model names and comprehensive test cases for the new multimodal embedding functionality. The updates to various test and sample applications to use gemini-embedding-001 for text embedding are also appropriate. Overall, the changes are well-implemented and directly support the stated objective of adding multimodal embedding capabilities.

@ifielker ifielker merged commit f84d219 into main Mar 13, 2026
7 checks passed
@ifielker ifielker deleted the if-embedder2 branch March 13, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants