From f609445db5af139d57752ccdfbc5133c4767f679 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 30 Sep 2024 10:02:43 -0700 Subject: [PATCH 1/2] Update Vertex API_NOT_ENABLED error text --- packages/vertexai/src/requests/request.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/vertexai/src/requests/request.ts b/packages/vertexai/src/requests/request.ts index 8c563d8ccfc..edb894d7f76 100644 --- a/packages/vertexai/src/requests/request.ts +++ b/packages/vertexai/src/requests/request.ts @@ -166,12 +166,13 @@ export async function makeRequest( ) { throw new VertexAIError( VertexAIErrorCode.API_NOT_ENABLED, - `The Vertex AI for Firebase SDK requires the Firebase Vertex AI API ` + - `firebasevertexai.googleapis.com to be enabled for your ` + - `project. Get started in the Firebase Console` + - ` (https://console.firebase.google.com/project/${url.apiSettings.project}/genai/vertex)` + - ` or verify that the API is enabled in the Google Cloud` + - ` Console (https://console.developers.google.com/apis/api/firebasevertexai.googleapis.com/overview?project=${url.apiSettings.project}).`, + `The Vertex AI in Firebase SDK requires the Vertex AI in Firebase + API ('firebasevertexai.googleapis.com') to be enabled in your + Firebase project. Enable this API by visiting the Firebase Console + at https://console.firebase.google.com/project/${url.apiSettings.project}/genai/ + and clicking "Get started". If you enabled this API recently, + wait a few minutes for the action to propagate to our systems and + then retry.`, { status: response.status, statusText: response.statusText, From 320316d3fd18b4d25af949f259b5a8396fc654af Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 30 Sep 2024 10:48:32 -0700 Subject: [PATCH 2/2] Fix test regex --- packages/vertexai/src/methods/generate-content.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vertexai/src/methods/generate-content.test.ts b/packages/vertexai/src/methods/generate-content.test.ts index fd12964c4bc..c5a1d9e1e91 100644 --- a/packages/vertexai/src/methods/generate-content.test.ts +++ b/packages/vertexai/src/methods/generate-content.test.ts @@ -231,7 +231,9 @@ describe('generateContent()', () => { } as Response); await expect( generateContent(fakeApiSettings, 'model', fakeRequestParams) - ).to.be.rejectedWith(/firebasevertexai\.googleapis.*my-project/); + ).to.be.rejectedWith( + /firebasevertexai\.googleapis[\s\S]*my-project[\s\S]*api-not-enabled/ + ); expect(mockFetch).to.be.called; }); });