Skip to content

Remove deprecated APIs and internalize response constructors in firebase-ai - #8563

Open
VinayGuthal wants to merge 3 commits into
mainfrom
clean_up
Open

Remove deprecated APIs and internalize response constructors in firebase-ai#8563
VinayGuthal wants to merge 3 commits into
mainfrom
clean_up

Conversation

@VinayGuthal

@VinayGuthal VinayGuthal commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Cleans up the firebase-ai public API surface by removing deprecated classes, methods, and properties, and marking constructors of SDK-emitted response/status models as internal.

Removed Deprecated Classes & APIs
Restricted Constructors on Output/Status Types to internal
Tests & API Signatures updated
Removed VERTEX_AI and used AgentPlatform instead.

@github-actions

Copy link
Copy Markdown
Contributor

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@google-oss-bot

Copy link
Copy Markdown
Collaborator

Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR or 'NO_RELEASE_CHANGE' to the description to silence this warning.)

@gemini-code-assist

Copy link
Copy Markdown
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
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 the 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 counterproductive. 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.

@VinayGuthal VinayGuthal changed the title remove deprecated code Remove deprecated APIs and internalize response constructors in firebase-ai Aug 31, 2026
@VinayGuthal

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 cleans up the API by removing deprecated classes and methods (such as the vertexAI backend, MediaData, Voices, and GroundingAttribution), making several constructors internal to prevent external instantiation, and renaming internal "Bidi" components to "Live". The review feedback suggests several Kotlin-specific improvements, such as declaring DownloadStatus as a sealed class and converting stateless classes like DownloadCompleted and LiveServerSetupComplete into objects. It also recommends updating outdated variable names and comments that still refer to 'Vertex AI' to reflect the transition to 'Agent Platform'.

Comment on lines 185 to +187
/** An abstract class representing the status of an on-device model download operation. */
@PublicPreviewAPI
public abstract class DownloadStatus {
public abstract class DownloadStatus internal constructor() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since DownloadStatus has an internal constructor() and cannot be subclassed outside of this module, it is effectively sealed. Declaring it as a sealed class instead of an abstract class is more idiomatic in Kotlin and enables exhaustive when expressions for Kotlin consumers.

Suggested change
/** An abstract class representing the status of an on-device model download operation. */
@PublicPreviewAPI
public abstract class DownloadStatus {
public abstract class DownloadStatus internal constructor() {
/** A sealed class representing the status of an on-device model download operation. */
@PublicPreviewAPI
public sealed class DownloadStatus internal constructor() {

Comment on lines 212 to 216
/** Represents when a download has successfully completed. */
public class DownloadCompleted : DownloadStatus() {
public class DownloadCompleted internal constructor() : DownloadStatus() {
override fun equals(other: Any?): Boolean = other is DownloadCompleted
override fun hashCode(): Int = javaClass.hashCode()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since DownloadCompleted is stateless and its constructor is now internal, it is more idiomatic and efficient to define it as an object instead of a class. This avoids unnecessary allocations and removes the need for manual equals and hashCode overrides.

  /** Represents when a download has successfully completed. */
  public object DownloadCompleted : DownloadStatus()

Comment on lines +133 to 136
public class LiveServerSetupComplete internal constructor() : LiveServerMessage {
@Serializable
internal data class Internal(val setupComplete: JsonObject) : InternalLiveServerMessage {
override fun toPublic() = LiveServerSetupComplete()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since LiveServerSetupComplete is stateless and its constructor is now internal, it is more idiomatic and efficient to define it as an object instead of a class. This avoids unnecessary allocations.

Suggested change
public class LiveServerSetupComplete internal constructor() : LiveServerMessage {
@Serializable
internal data class Internal(val setupComplete: JsonObject) : InternalLiveServerMessage {
override fun toPublic() = LiveServerSetupComplete()
public object LiveServerSetupComplete : LiveServerMessage {
@Serializable
internal data class Internal(val setupComplete: JsonObject) : InternalLiveServerMessage {
override fun toPublic() = LiveServerSetupComplete


public val vertexAIFlashModel: GenerativeModel by lazy {
getGenerativeModel(GenerativeBackend.vertexAI("global"), "gemini-3.5-flash")
getGenerativeModel(GenerativeBackend.agentPlatform("global"), "gemini-3.5-flash")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

Since the backend has been changed from vertexAI to agentPlatform, consider renaming the variables vertexAIFlashModel, vertexAIFlashLiteModel, and vertexAI3_5FlashModel to use agentPlatform (e.g., agentPlatformFlashModel) to avoid confusion and keep the naming consistent with the actual backend being used.

}
public val vertexAITemplateModel: TemplateGenerativeModel by lazy {
FirebaseAI.getInstance(app(), GenerativeBackend.vertexAI()).templateGenerativeModel()
FirebaseAI.getInstance(app(), GenerativeBackend.agentPlatform()).templateGenerativeModel()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

Since the backend has been changed from vertexAI to agentPlatform, consider renaming vertexAITemplateModel to agentPlatformTemplateModel to avoid confusion and keep the naming consistent with the actual backend being used.

// Initialize the Vertex AI Gemini API backend service.
TemplateGenerativeModel templateModel =
FirebaseAI.getInstance(GenerativeBackend.vertexAI("global")).templateGenerativeModel();
FirebaseAI.getInstance(GenerativeBackend.agentPlatform("global")).templateGenerativeModel();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

The comment on line 60 still refers to "Vertex AI Gemini API". Consider updating it to "Agent Platform" to match the updated backend.

// Create a `TemplateGenerativeModel` instance.
TemplateGenerativeModel model =
FirebaseAI.getInstance(GenerativeBackend.vertexAI("global")).templateGenerativeModel();
FirebaseAI.getInstance(GenerativeBackend.agentPlatform("global")).templateGenerativeModel();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

The comment on line 92 still refers to "Vertex AI Gemini API". Consider updating it to "Agent Platform" to match the updated backend.

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.

2 participants