Skip to content

Commit 6da14c8

Browse files
committed
[Vertex AI] Switch to firebasevertexai.googleapis.com API
# Conflicts: # FirebaseVertexAI/Sources/GenerativeAIService.swift
1 parent 2aab14a commit 6da14c8

File tree

5 files changed

+2
-84
lines changed

5 files changed

+2
-84
lines changed

FirebaseVertexAI/Sources/Constants.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@ import Foundation
1717
/// Constants associated with the Vertex AI for Firebase SDK.
1818
enum Constants {
1919
/// The Vertex AI backend endpoint URL.
20-
///
21-
/// TODO(andrewheard): Update to "https://firebasevertexai.googleapis.com" after the Vertex AI in
22-
/// Firebase API launch.
23-
static let baseURL = "https://firebaseml.googleapis.com"
20+
static let baseURL = "https://firebasevertexai.googleapis.com"
2421
}

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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ struct GenerativeAIService {
263263
// Log specific RPC errors that cannot be mitigated or handled by user code.
264264
// These errors do not produce specific GenerateContentError or CountTokensError cases.
265265
private func logRPCError(_ error: RPCError) {
266-
// TODO(andrewheard): Remove this check after the Vertex AI in Firebase API launch.
267-
if error.isFirebaseMLServiceDisabledError() {
268-
VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """
269-
The Vertex AI in Firebase SDK requires the Firebase ML API (`firebaseml.googleapis.com`) to \
270-
be enabled in your Firebase project. Enable this API by visiting the Firebase Console at
271-
https://console.firebase.google.com/project/\(projectID)/genai/ and clicking "Get started". \
272-
If you enabled this API recently, wait a few minutes for the action to propagate to our \
273-
systems and then retry.
274-
""")
275-
}
276-
277266
if error.isVertexAIInFirebaseServiceDisabledError() {
278267
VertexLog.error(code: .vertexAIInFirebaseAPIDisabled, """
279268
The Vertex AI in Firebase SDK requires the Vertex AI in Firebase 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)