Skip to content

Commit 874ce85

Browse files
committed
[Vertex AI] Switch to firebasevertexai.googleapis.com API
1 parent 801cbb3 commit 874ce85

File tree

5 files changed

+2
-85
lines changed

5 files changed

+2
-85
lines changed

FirebaseVertexAI/Sources/Constants.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,5 @@ import Foundation
2121
/// Constants associated with the Vertex AI for Firebase SDK.
2222
enum Constants {
2323
/// The Vertex AI backend endpoint URL.
24-
///
25-
/// TODO(andrewheard): Update to "https://firebasevertexai.googleapis.com" after the Vertex AI in
26-
/// Firebase API launch.
27-
static let baseURL = "https://firebaseml.googleapis.com"
24+
static let baseURL = "https://firebasevertexai.googleapis.com"
2825
}

FirebaseVertexAI/Sources/Errors.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ struct RPCError: Error {
3131
self.details = details
3232
}
3333

34-
// TODO(andrewheard): Remove this method after the Vertex AI in Firebase API launch.
35-
func isFirebaseMLServiceDisabledError() -> Bool {
36-
return details.contains { $0.isFirebaseMLServiceDisabledErrorDetails() }
37-
}
38-
3934
func isVertexAIInFirebaseServiceDisabledError() -> Bool {
4035
return details.contains { $0.isVertexAIInFirebaseServiceDisabledErrorDetails() }
4136
}
@@ -95,17 +90,6 @@ struct ErrorDetails {
9590
return isErrorInfo() && reason == "SERVICE_DISABLED" && domain == "googleapis.com"
9691
}
9792

98-
// TODO(andrewheard): Remove this method after the Vertex AI in Firebase API launch.
99-
func isFirebaseMLServiceDisabledErrorDetails() -> Bool {
100-
guard isServiceDisabledError() else {
101-
return false
102-
}
103-
guard let metadata, metadata["service"] == "firebaseml.googleapis.com" else {
104-
return false
105-
}
106-
return true
107-
}
108-
10993
func isVertexAIInFirebaseServiceDisabledErrorDetails() -> Bool {
11094
guard isServiceDisabledError() else {
11195
return false

FirebaseVertexAI/Sources/GenerativeAIRequest.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public struct RequestOptions {
3131
let timeout: TimeInterval?
3232

3333
/// The API version to use in requests to the backend.
34-
///
35-
/// TODO(andrewheard): Update to "v1beta" after the Vertex AI in Firebase API launch.
36-
let apiVersion = "v2beta"
34+
let apiVersion = "v1beta"
3735

3836
/// Initializes a request options object.
3937
///

FirebaseVertexAI/Sources/GenerativeAIService.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,6 @@ struct GenerativeAIService {
266266
// Log specific RPC errors that cannot be mitigated or handled by user code.
267267
// These errors do not produce specific GenerateContentError or CountTokensError cases.
268268
private func logRPCError(_ error: RPCError) {
269-
// TODO(andrewheard): Remove this check after the Vertex AI in Firebase API launch.
270-
if error.isFirebaseMLServiceDisabledError() {
271-
VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """
272-
The Vertex AI for Firebase SDK requires the Firebase ML API `firebaseml.googleapis.com` to \
273-
be enabled for your project. Get started in the Firebase Console \
274-
(https://console.firebase.google.com/project/\(projectID)/genai/vertex) or verify that the \
275-
API is enabled in the Google Cloud Console \
276-
(https://console.developers.google.com/apis/api/firebaseml.googleapis.com/overview?project=\
277-
\(projectID)).
278-
""")
279-
}
280-
281269
if error.isVertexAIInFirebaseServiceDisabledError() {
282270
VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """
283271
The Vertex AI for Firebase SDK requires the Firebase Vertex AI API \

FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -453,30 +453,6 @@ final class GenerativeModelTests: XCTestCase {
453453
}
454454
}
455455

456-
// TODO(andrewheard): Remove this test case after the Vertex AI in Firebase API launch.
457-
func testGenerateContent_failure_firebaseMLAPINotEnabled() async throws {
458-
let expectedStatusCode = 403
459-
MockURLProtocol
460-
.requestHandler = try httpRequestHandler(
461-
forResource: "unary-failure-firebaseml-api-not-enabled",
462-
withExtension: "json",
463-
statusCode: expectedStatusCode
464-
)
465-
466-
do {
467-
_ = try await model.generateContent(testPrompt)
468-
XCTFail("Should throw GenerateContentError.internalError; no error thrown.")
469-
} catch let GenerateContentError.internalError(error as RPCError) {
470-
XCTAssertEqual(error.httpResponseCode, expectedStatusCode)
471-
XCTAssertEqual(error.status, .permissionDenied)
472-
XCTAssertTrue(error.message.starts(with: "Firebase ML API has not been used in project"))
473-
XCTAssertTrue(error.isFirebaseMLServiceDisabledError())
474-
return
475-
} catch {
476-
XCTFail("Should throw GenerateContentError.internalError(RPCError); error thrown: \(error)")
477-
}
478-
}
479-
480456
func testGenerateContent_failure_firebaseVertexAIAPINotEnabled() async throws {
481457
let expectedStatusCode = 403
482458
MockURLProtocol
@@ -799,32 +775,6 @@ final class GenerativeModelTests: XCTestCase {
799775
XCTFail("Should have caught an error.")
800776
}
801777

802-
// TODO(andrewheard): Remove this test case after the Vertex AI in Firebase API launch.
803-
func testGenerateContentStream_failure_firebaseMLAPINotEnabled() async throws {
804-
let expectedStatusCode = 403
805-
MockURLProtocol
806-
.requestHandler = try httpRequestHandler(
807-
forResource: "unary-failure-firebaseml-api-not-enabled",
808-
withExtension: "json",
809-
statusCode: expectedStatusCode
810-
)
811-
812-
do {
813-
let stream = try model.generateContentStream(testPrompt)
814-
for try await _ in stream {
815-
XCTFail("No content is there, this shouldn't happen.")
816-
}
817-
} catch let GenerateContentError.internalError(error as RPCError) {
818-
XCTAssertEqual(error.httpResponseCode, expectedStatusCode)
819-
XCTAssertEqual(error.status, .permissionDenied)
820-
XCTAssertTrue(error.message.starts(with: "Firebase ML API has not been used in project"))
821-
XCTAssertTrue(error.isFirebaseMLServiceDisabledError())
822-
return
823-
}
824-
825-
XCTFail("Should have caught an error.")
826-
}
827-
828778
func testGenerateContentStream_failure_vertexAIInFirebaseAPINotEnabled() async throws {
829779
let expectedStatusCode = 403
830780
MockURLProtocol

0 commit comments

Comments
 (0)