Skip to content

Commit f1f0772

Browse files
committed
fix: Replace Vertex AI with AI Logic
1 parent ac3dd7c commit f1f0772

5 files changed

Lines changed: 62 additions & 62 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ import { } from '@angular/fire/app-check';
174174
<tr>
175175
<td>
176176

177-
#### [Vertex AI](docs/vertexai.md#vertex-ai)
177+
#### [AI Logic](docs/ai.md#ai-logic)
178178
```ts
179-
import { } from '@angular/fire/vertexai';
179+
import { } from '@angular/fire/ai';
180180
```
181181
</td>
182182

docs/ai.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<small>
2+
<a href="https://github.com/angular/angularfire">AngularFire</a> &#10097; <a href="../README.md#developer-guide">Developer Guide</a> &#10097; AI Logic
3+
</small>
4+
5+
# AI Logic
6+
7+
Firebase AI Logic gives you access to the latest generative AI models from Google: the Gemini models and Imagen models.
8+
9+
[Learn more](https://firebase.google.com/docs/ai-logic)
10+
11+
## Dependency Injection
12+
13+
As a prerequisite, ensure that `AngularFire` has been added to your project via
14+
```bash
15+
ng add @angular/fire
16+
```
17+
18+
Provide an AI instance in the application's `app.config.ts`:
19+
20+
```ts
21+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
22+
import { provideAI, getAI } from '@angular/fire/ai';
23+
24+
export const appConfig: ApplicationConfig = {
25+
providers: [
26+
provideFirebaseApp(() => initializeApp({ ... })),
27+
provideAI(() => getAI()),
28+
...
29+
],
30+
...,
31+
}
32+
```
33+
34+
Next inject `AI` into your component:
35+
36+
```typescript
37+
import { Component, inject } from '@angular/core';
38+
import { AI } from '@angular/fire/ai';
39+
40+
@Component({ ... })
41+
export class MyComponent {
42+
private ai = inject(AI);
43+
...
44+
}
45+
```
46+
47+
## Firebase API
48+
49+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
50+
51+
Update the imports from `import { ... } from 'firebase/ai'` to `import { ... } from '@angular/fire/ai'` and follow the official documentation.
52+
53+
[Getting Started](https://firebase.google.com/docs/ai-logic/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/ai)

docs/vertexai.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/schematics/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const enum FEATURES {
1212
Firestore,
1313
Storage,
1414
RemoteConfig,
15-
VertexAI,
15+
AI,
1616
}
1717

1818
export const featureOptions = [
@@ -27,7 +27,7 @@ export const featureOptions = [
2727
{ name: 'Performance Monitoring', value: FEATURES.Performance },
2828
{ name: 'Cloud Storage', value: FEATURES.Storage },
2929
{ name: 'Remote Config', value: FEATURES.RemoteConfig },
30-
{ name: 'Vertex AI', value: FEATURES.VertexAI },
30+
{ name: 'AI', value: FEATURES.AI },
3131
];
3232

3333
export const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun, WebFrameworks }

src/schematics/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,13 @@ export function featureToRules(
293293
"@angular/fire/remote-config"
294294
)}(() => getRemoteConfig())`;
295295
});
296-
case FEATURES.VertexAI:
296+
case FEATURES.AI:
297297
return addRootProvider(projectName, ({ code, external }) => {
298-
external("getVertexAI", "@angular/fire/vertexai");
298+
external("getAI", "@angular/fire/ai");
299299
return code`${external(
300-
"provideVertexAI",
301-
"@angular/fire/vertexai"
302-
)}(() => getVertexAI())`;
300+
"provideAI",
301+
"@angular/fire/ai"
302+
)}(() => getAI())`;
303303
});
304304
default:
305305
return undefined;

0 commit comments

Comments
 (0)