Skip to content

feat(vertexai): Add a new package firebase_ai #17332

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

Merged

Conversation

natebosch
Copy link
Contributor

@natebosch natebosch commented May 5, 2025

Copy all the code from firebase_vertexai and rename with "Vertex"
removed or replaced with "Firebase".

Make firebase_vertexai an export package, retaining only the
FirebaseVertexAI implementation and adding typedef aliases for 2
renamed exception types. Replace the rest with exports from
package:firebase_ai.

Revert the examples changes to use googleAI - the example in the
firebase_ai package will show both while the old example shows only
the usage of vertex..

Import from src across the packages to keep existing tests as close to
identical as possible despite doubling up test cases with the upstream
package.

Copy all the code from firebase_vertexai and rename with "Vertex"
removed or replaced with "Firebase".

Make firebase_vertexai an export package, retaining only the
FirebaseVertexAI implementation and adding `typedef` aliases for 2
renamed exception types. Replace the rest with exports from
`package:firebase_ai`.

Revert the examples changes to use googleAI - the example in the
`firebase_ai` package will show both while the old example shows only
the usage of vertex..

Import from src across the packages to keep existing tests as close to
identical as possible despite doubling up test cases with the upstream
package.
@natebosch natebosch requested a review from cynthiajoan May 5, 2025 20:35
@natebosch natebosch changed the base branch from main to vertexai/developer_api May 5, 2025 20:35
@natebosch natebosch changed the title vertexai/package rename Add a new package firebase_ai May 5, 2025
@natebosch natebosch changed the title Add a new package firebase_ai [feat] Add a new package firebase_ai May 5, 2025
@natebosch natebosch changed the title [feat] Add a new package firebase_ai feat(vertexai): Add a new package firebase_ai May 5, 2025
@natebosch
Copy link
Contributor Author

If you'd prefer to review and land any parts of this as separate commits I'm happy to split it up. Most of the LOC here are copy/paste (and lots of boilerplate for the flutter stuff) but there is no way to indicate a file rename in git so the review will show everything as new.

For the most part this reflects a global rename from FirebaseVertexAI* or VertexAI* to FirebaseAI*. Some URLs to help docs are not changed here and may need to be updated in coordination with the doc hosting.

@natebosch
Copy link
Contributor Author

We may need some CI config changes.

export 'src/chat.dart' show ChatSession, StartChatExtension;
export 'src/content.dart'
show
UsageMetadata,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was planning to remove this field, since there's no use case for developer to instantiate the UsageMetadata. Do you think it's a good time for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can drop the export of TaskType since I think that's unused.

Do we really want to remove this type? It's still user visible right? We can consider removing the public constructor, but if we expect user code to read from this class I think we do want to export it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, let's remove the public constructor in a follow up PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need to keep this test package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I think it's safe to drop stuff that isn't testing the public API.

@cynthiajoan
Copy link
Collaborator

We may need some CI config changes.

Yeah would need to add the new package to melos config.

@cynthiajoan cynthiajoan merged commit 0859ec7 into firebase:vertexai/developer_api May 8, 2025
21 of 26 checks passed
cynthiajoan added a commit that referenced this pull request May 13, 2025
* feat(vertexai): Allow serializing to Developer API models (#17294)

Move parsing from top level methods, and serialization from a method on
the model,into instance methods on a new `SerializationStrategy` class.
Use the existing parsing code for the vertex strategy and copy over code
form the developer SDK for the Google AI strategy.

Add a `_ModelUri` class to allow a vertex and developer specialization
for the different backends.

Copy the serialization and parsing tests from the developer SDK, skip a
few tests that rely on arguments or methods that are unsupported in the
vertex model. Tests skipped for content embedding and extra arguments
passed to countTokens.

* chore(vertexai): update sample for developer api and fix the instance key for FirebaseVertexAI  (#17319)

* add imagen developer api support (#17321)

* feat(vertexai): Add a new package firebase_ai (#17332)

* Add a new package firebase_ai

Copy all the code from firebase_vertexai and rename with "Vertex"
removed or replaced with "Firebase".

Make firebase_vertexai an export package, retaining only the
FirebaseVertexAI implementation and adding `typedef` aliases for 2
renamed exception types. Replace the rest with exports from
`package:firebase_ai`.

Revert the examples changes to use googleAI - the example in the
`firebase_ai` package will show both while the old example shows only
the usage of vertex..

Import from src across the packages to keep existing tests as close to
identical as possible despite doubling up test cases with the upstream
package.

* Move to new directory

* Add ::vertexai and ::googlai instance key suffixes

* Use ovrride and new SpeaechConfig API

* Remove export of TaskType

* Remove duplicate testing of the base model

* Use 2.0.0 as initial version

* Reformat

* Add a failing test - check if CI is already running

* Remove failing test

CI is confirmed running for this package.

* Add a copy of the analysis options in the new parent directory

* Revert to latest version of example app

Minor code changes for the interface change.

* Restore the same example app in both packages

Minor code changes in the _vertexai example app for the interface
differences

---------

Co-authored-by: Cynthia J <[email protected]>

* add all_link_rules.yaml to the root of new package

* chore(firebaseai): merge main into developer api branch (#17341)

* chore(ci): bump macos-14 to macos-15 (#17311)

* feat(cloud_functions): add support for cloud functions stream (#17214)

* chore: add platform interface and method channel implementation for Cloud Functions stream

* chore: add `httpsCallableStreamFromUrl` and `httpsStreamCallableWithUri`

* chore: resolve comments

* chore: add Android implementation for Cloud Functions stream

* chore: resolve formatting issues

* chore: correct variable name

* chore: add support for Cloud Functions Stream(Android)

* chore: create dedicated StreamHandler class

* chore: add streamhandler implementation for ios

* chore: add iOS implementation for Cloud Functions stream

* chore: add license header to stream handler files

* chore: web Cloud Functions stream wip

* chore: push all

* chore: update functions based on API Doc modification

* chore: clean up code

* chore: add web package

* chore: add streaming example

* chore: fix ci issues

* chore: fix ci

* chore: fix cloud function test

* chore: add missing doc

* chore: fixes and  clean up

* chore: add e2e for Cloud Functions Stream

* chore: fix formatting issue

* chore: add more tests and fix timeout for Android

* chore: add test for map and list

* chore: fix test

* chore: update year to 2025 in files

* chore(web): add support for abort signal

* chore: resolve comments and add test for Abort

* chore: fix test

* chore: fix test

* chore: update copyright year

* chore: print error to console

* chore(release): publish packages (#17314)

* chore(release): publish packages

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]+1

* chore: BoM Version 3.10.0

* constants

* fix(auth,apple): prevent EXC_BAD_ACCESS crash in Apple Sign-In completion handler (#17273)

- Locally captures completion handler to prevent deallocation
- Fixes crash during async Apple Sign-In operations

* chore(docs): Update Extension Helper Docs (#17327)

* feat(vertexai): Add HarmBlockThreshold.OFF (#17325)

* Add HarmBlockThreshold.OFF. Add unit test for api. Fix the schema output json.

* fix a nit

* feat(fdc): Included platform detection changes (#17308)

* feat(vertexai): Add responseModality (#17326)

* Add responseModality

* review comments

* handle omit tokenCount nicely (#17336)

* Add new attributes for schema (#17340)

* tweak after merge main

* fix analyzer for vertexai/api_test.dart

* remove dependency_overrides in pubspec.yaml

---------

Co-authored-by: MichaelV00 <[email protected]>
Co-authored-by: Jude Selase Kwashie <[email protected]>
Co-authored-by: Guillaume Bernos <[email protected]>
Co-authored-by: Luke Memet <[email protected]>
Co-authored-by: Maneesh Tewani <[email protected]>

* manually update the schema_test with main code

* add the deprecation document (#17344)

* ignore deprecated_member_use for example in firebase_vertexai

* fix bidi web socket channel connect for chrome

* review comments

* readme words update

* try ignore the deprecation in the whole package analysis_options

---------

Co-authored-by: Nate Bosch <[email protected]>
Co-authored-by: MichaelV00 <[email protected]>
Co-authored-by: Jude Selase Kwashie <[email protected]>
Co-authored-by: Guillaume Bernos <[email protected]>
Co-authored-by: Luke Memet <[email protected]>
Co-authored-by: Maneesh Tewani <[email protected]>
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