You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 36bab40
Browse filesBrowse the repository at this point in the historyBrowse files
fix(schematics): emit AgentPlatformBackend from the v21 AI migration
`ng update` rewrote an AngularFire 20 app's `getVertexAI(...)` calls to
`new VertexAIBackend()`, a class the Firebase SDK has deprecated.
A call that passed a `location` keeps it. A call that passed none, or a falsy
one, moves to the 'global' location, so the migration warns once for each file
whose region changed, once where a location is an expression only runtime can
resolve, and informs the user when the workspace calls the Live API, which
Firebase does not serve from 'global'.
Five specs cover the emitted class: one ties it to the declared firebase
minimum, four compile the migration's output against the installed SDK.
Fixes#3758
> Firebase AI Logic was previously called **Vertex AI in Firebase**. If you are upgrading from AngularFire 20, the module moved from `@angular/fire/vertexai` to `@angular/fire/ai` and most symbols were renamed (`provideVertexAI` to `provideAI`, `VertexAI` to `AI`). One is not a rename: plain `getAI()` uses the Gemini Developer API backend, so the old `getVertexAI()` maps to `getAI(app, { backend: new VertexAIBackend() })`. Running `ng update @angular/fire` rewrites all of this for you and keeps your app on the Vertex AI backend. See the [AngularFire 20 to 21 upgrade guide](./version-21-upgrade.md).
11
+
> Firebase AI Logic was previously called **Vertex AI in Firebase**. If you are upgrading from AngularFire 20, the module moved from `@angular/fire/vertexai` to `@angular/fire/ai` and most symbols were renamed (`provideVertexAI` to `provideAI`, `VertexAI` to `AI`). One is not a rename: plain `getAI()` uses the Gemini Developer API backend, so the old `getVertexAI()` maps to `getAI(app, { backend: new AgentPlatformBackend() })`. Running `ng update @angular/fire` rewrites all of this for you and keeps your app on the same backend, though a call that passed no `location` moves from `us-central1` to `global`. See the [AngularFire 20 to 21 upgrade guide](./version-21-upgrade.md).
Copy file name to clipboardExpand all lines: docs/version-21-upgrade.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The Vertex AI module has been renamed to Firebase AI Logic. The `@angular/fire/v
20
20
21
21
| Before (`@angular/fire/vertexai`) | After (`@angular/fire/ai`) |
22
22
|---|---|
23
-
|`getVertexAI(app?, { location? })`|`getAI(app, { backend: new VertexAIBackend(location?) })`|
23
+
|`getVertexAI(app?, { location? })`|`getAI(app, { backend: new AgentPlatformBackend(location?) })`|
24
24
|`provideVertexAI`|`provideAI`|
25
25
|`VertexAI`|`AI`|
26
26
|`VertexAIError`|`AIError`|
@@ -30,7 +30,30 @@ The Vertex AI module has been renamed to Firebase AI Logic. The `@angular/fire/v
30
30
|`vertexAIInstance$`|`AIInstance$`|
31
31
|`VertexAIModule`|`AIModule`|
32
32
33
-
**`getVertexAI` is not a plain rename.**`getAI` already existed alongside it, and a plain `getAI()` call talks to the Gemini Developer API backend, not to Vertex AI. The equivalent of `getVertexAI()` is `getAI(app, { backend: new VertexAIBackend() })`, which is what the migration writes, so your app keeps calling the Vertex AI backend it was configured, enabled, and billed for. A `location` option moves into the `VertexAIBackend` constructor.
33
+
### `getVertexAI` is not a plain rename
34
+
35
+
`getAI` already existed alongside it, and a plain `getAI()` call talks to the Gemini Developer API backend, not to the Agent Platform Gemini API (formerly Vertex AI). The equivalent of `getVertexAI()` is `getAI(app, { backend: new AgentPlatformBackend() })`, which is what the migration writes, so your app keeps calling the backend it was configured, enabled, and billed for. A `location` option moves into the `AgentPlatformBackend` constructor.
36
+
37
+
### The default region changes
38
+
39
+
`getVertexAI()` with no `location` resolved to `us-central1`. `AgentPlatformBackend` with no argument resolves to `global`. Firebase suggests `global` when your model supports it, and the Gemini 3.x models are only available there, which is why the migration writes it. To keep the region you had instead, write `new AgentPlatformBackend('us-central1')`.
40
+
41
+
Review this before deploying if your project has a data residency requirement.
42
+
43
+
#### Which calls move, and what the migration tells you
44
+
45
+
- A call that passed a non-empty `location` string keeps it, so its region does not move.
46
+
- A call that passed no `location`, or an empty one, moves to `global`. `getVertexAI` treated an empty value as `us-central1`, and `AgentPlatformBackend` treats it as `global`. The migration drops the empty value rather than writing it through, and warns.
47
+
- A call whose `location` is an expression the migration cannot read gets its own warning, because only your runtime knows whether that value is empty.
48
+
- A call whose options the migration cannot rewrite at all, such as a quoted `{ 'location': ... }` key, is left as written and warned about separately. Its import still moves, so it stops compiling until you migrate it by hand.
49
+
50
+
Each of those warnings is emitted once per file, so a file that has both a moved region and an unreadable `location` produces two.
51
+
52
+
#### If your app uses the Live API, do not stay on `global`
53
+
54
+
Firebase does not support the `global` location for the Live API models, so `getLiveGenerativeModel` and `startAudioConversation` stop working there. When the migration sees either of them anywhere in your workspace it says so in the region warning. Pass `'us-central1'`, or another supported location, to `AgentPlatformBackend`.
55
+
56
+
### What the migration rewrites for you
34
57
35
58
`ng update @angular/fire` rewrites these imports and identifiers for you and logs every `getVertexAI` call it rewrites. `getGenerativeModel` keeps its name.
36
59
@@ -42,7 +65,7 @@ Code the migration cannot rewrite safely is left in place with a warning. The im
42
65
43
66
-**Options it cannot read:** when the `getVertexAI` call's options are not a literal `{ location }` object, or that literal references other symbols the migration is also rewriting.
44
67
-**The function used as a value:** when `getVertexAI` is stored or passed around rather than called directly.
45
-
-**Name collisions:** when a local declaration in the file reuses an imported symbol's name, or the file already gets `getAI` or `VertexAIBackend` from a source other than AI Logic.
68
+
-**Name collisions:** when a local declaration in the file reuses an imported symbol's name, or the file already gets `getAI` or `AgentPlatformBackend` from a source other than AI Logic.
46
69
-**Wildcard re-exports:** when a file has `export * from '@angular/fire/vertexai'`, that line stays as written, because rewriting it would silently rename your re-exported public symbols. Replace it with named re-exports by hand.
47
70
48
71
A file where a named `getVertexAI` import is used in a way that cannot be rewritten keeps every use of its named `getVertexAI` imports in place (namespace-style `ns.getVertexAI(...)` calls are judged per call), and each skipped call is logged.
Copy file name to clipboardExpand all lines: src/schematics/migration.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
},
9
9
"migration-v21": {
10
10
"version": "21.0.0",
11
-
"description": "Align the workspace's firebase dependency with the range @angular/fire 21 requires, and rewrite Vertex AI imports to Firebase AI Logic (getVertexAI callers keep the Vertex AI backend)",
11
+
"description": "Align the workspace's firebase dependency with the range @angular/fire 21 requires, and rewrite Vertex AI imports to Firebase AI Logic (getVertexAI callers keep the same backend, and a call that passed no location moves from us-central1 to global)",
0 commit comments