Skip to content

Bits for migrating to vertex #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ resource "google_project_service" "services" {

# generativelanguage.googleapis.com is designed for experimentation only. A low initial quota
# is set to protect the project. To use Gemini AI in a production environment, migrate to Vertex AI in
# Firebase. See prod.tf for more details.
# Firebase. See prod.tf.example for more details.
resource "google_service_usage_consumer_quota_override" "generativelanguage" {
project = var.project
service = "generativelanguage.googleapis.com"
Expand Down Expand Up @@ -149,7 +149,7 @@ resource "local_file" "environment_ts" {
{
project_id = data.google_project.project.project_id,
gemini_api_key = google_apikeys_key.generativelanguage.key_string,
debug_token = "" # Use local.uuid4 in when using Vertex AI in Firebase
debug_token = "" # TODO: Use local.uuid4 in when using Vertex AI in Firebase
}
))
filename = "${path.module}/src/environments/environments.ts"
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { initializeApp, provideFirebaseApp, getApp } from '@angular/fire/app';
// TODO: Recommended to use together with Vertex AI
import {
ReCaptchaEnterpriseProvider,
initializeAppCheck,
Expand All @@ -36,6 +37,7 @@ export const appConfig: ApplicationConfig = {
provideFirebaseApp(() =>
initializeApp(environment.firebase),
),
// TODO
// Turn on app check for Vertex AI in Firebase
// provideAppCheck(() => {
// TODO: don't use debug token in prod
Expand Down
2 changes: 2 additions & 0 deletions src/app/services/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { GoogleGenerativeAIFetchError } from '@google/generative-ai';
import { v4 as uuidv4 } from 'uuid';
import { GoogleGenerativeAI } from '@google/generative-ai';
import { environment } from '../../environments/environments';
// TODO: import Vertex AI
import { getVertexAI, getGenerativeModel } from 'firebase/vertexai-preview';

type Priority = 'none' | 'low' | 'medium' | 'high';
Expand Down Expand Up @@ -87,6 +88,7 @@ export class TaskService {
private firestore = inject(Firestore);
private auth = inject(Auth);

// TODO: Use Vertex AI
private vertexAI = getVertexAI(getApp());
// Caveat: the VertexAI model may take a while (~10s) to initialize after your
// first call to GenerateContent(). You may see a PERMISSION_DENIED error before then.
Expand Down