From 24ded5069d15e76ab576a53c250fc0eb5e348143 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 25 Apr 2025 14:55:07 -0700 Subject: [PATCH 1/2] [Firebase AI] More naming updates --- FirebaseAI/README.md | 6 ++-- FirebaseAI/Sample/README.md | 4 +-- FirebaseAI/Sources/Constants.swift | 2 +- FirebaseAI/Sources/FirebaseAI.swift | 33 +++++++------------ FirebaseAI/Sources/FirebaseInfo.swift | 2 +- FirebaseAI/Sources/GenerativeModel.swift | 4 +-- .../Sources/Types/Internal/APIConfig.swift | 4 +-- .../Types/Public/Imagen/ImagenModel.swift | 8 ++--- .../GenerateContentIntegrationTests.swift | 2 +- .../Tests/Unit/GenerativeModelTests.swift | 4 +-- FirebaseAI/Tests/Unit/README.md | 2 +- FirebaseAI/Tests/Unit/Snippets/README.md | 2 +- 12 files changed, 32 insertions(+), 41 deletions(-) diff --git a/FirebaseAI/README.md b/FirebaseAI/README.md index 0392f86e996..8a5d2cb853a 100644 --- a/FirebaseAI/README.md +++ b/FirebaseAI/README.md @@ -1,4 +1,4 @@ -# Vertex AI for Firebase SDK +# Firebase AI SDK - For developer documentation, please visit https://firebase.google.com/docs/vertex-ai. - Try out the [sample app](https://github.com/firebase/quickstart-ios/tree/main/vertexai to get started. @@ -7,7 +7,7 @@ After following the Swift Package Manager [setup instructions](https://github.com/firebase/firebase-ios-sdk#swift-package-manager-1), -choose the `FirebaseVertexAI` scheme to build the SDK. +choose the `FirebaseAI` scheme to build the SDK. ### Unit Tests @@ -15,7 +15,7 @@ choose the `FirebaseVertexAI` scheme to build the SDK. > These unit tests require mock response files, which can be downloaded by running `scripts/update_vertexai_responses.sh` from the root of this repository. -Choose the `FirebaseVertexAIUnit` scheme to build and run the unit tests. +Choose the `FirebaseAIUnit` scheme to build and run the unit tests. #### Updating Mock Responses diff --git a/FirebaseAI/Sample/README.md b/FirebaseAI/Sample/README.md index eed4f6c5ee1..309958ab2ed 100644 --- a/FirebaseAI/Sample/README.md +++ b/FirebaseAI/Sample/README.md @@ -1,5 +1,5 @@ -# Vertex AI for Firebase Quickstart +# Firebase AI SDK Quickstart Try out the - [Vertex AI Quickstart](https://github.com/firebase/quickstart-ios/tree/main/vertexai) + [Firebase AI SDK Quickstart](https://github.com/firebase/quickstart-ios/tree/main/firebaseai) in the `quickstart-ios` repository to get started. diff --git a/FirebaseAI/Sources/Constants.swift b/FirebaseAI/Sources/Constants.swift index 2b7ac34508d..8e312723993 100644 --- a/FirebaseAI/Sources/Constants.swift +++ b/FirebaseAI/Sources/Constants.swift @@ -14,7 +14,7 @@ import Foundation -/// Constants associated with the Vertex AI for Firebase SDK. +/// Constants associated with the Firebase AI SDK. enum Constants { /// The base reverse-DNS name for `NSError` or `CustomNSError` error domains. /// diff --git a/FirebaseAI/Sources/FirebaseAI.swift b/FirebaseAI/Sources/FirebaseAI.swift index e3fa0fbc44a..2fbe4bf8bc6 100644 --- a/FirebaseAI/Sources/FirebaseAI.swift +++ b/FirebaseAI/Sources/FirebaseAI.swift @@ -20,7 +20,7 @@ import Foundation // Avoids exposing internal FirebaseCore APIs to Swift users. internal import FirebaseCoreExtension -/// The Vertex AI for Firebase SDK provides access to Gemini models directly from your app. +/// The Firebase AI SDK provides access to Gemini models directly from your app. @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) public final class FirebaseAI: Sendable { // MARK: - Public APIs @@ -95,7 +95,7 @@ public final class FirebaseAI: Sendable { /// **[Public Preview]** Initializes an ``ImagenModel`` with the given parameters. /// - /// > Warning: For Vertex AI in Firebase, image generation using Imagen 3 models is in Public + /// > Warning: For Firebase AI SDK, image generation using Imagen 3 models is in Public /// Preview, which means that the feature is not subject to any SLA or deprecation policy and /// could change in backwards-incompatible ways. /// @@ -129,32 +129,23 @@ public final class FirebaseAI: Sendable { ) } - /// Class to enable VertexAI to register via the Objective-C based Firebase component system - /// to include VertexAI in the userAgent. + /// Class to enable FirebaseAI to register via the Objective-C based Firebase component system + /// to include FirebaseAI in the userAgent. @objc(FIRVertexAIComponent) class FirebaseVertexAIComponent: NSObject {} // MARK: - Private - /// Firebase data relevant to Vertex AI. + /// Firebase data relevant to Firebase AI. let firebaseInfo: FirebaseInfo let apiConfig: APIConfig - #if compiler(>=6) - /// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in - /// the format `appName:location`. - private nonisolated(unsafe) static var instances: [InstanceKey: FirebaseAI] = [:] + /// A map of active `FirebaseAI` instances keyed by the `FirebaseApp` name and the `location`, + /// in the format `appName:location`. + private nonisolated(unsafe) static var instances: [InstanceKey: FirebaseAI] = [:] - /// Lock to manage access to the `instances` array to avoid race conditions. - private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init() - #else - /// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in - /// the format `appName:location`. - private static var instances: [InstanceKey: VertexAI] = [:] - - /// Lock to manage access to the `instances` array to avoid race conditions. - private static var instancesLock: os_unfair_lock = .init() - #endif + /// Lock to manage access to the `instances` array to avoid race conditions. + private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init() let location: String? @@ -225,7 +216,7 @@ public final class FirebaseAI: Sendable { private func vertexAIModelResourceName(modelName: String) -> String { guard let location else { - fatalError("Location must be specified for the Vertex AI service.") + fatalError("Location must be specified for the Firebase AI service.") } guard !location.isEmpty && location .allSatisfy({ !$0.isWhitespace && !$0.isNewline && $0 != "/" }) else { @@ -250,7 +241,7 @@ public final class FirebaseAI: Sendable { } } - /// Identifier for a unique instance of ``VertexAI``. + /// Identifier for a unique instance of ``FirebaseAI``. /// /// This type is `Hashable` so that it can be used as a key in the `instances` dictionary. private struct InstanceKey: Sendable, Hashable { diff --git a/FirebaseAI/Sources/FirebaseInfo.swift b/FirebaseAI/Sources/FirebaseInfo.swift index 13f4db4f3e7..c1f27aa7fe3 100644 --- a/FirebaseAI/Sources/FirebaseInfo.swift +++ b/FirebaseAI/Sources/FirebaseInfo.swift @@ -19,7 +19,7 @@ import Foundation @preconcurrency import FirebaseAuthInterop @preconcurrency import FirebaseCore -/// Firebase data used by VertexAI +/// Firebase data used by FirebaseAI @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) struct FirebaseInfo: Sendable { let appCheck: AppCheckInterop? diff --git a/FirebaseAI/Sources/GenerativeModel.swift b/FirebaseAI/Sources/GenerativeModel.swift index a9ebef87b8b..d960d7a768e 100644 --- a/FirebaseAI/Sources/GenerativeModel.swift +++ b/FirebaseAI/Sources/GenerativeModel.swift @@ -59,9 +59,9 @@ public final class GenerativeModel: Sendable { /// - modelName: The name of the model, for example "gemini-2.0-flash". /// - modelResourceName: The model resource name corresponding with `modelName` in the backend. /// The form depends on the backend and will be one of: - /// - Vertex AI via Vertex AI in Firebase: + /// - Vertex AI via Firebase AI SDK: /// `"projects/{projectID}/locations/{locationID}/publishers/google/models/{modelName}"` - /// - Developer API via Vertex AI in Firebase: `"projects/{projectID}/models/{modelName}"` + /// - Developer API via Firebase AI SDK: `"projects/{projectID}/models/{modelName}"` /// - Developer API via Generative Language: `"models/{modelName}"` /// - firebaseInfo: Firebase data used by the SDK, including project ID and API key. /// - apiConfig: Configuration for the backend API used by this model. diff --git a/FirebaseAI/Sources/Types/Internal/APIConfig.swift b/FirebaseAI/Sources/Types/Internal/APIConfig.swift index 6562570ffe6..0cff1913d61 100644 --- a/FirebaseAI/Sources/Types/Internal/APIConfig.swift +++ b/FirebaseAI/Sources/Types/Internal/APIConfig.swift @@ -69,10 +69,10 @@ extension APIConfig { extension APIConfig.Service { /// Network addresses for generative AI API services. enum Endpoint: String { - /// The Vertex AI in Firebase production endpoint. + /// The Firebase AI SDK production endpoint. case firebaseVertexAIProd = "https://firebasevertexai.googleapis.com" - /// The Vertex AI in Firebase staging endpoint; for SDK development and testing only. + /// The Firebase AI SDK staging endpoint; for SDK development and testing only. case firebaseVertexAIStaging = "https://staging-firebasevertexai.sandbox.googleapis.com" /// The Gemini Developer API production endpoint; for SDK development and testing only. diff --git a/FirebaseAI/Sources/Types/Public/Imagen/ImagenModel.swift b/FirebaseAI/Sources/Types/Public/Imagen/ImagenModel.swift index a829f616773..e6f96df511a 100644 --- a/FirebaseAI/Sources/Types/Public/Imagen/ImagenModel.swift +++ b/FirebaseAI/Sources/Types/Public/Imagen/ImagenModel.swift @@ -21,9 +21,9 @@ import Foundation /// See the [generate images /// documentation](https://firebase.google.com/docs/vertex-ai/generate-images-imagen?platform=ios) /// for more details about the image generation capabilities offered by the Imagen model in the -/// Vertex AI in Firebase SDK. +/// Firebase AI SDK SDK. /// -/// > Warning: For Vertex AI in Firebase, image generation using Imagen 3 models is in Public +/// > Warning: For Firebase AI SDK, image generation using Imagen 3 models is in Public /// Preview, which means that the feature is not subject to any SLA or deprecation policy and /// could change in backwards-incompatible ways. @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) @@ -73,7 +73,7 @@ public final class ImagenModel { /// > Note: By default, 1 image sample is generated; see ``ImagenGenerationConfig/numberOfImages`` /// to configure the number of images that are generated. /// - /// > Warning: For Vertex AI in Firebase, image generation using Imagen 3 models is in Public + /// > Warning: For Firebase AI SDK, image generation using Imagen 3 models is in Public /// Preview, which means that the feature is not subject to any SLA or deprecation policy and /// could change in backwards-incompatible ways. /// @@ -105,7 +105,7 @@ public final class ImagenModel { /// > Note: By default, 1 image sample is generated; see ``ImagenGenerationConfig/numberOfImages`` /// to configure the number of images that are generated. /// - /// > Warning: For Vertex AI in Firebase, image generation using Imagen 3 models is in Public + /// > Warning: For Firebase AI SDK, image generation using Imagen 3 models is in Public /// Preview, which means that the feature is not subject to any SLA or deprecation policy and /// could change in backwards-incompatible ways. /// diff --git a/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift b/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift index b40112dd9c3..885a6d980dd 100644 --- a/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift +++ b/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift @@ -219,7 +219,7 @@ struct GenerateContentIntegrationTests { InstanceConfig.vertexV1AppCheckNotConfigured, InstanceConfig.vertexV1BetaAppCheckNotConfigured, // App Check is not supported on the Generative Language Developer API endpoint since it - // bypasses the Vertex AI in Firebase proxy. + // bypasses the Firebase AI SDK proxy. ]) func generateContent_appCheckNotConfigured_shouldFail(_ config: InstanceConfig) async throws { let model = FirebaseAI.componentInstance(config).generativeModel( diff --git a/FirebaseAI/Tests/Unit/GenerativeModelTests.swift b/FirebaseAI/Tests/Unit/GenerativeModelTests.swift index 89bd8a13699..bf4a61ba1c0 100644 --- a/FirebaseAI/Tests/Unit/GenerativeModelTests.swift +++ b/FirebaseAI/Tests/Unit/GenerativeModelTests.swift @@ -600,7 +600,7 @@ final class GenerativeModelTests: XCTestCase { XCTAssertEqual(error.httpResponseCode, expectedStatusCode) XCTAssertEqual(error.status, .permissionDenied) XCTAssertTrue(error.message - .starts(with: "Vertex AI in Firebase API has not been used in project")) + .starts(with: "Firebase AI SDK API has not been used in project")) XCTAssertTrue(error.isVertexAIInFirebaseServiceDisabledError()) return } catch { @@ -972,7 +972,7 @@ final class GenerativeModelTests: XCTestCase { XCTAssertEqual(error.httpResponseCode, expectedStatusCode) XCTAssertEqual(error.status, .permissionDenied) XCTAssertTrue(error.message - .starts(with: "Vertex AI in Firebase API has not been used in project")) + .starts(with: "Firebase AI SDK API has not been used in project")) XCTAssertTrue(error.isVertexAIInFirebaseServiceDisabledError()) return } diff --git a/FirebaseAI/Tests/Unit/README.md b/FirebaseAI/Tests/Unit/README.md index ab643fb447e..9463d595294 100644 --- a/FirebaseAI/Tests/Unit/README.md +++ b/FirebaseAI/Tests/Unit/README.md @@ -1,3 +1,3 @@ -See the Vertex AI for Firebase +See the Firebase AI SDK [README](https://github.com/firebase/firebase-ios-sdk/tree/main/FirebaseVertexAI#unit-tests) for required setup instructions. diff --git a/FirebaseAI/Tests/Unit/Snippets/README.md b/FirebaseAI/Tests/Unit/Snippets/README.md index 8d03458c456..6c4313f6d57 100644 --- a/FirebaseAI/Tests/Unit/Snippets/README.md +++ b/FirebaseAI/Tests/Unit/Snippets/README.md @@ -1,4 +1,4 @@ -# Vertex AI in Firebase Code Snippet Tests +# Firebase AI SDK Code Snippet Tests These "tests" are for verifying that the code snippets provided in our documentation continue to compile. They are intentionally skipped in CI but can From 45a9f220895b69a3465cc6bf834c19b54a52da65 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 25 Apr 2025 15:19:45 -0700 Subject: [PATCH 2/2] Wait to change until shared responses are updated --- FirebaseAI/Tests/Unit/GenerativeModelTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FirebaseAI/Tests/Unit/GenerativeModelTests.swift b/FirebaseAI/Tests/Unit/GenerativeModelTests.swift index bf4a61ba1c0..89bd8a13699 100644 --- a/FirebaseAI/Tests/Unit/GenerativeModelTests.swift +++ b/FirebaseAI/Tests/Unit/GenerativeModelTests.swift @@ -600,7 +600,7 @@ final class GenerativeModelTests: XCTestCase { XCTAssertEqual(error.httpResponseCode, expectedStatusCode) XCTAssertEqual(error.status, .permissionDenied) XCTAssertTrue(error.message - .starts(with: "Firebase AI SDK API has not been used in project")) + .starts(with: "Vertex AI in Firebase API has not been used in project")) XCTAssertTrue(error.isVertexAIInFirebaseServiceDisabledError()) return } catch { @@ -972,7 +972,7 @@ final class GenerativeModelTests: XCTestCase { XCTAssertEqual(error.httpResponseCode, expectedStatusCode) XCTAssertEqual(error.status, .permissionDenied) XCTAssertTrue(error.message - .starts(with: "Firebase AI SDK API has not been used in project")) + .starts(with: "Vertex AI in Firebase API has not been used in project")) XCTAssertTrue(error.isVertexAIInFirebaseServiceDisabledError()) return }