Skip to content

feat(firebase-ai): create ai package, vertexai wraps around it #8555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 72 commits into
base: main
Choose a base branch
from

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Jun 3, 2025

Description

  • Moved the bulk of code to new ai package. Kept relevant types in vertexai package and deprecated them.
  • Updated implementation (where possible) to match firebase-js-sdk.
  • Updated mocks to match latest implementation on vertexai-sdk-test-data repo which now segments responses from vertexai and googleai.
  • I did attempt to symlink ai into vertexai but nested symlinks within directories were not being packaged in dist/ so opted to make ai package a dependency which I think is a better way of doing it.
  • Created an ai example app for illustration and tested latest vertexai and ai implementations which surfaced a couple of subtle bugs that have been resolved.

Important

  • We need to do the same attribution as we did for vertexai for this pull request.
  • Double check what needs to be in the CHANGELOG for this release.

Related issues

Release Summary

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan


Think react-native-firebase is great? Please consider supporting the project with any of the below:

Copy link

vercel bot commented Jun 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-firebase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 8:53am

@mikehardy
Copy link
Collaborator

Looking into this one now for review - noticed Other tests were failing because TextEncoder implementation seems to be missing and is needed ? Unexpected as it seems that should have been failing for a while if so, but...okay

rebased to main and put an in situ implementation of the string -> uint8array conversion in the storage library and it passes locally, hopefully this goes green in CI - will finish the review later

Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

✅ Looks like all old comments are resolved
✅ LGTM and runs locally okay except windows and one comment nit

The windows thing has bothered me for a while - I made sure the repo was windows-capable for development a long time back and we have received some PRs from folks that only have access to windows machines - more common than you might think!

❓ Rather than moan about it and keep wishing, I ported the AI mock responses script to typescript and verified it works on windows and macOS now ✅ - added a commit there as well as a couple unit test plugin fixups for windows compliance

❓ I left one teeny tiny note on the param comment to a function - initializeApp - now that it has a new signature I think the comment needs an update

That - the update to the comment - is the only thing I can think of

If that's updated (could just commit the suggestion if it works?) and you like the AI test data git clone port, this is good to go for me

@mikehardy mikehardy added the Workflow: Pending Merge Waiting on CI or similar label Aug 6, 2025
The new Firebase AI Logic SDK provides **preview** support for the Gemini Developer API, including its free tier offering.
Using the Firebase AI Logic SDK with the Vertex AI Gemini API is still generally available (GA).

To start using the new SDK, import the `@react-native-firebase/ai` package and use the modular method `getAI()` to initialize. See details in the [migration guide](https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk).

Choose a reason for hiding this comment

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

I like the in general changelog. The only thing I think we would like to add, since RN is not listed in the official migration guide doc, we probably want to actually have the code change example here.

@@ -0,0 +1,112 @@
/**
* @license
* Copyright 2024 Google LLC

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC

@@ -0,0 +1,55 @@
/**
* @license
* Copyright 2024 Google LLC

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC

Choose a reason for hiding this comment

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

Do we also want to add GoogleAI backend test cases as well?

@@ -0,0 +1,167 @@
/**
* @license
* Copyright 2024 Google LLC

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC


it('total tokens with modality details', async () => {
const mockResponse = getMockResponse(
BackendName.VertexAI,

Choose a reason for hiding this comment

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

for my education, we are having the fakeAPI backend set to googleAI, but in the getMockResponse we pass the backend as VertexAI, is that going to have any issue?

@@ -0,0 +1,365 @@
/**
* @license
* Copyright 2024 Google LLC

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC

@@ -0,0 +1,92 @@
/**
* @license
* Copyright 2024 Google LLC

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC

@@ -0,0 +1,125 @@
import { ApiSettings } from '../types/internal';

Choose a reason for hiding this comment

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

License header?

@@ -0,0 +1,2 @@
export * from './ai-model';

Choose a reason for hiding this comment

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

Just wondering, do we need license header for index.ts?

@@ -0,0 +1,137 @@
/**
* @license
* Copyright 2024 Google LLC

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Workflow: Pending Merge Waiting on CI or similar
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants