From c2cb9126d3d95861f28fa34bb418ffdbde6ffd48 Mon Sep 17 00:00:00 2001 From: James Daniels Date: Wed, 15 May 2024 15:55:38 -0400 Subject: [PATCH] VertexAI docs --- README.md | 12 +++++++++++ docs/vertexai.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 docs/vertexai.md diff --git a/README.md b/README.md index e4e749e1f..1f10bab76 100644 --- a/README.md +++ b/README.md @@ -190,4 +190,16 @@ import { } from '@angular/fire/app-check'; ``` + + + +#### [Vertex AI](docs/vertexai.md#vertex-ai-preview) +```ts +import { } from '@angular/fire/vertexai-preview'; +``` + + + + + diff --git a/docs/vertexai.md b/docs/vertexai.md new file mode 100644 index 000000000..75ce2ad0e --- /dev/null +++ b/docs/vertexai.md @@ -0,0 +1,53 @@ + +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-preview'; + +@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-preview'` to `import { ... } from '@angular/fire/vertexai-preview'` 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-preview)