Skip to content

Commit 2d48936

Browse files
committed
Remove location from Vertex AI public API (#12706)
1 parent a386df6 commit 2d48936

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

FirebaseVertexAI/Sample/ChatSample/ViewModels/ConversationViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ConversationViewModel: ObservableObject {
3636
private var chatTask: Task<Void, Never>?
3737

3838
init() {
39-
model = VertexAI.vertexAI(location: "us-central1").generativeModel(modelName: "gemini-1.0-pro")
39+
model = VertexAI.vertexAI().generativeModel(modelName: "gemini-1.0-pro")
4040
chat = model.startChat()
4141
}
4242

FirebaseVertexAI/Sample/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class PhotoReasoningViewModel: ObservableObject {
4444
private var model: GenerativeModel?
4545

4646
init() {
47-
let vertexAI = VertexAI.vertexAI(location: "us-central1")
48-
model = vertexAI.generativeModel(modelName: "gemini-1.0-pro-vision")
47+
model = VertexAI.vertexAI().generativeModel(modelName: "gemini-1.0-pro-vision")
4948
}
5049

5150
func reason() async {

FirebaseVertexAI/Sample/GenerativeAITextSample/ViewModels/SummarizeViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SummarizeViewModel: ObservableObject {
3232
private var model: GenerativeModel?
3333

3434
init() {
35-
model = VertexAI.vertexAI(location: "us-central1").generativeModel(modelName: "gemini-1.0-pro")
35+
model = VertexAI.vertexAI().generativeModel(modelName: "gemini-1.0-pro")
3636
}
3737

3838
func summarize(inputText: String) async {

FirebaseVertexAI/Sources/VertexAI.swift

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

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

38-
return vertexAI(app: app, location: location)
34+
return vertexAI(app: app)
3935
}
4036

4137
/// Creates an instance of `VertexAI` configured with a custom `FirebaseApp`.
4238
///
4339
/// - Parameters:
4440
/// - app: The custom `FirebaseApp` used for initialization.
45-
/// - location: The region identifier, e.g., `us-central1`; see
46-
/// [Vertex AI
47-
/// regions](https://cloud.google.com/vertex-ai/docs/general/locations#vertex-ai-regions)
48-
/// for a list of supported regions.
4941
/// - Returns: A `VertexAI` instance, configured with the custom `FirebaseApp`.
50-
public static func vertexAI(app: FirebaseApp, location: String) -> VertexAI {
42+
public static func vertexAI(app: FirebaseApp) -> VertexAI {
5143
guard let provider = ComponentType<VertexAIProvider>.instance(for: VertexAIProvider.self,
5244
in: app.container) else {
5345
fatalError("No \(VertexAIProvider.self) instance found for Firebase app: \(app.name)")
5446
}
5547

56-
return provider.vertexAI(location)
48+
return provider.vertexAI("us-central1")
5749
}
5850

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

FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ final class VertexAIAPITests: XCTestCase {
3434
let filters = [SafetySetting(harmCategory: .dangerousContent, threshold: .blockOnlyHigh)]
3535

3636
// Instantiate Vertex AI SDK - Default App
37-
let vertexAI = VertexAI.vertexAI(location: "my-location")
37+
let vertexAI = VertexAI.vertexAI()
3838

3939
// Instantiate Vertex AI SDK - Custom App
40-
let _ = VertexAI.vertexAI(app: app!, location: "my-location")
40+
let _ = VertexAI.vertexAI(app: app!)
4141

4242
// Permutations without optional arguments.
4343

0 commit comments

Comments
 (0)