Skip to content

Conversation

@rlazo
Copy link
Collaborator

@rlazo rlazo commented Feb 9, 2026

Introduces a new internal architecture for generative model providers, allowing for flexible integration of different generative AI backends.

Key changes include:

  • Added GenerativeModelProvider interface to define common operations for generative models.
  • Implemented CloudGenerativeModelProvider for interacting with cloud-based generative AI services.
  • Implemented OnDeviceModelProvider to support on-device generative AI models, including logic for handling text and image parts in prompts and mapping interop types.
  • Introduced FallbackGenerativeModelProvider to enable a primary model with a configurable fallback to a secondary model based on a precondition or exceptions.
  • Added MissingOnDeviceModelProvider as a placeholder for when on-device models are not available.
  • Modified Candidate to include a fromInterop method for converting on-device model responses.
  • Changed GenerateContentResponse constructor visibility to internal to accommodate new provider implementations.

Test added for:

  • FallbackGenerativeModelProvider.kt
  • OnDeviceGenerativeModelProvider.kt

Test not needed for:

  • GenerativeModelProvider.kt Is an interface
  • MissingOnDeviceGenerativeModelProvider.kt Only throws exceptions
  • CloudGenerativeModelProvider.kt All the SDK test suite verifies that it works

Introduces a new internal architecture for generative model providers,
allowing for flexible integration of different generative AI backends.

Key changes include:
- Added `GenerativeModelProvider` interface to define common
operations for generative models.
- Implemented `CloudGenerativeModelProvider` for interacting with
cloud-based generative AI services.
- Implemented `OnDeviceModelProvider` to support on-device generative
AI models, including logic for handling text and image parts in
prompts and mapping interop types.
- Introduced `FallbackGenerativeModelProvider` to enable a primary
model with a configurable fallback to a secondary model based on a
precondition or exceptions.
- Added `MissingOnDeviceModelProvider` as a placeholder for when
on-device models are not available.
- Modified `Candidate` to include a `fromInterop` method for
converting on-device model responses.
- Changed `GenerateContentResponse` constructor visibility to
`internal` to accommodate new provider implementations.
@gemini-code-assist
Copy link
Contributor

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

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.

@rlazo
Copy link
Collaborator Author

rlazo commented Feb 9, 2026

/gemini review

@google-oss-bot
Copy link
Collaborator

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

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 a well-designed internal architecture for generative model providers, which significantly improves flexibility for integrating different AI backends. The separation of concerns with CloudGenerativeModelProvider, OnDeviceModelProvider, and FallbackGenerativeModelProvider is clean and effective. My review includes a couple of suggestions for the OnDeviceModelProvider to enhance its robustness and configurability.

@rlazo
Copy link
Collaborator Author

rlazo commented Feb 9, 2026

/gemini review

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 a new internal architecture for generative model providers, which is a great step towards a more flexible and maintainable system. The new GenerativeModelProvider interface and its various implementations (Cloud, OnDevice, Fallback, Missing) are well-designed and effectively abstract away the specifics of different AI backends. The changes to related data classes like Candidate and GenerateContentResponse are consistent with this new architecture. My review includes a few suggestions to further improve maintainability by reducing some code duplication in the new provider implementations. Overall, this is a solid contribution.

@google-oss-bot
Copy link
Collaborator

The public api surface has changed for the subproject firebase-ai:
error: Added constructor com.google.firebase.ai.OnDeviceConfig(com.google.firebase.ai.InferenceMode,Integer,Float,Integer,Integer,int) [AddedMethod]
error: Added method com.google.firebase.ai.OnDeviceConfig.getCandidateCount() [AddedMethod]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

@google-oss-bot
Copy link
Collaborator

The public api surface has changed for the subproject firebase-ai:
error: Added constructor com.google.firebase.ai.OnDeviceConfig(com.google.firebase.ai.InferenceMode,Integer,Float,Integer,Integer,int) [AddedMethod]
error: Added method com.google.firebase.ai.OnDeviceConfig.getCandidateCount() [AddedMethod]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

Copy link
Collaborator

@emilypgoogle emilypgoogle left a comment

Choose a reason for hiding this comment

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

Surface level naming consistency comments, contents seem fine

@rlazo rlazo requested a review from emilypgoogle February 10, 2026 00:44
@rlazo
Copy link
Collaborator Author

rlazo commented Feb 10, 2026

Test coverage should be good now:

Test added for:

  • FallbackGenerativeModelProvider.kt
  • OnDeviceGenerativeModelProvider.kt

Test not needed for:

  • GenerativeModelProvider.kt Is an interface
  • MissingOnDeviceGenerativeModelProvider.kt Only throws exceptions
  • CloudGenerativeModelProvider.kt All the SDK test suite verifies that it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants