Skip to content

refactor(ai): Use GenerativeAIService in GeminiLanguageModel#16284

Open
andrewheard wants to merge 4 commits into
wwdc26-preview-devfrom
ah/wwdc26-rm-generativemodel-dep
Open

refactor(ai): Use GenerativeAIService in GeminiLanguageModel#16284
andrewheard wants to merge 4 commits into
wwdc26-preview-devfrom
ah/wwdc26-rm-generativemodel-dep

Conversation

@andrewheard

Copy link
Copy Markdown
Contributor

Refactored GeminiLanguageModel to directly call GenerativeAIService instead of going through GenerativeModel. GeminiLanguageModel now holds an instance of the GenerativeAIService and constructs the GenerateContentRequest itself.

#no-changelog

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

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request refactors the GeminiLanguageModel to interact directly with the GenerativeAIService, streamlining the request construction process by handling GenerateContentRequest internally. Additionally, it updates platform availability annotations across several components to support newer OS versions and improves test robustness regarding error handling.

Highlights

  • Refactoring to GenerativeAIService: GeminiLanguageModel now directly utilizes GenerativeAIService for content generation, bypassing the previous GenerativeModel abstraction and handling GenerateContentRequest construction internally.
  • Availability Updates: Updated availability annotations across multiple files to include watchOS 27.0 and set minimum requirements to iOS 27.0, macOS 27.0, and visionOS 27.0.
  • Test Suite Adjustments: Updated ResponseStreamTests to accommodate compiler-specific error handling logic for FoundationModels integration.
New Features

🧠 You can now enable Memory (public preview) 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.

Activity
  • Pull request created by andrewheard.
  • Gemini Code Assist bot provided usage instructions.
  • Author requested a summary via /gemini summary.

@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 expands platform support for FoundationModels (specifically adding watchOS 27.0 support) and refactors GeminiLanguageModel and its executor to directly utilize GenerativeAIService and GenerateContentRequest instead of routing through FirebaseAI. The review feedback correctly highlights critical compilation risks: simplifying the compilation guards to only check the compiler version (e.g., #if compiler(>=6.4)) without verifying canImport(FoundationModels) and IS_FOUNDATION_MODELS_SUPPORTED_PLATFORM will cause build failures on unsupported platforms. It is highly recommended to restore these conditional checks and update their corresponding #endif comments across the modified files.

Comment thread FirebaseAI/Sources/FirebaseAI.swift
Comment thread FirebaseAI/Sources/FirebaseAI.swift
Comment thread FirebaseAI/Sources/Types/Public/GeminiLanguageModel.swift
Comment thread FirebaseAI/Sources/Types/Public/GeminiLanguageModelExecutor.swift Outdated
Comment thread FirebaseAI/Sources/Types/Public/GeminiLanguageModelExecutor.swift Outdated
@andrewheard andrewheard marked this pull request as ready for review June 17, 2026 17:08
@andrewheard andrewheard requested a review from a team as a code owner June 17, 2026 17:08
@andrewheard andrewheard requested a review from paulb777 June 17, 2026 17:08

@paulb777 paulb777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not blocking for this PR, but should we add integration tests for Foundation Models, even if they can't run in CI yet?

@andrewheard

Copy link
Copy Markdown
Contributor Author

Not blocking for this PR, but should we add integration tests for Foundation Models, even if they can't run in CI yet?

@paulb777 They aren't extensive yet but we do have some: https://github.com/firebase/firebase-ios-sdk/blob/wwdc26-preview-dev/FirebaseAI/Tests/TestApp/Tests/Integration/GeminiLanguageModelTests.swift

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants