Skip to content

Commit 8cc0df4

Browse files
committed
Revert rename of FirebaseAI to AILog; keep module rename.
1 parent e61e1a1 commit 8cc0df4

22 files changed

+81
-112
lines changed

FirebaseAI/Sources/Constants.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ enum Constants {
1919
/// The base reverse-DNS name for `NSError` or `CustomNSError` error domains.
2020
///
2121
/// - Important: A suffix must be appended to produce an error domain (e.g.,
22-
/// "com.google.firebase.ai-logic.ExampleError").
23-
static let baseErrorDomain = "com.google.firebase.ai-logic"
22+
/// "com.google.firebase.firebaseai.ExampleError").
23+
static let baseErrorDomain = "com.google.firebase.firebaseai"
2424
}

FirebaseAI/Sources/FirebaseAI.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ internal import FirebaseCoreExtension
2222

2323
/// The Firebase AI SDK provides access to Gemini models directly from your app.
2424
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
25-
public final class AILogic: Sendable {
25+
public final class FirebaseAI: Sendable {
2626
// MARK: - Public APIs
2727

28-
/// Creates an instance of `AILogic`.
28+
/// Creates an instance of `FirebaseAI`.
2929
///
3030
/// - Parameters:
3131
/// - app: A custom `FirebaseApp` used for initialization; if not specified, uses the default
@@ -41,16 +41,17 @@ public final class AILogic: Sendable {
4141
/// _This flag is set to `false` by default._
4242
/// > Migrating to limited-use tokens sooner minimizes disruption when support for replay
4343
/// > protection is added.
44-
/// - Returns: An `AILogic` instance, configured with the custom `FirebaseApp`.
45-
public static func aiLogic(app: FirebaseApp? = nil, backend: Backend = .googleAI(),
46-
useLimitedUseAppCheckTokens: Bool = false) -> AILogic {
44+
/// - Returns: A `FirebaseAI` instance, configured with the custom `FirebaseApp`.
45+
public static func firebaseAI(app: FirebaseApp? = nil,
46+
backend: Backend = .googleAI(),
47+
useLimitedUseAppCheckTokens: Bool = false) -> FirebaseAI {
4748
let instance = createInstance(
4849
app: app,
4950
location: backend.location,
5051
apiConfig: backend.apiConfig,
5152
useLimitedUseAppCheckTokens: useLimitedUseAppCheckTokens
5253
)
53-
// Verify that the `AILogic` instance is always configured with the production endpoint since
54+
// Verify that the `FirebaseAI` instance is always configured with the production endpoint since
5455
// this is the public API surface for creating an instance.
5556
assert(instance.apiConfig.service.endpoint == .firebaseProxyProd)
5657
assert(instance.apiConfig.version == .v1beta)
@@ -151,9 +152,9 @@ public final class AILogic: Sendable {
151152

152153
let apiConfig: APIConfig
153154

154-
/// A map of active `AILogic` instances keyed by the `FirebaseApp` name and the `location`,
155+
/// A map of active `FirebaseAI` instances keyed by the `FirebaseApp` name and the `location`,
155156
/// in the format `appName:location`.
156-
private nonisolated(unsafe) static var instances: [InstanceKey: AILogic] = [:]
157+
private nonisolated(unsafe) static var instances: [InstanceKey: FirebaseAI] = [:]
157158

158159
/// Lock to manage access to the `instances` array to avoid race conditions.
159160
private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init()
@@ -167,7 +168,7 @@ public final class AILogic: Sendable {
167168

168169
static func createInstance(app: FirebaseApp?, location: String?,
169170
apiConfig: APIConfig,
170-
useLimitedUseAppCheckTokens: Bool) -> AILogic {
171+
useLimitedUseAppCheckTokens: Bool) -> FirebaseAI {
171172
guard let app = app ?? FirebaseApp.app() else {
172173
fatalError("No instance of the default Firebase app was found.")
173174
}
@@ -186,7 +187,7 @@ public final class AILogic: Sendable {
186187
if let instance = instances[instanceKey] {
187188
return instance
188189
}
189-
let newInstance = AILogic(
190+
let newInstance = FirebaseAI(
190191
app: app,
191192
location: location,
192193
apiConfig: apiConfig,
@@ -265,7 +266,7 @@ public final class AILogic: Sendable {
265266
}
266267
}
267268

268-
/// Identifier for a unique instance of ``AILogic``.
269+
/// Identifier for a unique instance of ``FirebaseAI``.
269270
///
270271
/// This type is `Hashable` so that it can be used as a key in the `instances` dictionary.
271272
private struct InstanceKey: Sendable, Hashable {

FirebaseAI/Tests/TestApp/Tests/Integration/CountTokensIntegrationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct CountTokensIntegrationTests {
4848
@Test(arguments: InstanceConfig.allConfigs)
4949
func countTokens_text(_ config: InstanceConfig) async throws {
5050
let prompt = "Why is the sky blue?"
51-
let model = AILogic.componentInstance(config).generativeModel(
51+
let model = FirebaseAI.componentInstance(config).generativeModel(
5252
modelName: ModelNames.gemini2Flash,
5353
generationConfig: generationConfig,
5454
safetySettings: safetySettings
@@ -65,7 +65,7 @@ struct CountTokensIntegrationTests {
6565

6666
@Test(arguments: InstanceConfig.allConfigs)
6767
func countTokens_text_systemInstruction(_ config: InstanceConfig) async throws {
68-
let model = AILogic.componentInstance(config).generativeModel(
68+
let model = FirebaseAI.componentInstance(config).generativeModel(
6969
modelName: ModelNames.gemini2Flash,
7070
generationConfig: generationConfig,
7171
safetySettings: safetySettings,
@@ -83,7 +83,7 @@ struct CountTokensIntegrationTests {
8383

8484
@Test(arguments: InstanceConfig.allConfigs)
8585
func countTokens_jsonSchema(_ config: InstanceConfig) async throws {
86-
let model = AILogic.componentInstance(config).generativeModel(
86+
let model = FirebaseAI.componentInstance(config).generativeModel(
8787
modelName: ModelNames.gemini2Flash,
8888
generationConfig: GenerationConfig(
8989
responseMIMEType: "application/json",

FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct GenerateContentIntegrationTests {
105105
arguments: InstanceConfig.allConfigs
106106
)
107107
func generateContentEnum(_ config: InstanceConfig) async throws {
108-
let model = AILogic.componentInstance(config).generativeModel(
108+
let model = FirebaseAI.componentInstance(config).generativeModel(
109109
modelName: ModelNames.gemini2FlashLite,
110110
generationConfig: GenerationConfig(
111111
responseMIMEType: "text/x.enum",
@@ -184,7 +184,7 @@ struct GenerateContentIntegrationTests {
184184
)
185185
func generateContentThinking(_ config: InstanceConfig, modelName: String,
186186
thinkingConfig: ThinkingConfig) async throws {
187-
let model = AILogic.componentInstance(config).generativeModel(
187+
let model = FirebaseAI.componentInstance(config).generativeModel(
188188
modelName: modelName,
189189
generationConfig: GenerationConfig(
190190
temperature: 0.0,
@@ -268,7 +268,7 @@ struct GenerateContentIntegrationTests {
268268
"country": .string(),
269269
]
270270
)
271-
let model = AILogic.componentInstance(config).generativeModel(
271+
let model = FirebaseAI.componentInstance(config).generativeModel(
272272
modelName: modelName,
273273
generationConfig: GenerationConfig(
274274
temperature: 0.0,
@@ -390,7 +390,7 @@ struct GenerateContentIntegrationTests {
390390
arguments: InstanceConfig.allConfigs
391391
)
392392
func generateContent_withGoogleSearch_succeeds(_ config: InstanceConfig) async throws {
393-
let model = AILogic.componentInstance(config).generativeModel(
393+
let model = FirebaseAI.componentInstance(config).generativeModel(
394394
modelName: ModelNames.gemini2Flash,
395395
tools: [.googleSearch()]
396396
)
@@ -485,7 +485,7 @@ struct GenerateContentIntegrationTests {
485485
- Do NOT wrap the JSON in Markdown code blocks (e.g., ```json ... ``` or ``` ... ```).
486486
- The response must start with '[' and end with ']'.
487487
"""
488-
let model = AILogic.componentInstance(config).generativeModel(
488+
let model = FirebaseAI.componentInstance(config).generativeModel(
489489
modelName: modelName,
490490
generationConfig: generationConfig,
491491
safetySettings: safetySettings
@@ -589,7 +589,7 @@ struct GenerateContentIntegrationTests {
589589

590590
@Test(arguments: InstanceConfig.appCheckNotConfiguredConfigs)
591591
func generateContent_appCheckNotConfigured_shouldFail(_ config: InstanceConfig) async throws {
592-
let model = AILogic.componentInstance(config).generativeModel(
592+
let model = FirebaseAI.componentInstance(config).generativeModel(
593593
modelName: ModelNames.gemini2Flash
594594
)
595595
let prompt = "Where is Google headquarters located? Answer with the city name only."

FirebaseAI/Tests/TestApp/Tests/Integration/ImagenIntegrationTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import Testing
3434
.serialized
3535
)
3636
struct ImagenIntegrationTests {
37-
var vertex: AILogic
37+
var vertex: FirebaseAI
3838
var storage: Storage
3939
var userID1: String
4040

4141
init() async throws {
4242
userID1 = try await TestHelpers.getUserID()
43-
vertex = AILogic.aiLogic(backend: .vertexAI())
43+
vertex = FirebaseAI.firebaseAI(backend: .vertexAI())
4444
storage = Storage.storage()
4545
}
4646

FirebaseAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ final class IntegrationTests: XCTestCase {
4444
// Candidates and total token counts may differ slightly between runs due to whitespace tokens.
4545
let tokenCountAccuracy = 1
4646

47-
var vertex: AILogic!
47+
var vertex: FirebaseAI!
4848
var model: GenerativeModel!
4949
var storage: Storage!
5050
var userID1 = ""
5151

5252
override func setUp() async throws {
5353
userID1 = try await TestHelpers.getUserID()
54-
vertex = AILogic.aiLogic(backend: .vertexAI())
54+
vertex = FirebaseAI.firebaseAI(backend: .vertexAI())
5555
model = vertex.generativeModel(
5656
modelName: "gemini-2.0-flash",
5757
generationConfig: generationConfig,
@@ -196,7 +196,7 @@ final class IntegrationTests: XCTestCase {
196196

197197
func testCountTokens_appCheckNotConfigured_shouldFail() async throws {
198198
let app = try XCTUnwrap(FirebaseApp.app(name: FirebaseAppNames.appCheckNotConfigured))
199-
let vertex = AILogic.aiLogic(app: app, backend: .vertexAI())
199+
let vertex = FirebaseAI.firebaseAI(app: app, backend: .vertexAI())
200200
let model = vertex.generativeModel(modelName: "gemini-2.0-flash")
201201
let prompt = "Why is the sky blue?"
202202

FirebaseAI/Tests/TestApp/Tests/Integration/SchemaTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct SchemaTests {
5050

5151
@Test(arguments: InstanceConfig.allConfigs)
5252
func generateContentSchemaItems(_ config: InstanceConfig) async throws {
53-
let model = AILogic.componentInstance(config).generativeModel(
53+
let model = FirebaseAI.componentInstance(config).generativeModel(
5454
modelName: ModelNames.gemini2FlashLite,
5555
generationConfig: GenerationConfig(
5656
responseMIMEType: "application/json",
@@ -75,7 +75,7 @@ struct SchemaTests {
7575

7676
@Test(arguments: InstanceConfig.allConfigs)
7777
func generateContentSchemaNumberRange(_ config: InstanceConfig) async throws {
78-
let model = AILogic.componentInstance(config).generativeModel(
78+
let model = FirebaseAI.componentInstance(config).generativeModel(
7979
modelName: ModelNames.gemini2FlashLite,
8080
generationConfig: GenerationConfig(
8181
responseMIMEType: "application/json",
@@ -104,7 +104,7 @@ struct SchemaTests {
104104
let price: Double // Will correspond to .double in schema
105105
let salePrice: Float // Will correspond to .float in schema
106106
}
107-
let model = AILogic.componentInstance(config).generativeModel(
107+
let model = FirebaseAI.componentInstance(config).generativeModel(
108108
modelName: ModelNames.gemini2FlashLite,
109109
generationConfig: GenerationConfig(
110110
responseMIMEType: "application/json",
@@ -195,7 +195,7 @@ struct SchemaTests {
195195
],
196196
description: "A U.S. mailing address"
197197
)
198-
let model = AILogic.componentInstance(config).generativeModel(
198+
let model = FirebaseAI.componentInstance(config).generativeModel(
199199
modelName: ModelNames.gemini2Flash,
200200
generationConfig: GenerationConfig(
201201
temperature: 0.0,

FirebaseAI/Tests/TestApp/Tests/Utilities/InstanceConfig.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ extension InstanceConfig: CustomTestStringConvertible {
146146
}
147147
}
148148

149-
extension AILogic {
150-
static func componentInstance(_ instanceConfig: InstanceConfig) -> AILogic {
149+
extension FirebaseAI {
150+
static func componentInstance(_ instanceConfig: InstanceConfig) -> FirebaseAI {
151151
switch instanceConfig.apiConfig.service {
152152
case .vertexAI:
153153
let location = instanceConfig.location ?? "us-central1"
154-
return AILogic.createInstance(
154+
return FirebaseAI.createInstance(
155155
app: instanceConfig.app,
156156
location: location,
157157
apiConfig: instanceConfig.apiConfig,
@@ -162,7 +162,7 @@ extension AILogic {
162162
instanceConfig.location == nil,
163163
"The Developer API is global and does not support `location`."
164164
)
165-
return AILogic.createInstance(
165+
return FirebaseAI.createInstance(
166166
app: instanceConfig.app,
167167
location: nil,
168168
apiConfig: instanceConfig.apiConfig,

FirebaseAI/Tests/Unit/APITests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ final class APITests: XCTestCase {
4242
let _ = RequestOptions(timeout: 30.0)
4343

4444
// Instantiate Firebase AI SDK - Default App
45-
let firebaseAI = AILogic.aiLogic()
46-
let _ = AILogic.aiLogic(backend: .googleAI())
47-
let _ = AILogic.aiLogic(backend: .vertexAI())
48-
let _ = AILogic.aiLogic(backend: .vertexAI(location: "my-location"))
45+
let firebaseAI = FirebaseAI.firebaseAI()
46+
let _ = FirebaseAI.firebaseAI(backend: .googleAI())
47+
let _ = FirebaseAI.firebaseAI(backend: .vertexAI())
48+
let _ = FirebaseAI.firebaseAI(backend: .vertexAI(location: "my-location"))
4949

5050
// Instantiate Firebase AI SDK - Custom App
51-
let _ = AILogic.aiLogic(app: app!)
52-
let _ = AILogic.aiLogic(app: app!, backend: .googleAI())
53-
let _ = AILogic.aiLogic(app: app!, backend: .vertexAI())
54-
let _ = AILogic.aiLogic(app: app!, backend: .vertexAI(location: "my-location"))
51+
let _ = FirebaseAI.firebaseAI(app: app!)
52+
let _ = FirebaseAI.firebaseAI(app: app!, backend: .googleAI())
53+
let _ = FirebaseAI.firebaseAI(app: app!, backend: .vertexAI())
54+
let _ = FirebaseAI.firebaseAI(app: app!, backend: .vertexAI(location: "my-location"))
5555

5656
// Permutations without optional arguments.
5757

FirebaseAI/Tests/Unit/ChatTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class ChatTests: XCTestCase {
7171
firebaseApp: app,
7272
useLimitedUseAppCheckTokens: false
7373
),
74-
apiConfig: AILogic.defaultVertexAIAPIConfig,
74+
apiConfig: FirebaseAI.defaultVertexAIAPIConfig,
7575
tools: nil,
7676
requestOptions: RequestOptions(),
7777
urlSession: urlSession
@@ -107,7 +107,7 @@ final class ChatTests: XCTestCase {
107107
modelName: modelName,
108108
modelResourceName: modelResourceName,
109109
firebaseInfo: GenerativeModelTestUtil.testFirebaseInfo(),
110-
apiConfig: AILogic.defaultVertexAIAPIConfig,
110+
apiConfig: FirebaseAI.defaultVertexAIAPIConfig,
111111
tools: nil,
112112
requestOptions: RequestOptions(),
113113
urlSession: urlSession
@@ -148,7 +148,7 @@ final class ChatTests: XCTestCase {
148148
modelName: modelName,
149149
modelResourceName: modelResourceName,
150150
firebaseInfo: GenerativeModelTestUtil.testFirebaseInfo(),
151-
apiConfig: AILogic.defaultVertexAIAPIConfig,
151+
apiConfig: FirebaseAI.defaultVertexAIAPIConfig,
152152
tools: nil,
153153
requestOptions: RequestOptions(),
154154
urlSession: urlSession
@@ -184,7 +184,7 @@ final class ChatTests: XCTestCase {
184184
modelName: modelName,
185185
modelResourceName: modelResourceName,
186186
firebaseInfo: GenerativeModelTestUtil.testFirebaseInfo(),
187-
apiConfig: AILogic.defaultVertexAIAPIConfig,
187+
apiConfig: FirebaseAI.defaultVertexAIAPIConfig,
188188
tools: nil,
189189
requestOptions: RequestOptions(),
190190
urlSession: urlSession

0 commit comments

Comments
 (0)