From 6d66e98c3a425cea0b289864d942b12f9b74b666 Mon Sep 17 00:00:00 2001 From: Samuel Bushi Date: Thu, 11 Jul 2024 23:22:10 +0000 Subject: [PATCH] Add cloud scope for vertex authclient --- js/ai/tests/model/middleware_test.ts | 4 ++-- js/plugins/vertexai/src/index.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/ai/tests/model/middleware_test.ts b/js/ai/tests/model/middleware_test.ts index ab1c9664da..cebb68eb59 100644 --- a/js/ai/tests/model/middleware_test.ts +++ b/js/ai/tests/model/middleware_test.ts @@ -18,16 +18,16 @@ import assert from 'node:assert'; import { beforeEach, describe, it } from 'node:test'; import { DocumentData } from '../../src/document.js'; import { - defineModel, GenerateRequest, GenerateResponseData, MessageData, Part, + defineModel, } from '../../src/model.js'; import { - augmentWithContext, AugmentWithContextOptions, CONTEXT_PREFACE, + augmentWithContext, simulateSystemPrompt, validateSupport, } from '../../src/model/middleware.js'; diff --git a/js/plugins/vertexai/src/index.ts b/js/plugins/vertexai/src/index.ts index 48964bdb5d..1cf3889d55 100644 --- a/js/plugins/vertexai/src/index.ts +++ b/js/plugins/vertexai/src/index.ts @@ -90,13 +90,18 @@ export interface PluginOptions { modelGardenModels?: ModelReference[]; } +const CLOUD_PLATFROM_OAUTH_SCOPE = + 'https://www.googleapis.com/auth/cloud-platform'; + /** * Add Google Cloud Vertex AI to Genkit. Includes Gemini and Imagen models and text embedder. */ export const vertexAI: Plugin<[PluginOptions] | []> = genkitPlugin( 'vertexai', async (options?: PluginOptions) => { - const authClient = new GoogleAuth(options?.googleAuth); + const authClient = new GoogleAuth( + options?.googleAuth ?? { scopes: [CLOUD_PLATFROM_OAUTH_SCOPE] } + ); const projectId = options?.projectId || (await authClient.getProjectId()); const location = options?.location || 'us-central1';