Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ import { } from '@angular/fire/app-check';
<tr>
<td>

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

Expand Down
53 changes: 53 additions & 0 deletions docs/ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<small>
<a href="https://github.com/angular/angularfire">AngularFire</a> &#10097; <a href="../README.md#developer-guide">Developer Guide</a> &#10097; AI Logic
</small>

# AI Logic

Firebase AI Logic gives you access to the latest generative AI models from Google: the Gemini models and Imagen models.

[Learn more](https://firebase.google.com/docs/ai-logic)

## Dependency Injection

As a prerequisite, ensure that `AngularFire` has been added to your project via
```bash
ng add @angular/fire
```

Provide an AI instance in the application's `app.config.ts`:

```ts
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { provideAI, getAI } from '@angular/fire/ai';

export const appConfig: ApplicationConfig = {
providers: [
provideFirebaseApp(() => initializeApp({ ... })),
provideAI(() => getAI()),
...
],
...,
}
```

Next inject `AI` into your component:

```typescript
import { Component, inject } from '@angular/core';
import { AI } from '@angular/fire/ai';

@Component({ ... })
export class MyComponent {
private ai = inject(AI);
...
}
```

## Firebase API

AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.

Update the imports from `import { ... } from 'firebase/ai'` to `import { ... } from '@angular/fire/ai'` and follow the official documentation.

[Getting Started](https://firebase.google.com/docs/ai-logic/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/ai)
53 changes: 0 additions & 53 deletions docs/vertexai.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/schematics/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const enum FEATURES {
Firestore,
Storage,
RemoteConfig,
VertexAI,
AI,
}

export const featureOptions = [
Expand All @@ -27,7 +27,7 @@ export const featureOptions = [
{ name: 'Performance Monitoring', value: FEATURES.Performance },
{ name: 'Cloud Storage', value: FEATURES.Storage },
{ name: 'Remote Config', value: FEATURES.RemoteConfig },
{ name: 'Vertex AI', value: FEATURES.VertexAI },
{ name: 'AI', value: FEATURES.AI },
];

export const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun, WebFrameworks }
Expand Down
10 changes: 5 additions & 5 deletions src/schematics/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ export function featureToRules(
"@angular/fire/remote-config"
)}(() => getRemoteConfig())`;
});
case FEATURES.VertexAI:
case FEATURES.AI:
return addRootProvider(projectName, ({ code, external }) => {
external("getVertexAI", "@angular/fire/vertexai");
external("getAI", "@angular/fire/ai");
return code`${external(
"provideVertexAI",
"@angular/fire/vertexai"
)}(() => getVertexAI())`;
"provideAI",
"@angular/fire/ai"
)}(() => getAI())`;
});
default:
return undefined;
Expand Down
Loading