Skip to content

Commit fc4d6e6

Browse files
authored
[Vertex AI] Re-added location parameter to public API (#12835)
1 parent b3ffeb1 commit fc4d6e6

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

FirebaseVertexAI/Sources/VertexAI.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,33 @@ public class VertexAI: NSObject {
2525

2626
/// The default `VertexAI` instance.
2727
///
28+
/// - Parameter location: The region identifier, defaulting to `us-central1`; see [Vertex AI
29+
/// regions](https://cloud.google.com/vertex-ai/docs/general/locations#vertex-ai-regions) for a
30+
/// list of supported regions.
2831
/// - Returns: An instance of `VertexAI`, configured with the default `FirebaseApp`.
29-
public static func vertexAI() -> VertexAI {
32+
public static func vertexAI(location: String = "us-central1") -> VertexAI {
3033
guard let app = FirebaseApp.app() else {
3134
fatalError("No instance of the default Firebase app was found.")
3235
}
3336

34-
return vertexAI(app: app)
37+
return vertexAI(app: app, location: location)
3538
}
3639

3740
/// Creates an instance of `VertexAI` configured with a custom `FirebaseApp`.
3841
///
3942
/// - Parameters:
4043
/// - app: The custom `FirebaseApp` used for initialization.
44+
/// - location: The region identifier, defaulting to `us-central1`; see [Vertex AI
45+
/// regions](https://cloud.google.com/vertex-ai/docs/general/locations#vertex-ai-regions)
46+
/// for a list of supported regions.
4147
/// - Returns: A `VertexAI` instance, configured with the custom `FirebaseApp`.
42-
public static func vertexAI(app: FirebaseApp) -> VertexAI {
48+
public static func vertexAI(app: FirebaseApp, location: String = "us-central1") -> VertexAI {
4349
guard let provider = ComponentType<VertexAIProvider>.instance(for: VertexAIProvider.self,
4450
in: app.container) else {
4551
fatalError("No \(VertexAIProvider.self) instance found for Firebase app: \(app.name)")
4652
}
4753

48-
return provider.vertexAI("us-central1")
54+
return provider.vertexAI(location)
4955
}
5056

5157
/// Initializes a generative model with the given parameters.

FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ final class VertexAIAPITests: XCTestCase {
3636

3737
// Instantiate Vertex AI SDK - Default App
3838
let vertexAI = VertexAI.vertexAI()
39+
let _ = VertexAI.vertexAI(location: "my-location")
3940

4041
// Instantiate Vertex AI SDK - Custom App
4142
let _ = VertexAI.vertexAI(app: app!)
43+
let _ = VertexAI.vertexAI(app: app!, location: "my-location")
4244

4345
// Permutations without optional arguments.
4446

0 commit comments

Comments
 (0)