From b1de969044429e2ae8772c73c168007ce6453918 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Fri, 27 Sep 2024 11:15:54 -0400 Subject: [PATCH 1/3] [Vertex AI] Update log message when API is not enabled --- .../Sources/GenerativeAIService.swift | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/FirebaseVertexAI/Sources/GenerativeAIService.swift b/FirebaseVertexAI/Sources/GenerativeAIService.swift index 0e2e39169ea..e10105c78ed 100644 --- a/FirebaseVertexAI/Sources/GenerativeAIService.swift +++ b/FirebaseVertexAI/Sources/GenerativeAIService.swift @@ -265,23 +265,33 @@ struct GenerativeAIService { private func logRPCError(_ error: RPCError) { // TODO(andrewheard): Remove this check after the Vertex AI in Firebase API launch. if error.isFirebaseMLServiceDisabledError() { - VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """ + let message = """ The Vertex AI for Firebase SDK requires the Firebase ML API `firebaseml.googleapis.com` to \ - be enabled for your project. Get started in the Firebase Console \ - (https://console.firebase.google.com/project/\(projectID)/genai/vertex) or verify that the \ - API is enabled in the Google Cloud Console \ - (https://console.developers.google.com/apis/api/firebaseml.googleapis.com/overview?project=\ - \(projectID)). - """) + be enabled for your project. Enable it by visiting the the Firebase Console at + https://console.firebase.google.com/project/\(projectID)/genai/vertex then retry. If you + enabled this API recently, wait a few minutes for the action to propagate to our systems and + retry. + """ + #if DEBUG + fatalError(message) + #else + VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, message) + #endif // DEBUG } if error.isVertexAIInFirebaseServiceDisabledError() { - VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """ + let message = """ The Vertex AI for Firebase SDK requires the Firebase Vertex AI API \ - `firebasevertexai.googleapis.com` to be enabled for your project. Get started by visiting \ - the Firebase Console at: \ - https://console.firebase.google.com/project/\(projectID)/genai/vertex - """) + `firebasevertexai.googleapis.com` to be enabled for your project. Enable it by visiting the \ + the Firebase Console at https://console.firebase.google.com/project/\(projectID)/genai/vertex + then retry. If you enabled this API recently, wait a few minutes for the action to propagate + to our systems and retry. + """ + #if DEBUG + fatalError(message) + #else + VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, message) + #endif // DEBUG } } From 9e4652804539917d032c73b46e2a331b687af297 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Fri, 27 Sep 2024 11:50:30 -0400 Subject: [PATCH 2/3] Revert `fatalError` behaviour --- .../Sources/GenerativeAIService.swift | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/FirebaseVertexAI/Sources/GenerativeAIService.swift b/FirebaseVertexAI/Sources/GenerativeAIService.swift index e10105c78ed..83b0e644fa0 100644 --- a/FirebaseVertexAI/Sources/GenerativeAIService.swift +++ b/FirebaseVertexAI/Sources/GenerativeAIService.swift @@ -265,33 +265,23 @@ struct GenerativeAIService { private func logRPCError(_ error: RPCError) { // TODO(andrewheard): Remove this check after the Vertex AI in Firebase API launch. if error.isFirebaseMLServiceDisabledError() { - let message = """ + VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """ The Vertex AI for Firebase SDK requires the Firebase ML API `firebaseml.googleapis.com` to \ be enabled for your project. Enable it by visiting the the Firebase Console at https://console.firebase.google.com/project/\(projectID)/genai/vertex then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. - """ - #if DEBUG - fatalError(message) - #else - VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, message) - #endif // DEBUG + """) } if error.isVertexAIInFirebaseServiceDisabledError() { - let message = """ + VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """ The Vertex AI for Firebase SDK requires the Firebase Vertex AI API \ `firebasevertexai.googleapis.com` to be enabled for your project. Enable it by visiting the \ the Firebase Console at https://console.firebase.google.com/project/\(projectID)/genai/vertex then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. - """ - #if DEBUG - fatalError(message) - #else - VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, message) - #endif // DEBUG + """) } } From bddb11db01646ee2e043c862a8caa5cd89452c62 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Mon, 30 Sep 2024 10:28:34 -0400 Subject: [PATCH 3/3] Update log message --- .../Sources/GenerativeAIService.swift | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/FirebaseVertexAI/Sources/GenerativeAIService.swift b/FirebaseVertexAI/Sources/GenerativeAIService.swift index 83b0e644fa0..ac429104352 100644 --- a/FirebaseVertexAI/Sources/GenerativeAIService.swift +++ b/FirebaseVertexAI/Sources/GenerativeAIService.swift @@ -266,21 +266,22 @@ struct GenerativeAIService { // TODO(andrewheard): Remove this check after the Vertex AI in Firebase API launch. if error.isFirebaseMLServiceDisabledError() { VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """ - The Vertex AI for Firebase SDK requires the Firebase ML API `firebaseml.googleapis.com` to \ - be enabled for your project. Enable it by visiting the the Firebase Console at - https://console.firebase.google.com/project/\(projectID)/genai/vertex then retry. If you - enabled this API recently, wait a few minutes for the action to propagate to our systems and - retry. + The Vertex AI in Firebase SDK requires the Firebase ML API (`firebaseml.googleapis.com`) to \ + be enabled in your Firebase project. Enable this API by visiting the Firebase Console at + https://console.firebase.google.com/project/\(projectID)/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. """) } if error.isVertexAIInFirebaseServiceDisabledError() { VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """ - The Vertex AI for Firebase SDK requires the Firebase Vertex AI API \ - `firebasevertexai.googleapis.com` to be enabled for your project. Enable it by visiting the \ - the Firebase Console at https://console.firebase.google.com/project/\(projectID)/genai/vertex - then retry. If you enabled this API recently, wait a few minutes for the action to propagate - to our systems and retry. + 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/\(projectID)/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. """) } }