diff --git a/README.md b/README.md index 40c77f55e..8a5ff5f6f 100644 --- a/README.md +++ b/README.md @@ -174,9 +174,9 @@ import { } from '@angular/fire/app-check'; -#### [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'; ``` diff --git a/docs/ai.md b/docs/ai.md new file mode 100644 index 000000000..88839a1fe --- /dev/null +++ b/docs/ai.md @@ -0,0 +1,53 @@ + +AngularFireDeveloper Guide ❱ AI Logic + + +# 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) diff --git a/docs/vertexai.md b/docs/vertexai.md deleted file mode 100644 index cf978a5e8..000000000 --- a/docs/vertexai.md +++ /dev/null @@ -1,53 +0,0 @@ - -AngularFireDeveloper Guide ❱ Vertex AI - - -# Vertex AI (preview) - -The Vertex AI Gemini API gives you access to the latest generative AI models from Google: the Gemini models. - -[Learn more](https://firebase.google.com/docs/vertex-ai) - -## Dependency Injection - -As a prerequisite, ensure that `AngularFire` has been added to your project via -```bash -ng add @angular/fire -``` - -Provide a Vertex AI instance in the application's `app.config.ts`: - -```ts -import { provideFirebaseApp, initializeApp } from '@angular/fire/app'; -import { provideVertexAI, getVertexAI } from '@angular/fire/vertexai-preview'; - -export const appConfig: ApplicationConfig = { - providers: [ - provideFirebaseApp(() => initializeApp({ ... })), - provideVertexAI(() => getVertexAI()), - ... - ], - ..., -} -``` - -Next inject `VertexAI` into your component: - -```typescript -import { Component, inject } from '@angular/core'; -import { VertexAI } from '@angular/fire/vertexai'; - -@Component({ ... }) -export class MyComponent { - private vertexAI = inject(VertexAI); - ... -} -``` - -## 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/vertexai'` to `import { ... } from '@angular/fire/vertexai'` and follow the official documentation. - -[Getting Started](https://firebase.google.com/docs/vertex-ai/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/vertexai) diff --git a/src/schematics/interfaces.ts b/src/schematics/interfaces.ts index a21df2168..aac0f6e36 100644 --- a/src/schematics/interfaces.ts +++ b/src/schematics/interfaces.ts @@ -12,7 +12,7 @@ export const enum FEATURES { Firestore, Storage, RemoteConfig, - VertexAI, + AI, } export const featureOptions = [ @@ -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 } diff --git a/src/schematics/utils.ts b/src/schematics/utils.ts index d6e0d075a..f24b3f2fb 100644 --- a/src/schematics/utils.ts +++ b/src/schematics/utils.ts @@ -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;