Skip to content

Commit d5c8b32

Browse files
committed
[Vertex AI] Add FirebaseVertexAIPreview SPM target for preview APIs
1 parent a3a026a commit d5c8b32

File tree

5 files changed

+67
-7
lines changed

5 files changed

+67
-7
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import FirebaseVertexAI
16+
import Foundation
17+
18+
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
19+
public extension VertexAI {
20+
func imagenModel(modelName: String, modelConfig: ImagenModelConfig? = nil,
21+
safetySettings: ImagenSafetySettings? = nil,
22+
requestOptions: RequestOptions = RequestOptions()) -> ImagenModel {
23+
return createImagenModel(
24+
modelName: modelName,
25+
modelConfig: modelConfig,
26+
safetySettings: safetySettings,
27+
requestOptions: requestOptions
28+
)
29+
}
30+
}

FirebaseVertexAI/Sources/VertexAI.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ public class VertexAI {
104104
)
105105
}
106106

107-
public func imagenModel(modelName: String, modelConfig: ImagenModelConfig? = nil,
108-
safetySettings: ImagenSafetySettings? = nil,
109-
requestOptions: RequestOptions = RequestOptions()) -> ImagenModel {
107+
// MARK: - Package APIs
108+
109+
package func createImagenModel(modelName: String, modelConfig: ImagenModelConfig?,
110+
safetySettings: ImagenSafetySettings?,
111+
requestOptions: RequestOptions) -> ImagenModel {
110112
return ImagenModel(
111113
name: modelResourceName(modelName: modelName),
112114
projectID: projectID,
@@ -119,12 +121,12 @@ public class VertexAI {
119121
)
120122
}
121123

124+
// MARK: - Private
125+
122126
/// Class to enable VertexAI to register via the Objective-C based Firebase component system
123127
/// to include VertexAI in the userAgent.
124128
@objc(FIRVertexAIComponent) class FirebaseVertexAIComponent: NSObject {}
125129

126-
// MARK: - Private
127-
128130
/// The `FirebaseApp` associated with this `VertexAI` instance.
129131
private let app: FirebaseApp
130132

FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import FirebaseAuth
1616
import FirebaseCore
1717
import FirebaseStorage
1818
import FirebaseVertexAI
19+
import FirebaseVertexAIPreview
1920
import VertexAITestApp
2021
import XCTest
2122

FirebaseVertexAI/Tests/TestApp/VertexAITestApp.xcodeproj/project.pbxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
862218812D04E098007ED2D4 /* IntegrationTestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 862218802D04E08D007ED2D4 /* IntegrationTestUtils.swift */; };
11+
86401F692D31B86E0026CAED /* FirebaseVertexAIPreview in Frameworks */ = {isa = PBXBuildFile; productRef = 86401F682D31B86E0026CAED /* FirebaseVertexAIPreview */; };
1112
8661385C2CC943DD00F4B78E /* TestApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8661385B2CC943DD00F4B78E /* TestApp.swift */; };
1213
8661385E2CC943DD00F4B78E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8661385D2CC943DD00F4B78E /* ContentView.swift */; };
1314
8661386E2CC943DE00F4B78E /* IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8661386D2CC943DE00F4B78E /* IntegrationTests.swift */; };
@@ -55,6 +56,7 @@
5556
buildActionMask = 2147483647;
5657
files = (
5758
8692F2982CC9477800539E8F /* FirebaseAppCheck in Frameworks */,
59+
86401F692D31B86E0026CAED /* FirebaseVertexAIPreview in Frameworks */,
5860
8692F29E2CC9477800539E8F /* FirebaseVertexAI in Frameworks */,
5961
8692F29A2CC9477800539E8F /* FirebaseAuth in Frameworks */,
6062
8692F29C2CC9477800539E8F /* FirebaseStorage in Frameworks */,
@@ -167,6 +169,7 @@
167169
8692F2992CC9477800539E8F /* FirebaseAuth */,
168170
8692F29B2CC9477800539E8F /* FirebaseStorage */,
169171
8692F29D2CC9477800539E8F /* FirebaseVertexAI */,
172+
86401F682D31B86E0026CAED /* FirebaseVertexAIPreview */,
170173
);
171174
productName = VertexAITestApp;
172175
productReference = 866138582CC943DD00F4B78E /* VertexAITestApp-SPM.app */;
@@ -560,6 +563,10 @@
560563
/* End XCLocalSwiftPackageReference section */
561564

562565
/* Begin XCSwiftPackageProductDependency section */
566+
86401F682D31B86E0026CAED /* FirebaseVertexAIPreview */ = {
567+
isa = XCSwiftPackageProductDependency;
568+
productName = FirebaseVertexAIPreview;
569+
};
563570
8692F2972CC9477800539E8F /* FirebaseAppCheck */ = {
564571
isa = XCSwiftPackageProductDependency;
565572
productName = FirebaseAppCheck;

Package.swift

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ let package = Package(
125125
name: "FirebaseVertexAI",
126126
targets: ["FirebaseVertexAI"]
127127
),
128+
.library(
129+
name: "FirebaseVertexAIPreview",
130+
targets: ["FirebaseVertexAIPreview"]
131+
),
128132
],
129133
dependencies: [
130134
.package(
@@ -1306,11 +1310,27 @@ let package = Package(
13061310
"FirebaseCore",
13071311
"FirebaseCoreExtension",
13081312
],
1309-
path: "FirebaseVertexAI/Sources"
1313+
path: "FirebaseVertexAI/Sources",
1314+
exclude: [
1315+
"VertexAI+Preview.swift",
1316+
]
1317+
),
1318+
.target(
1319+
name: "FirebaseVertexAIPreview",
1320+
dependencies: [
1321+
"FirebaseVertexAI",
1322+
],
1323+
path: "FirebaseVertexAI/Sources",
1324+
sources: [
1325+
"VertexAI+Preview.swift",
1326+
]
13101327
),
13111328
.testTarget(
13121329
name: "FirebaseVertexAIUnit",
1313-
dependencies: ["FirebaseVertexAI"],
1330+
dependencies: [
1331+
"FirebaseVertexAI",
1332+
"FirebaseVertexAIPreview",
1333+
],
13141334
path: "FirebaseVertexAI/Tests/Unit",
13151335
resources: [
13161336
.process("vertexai-sdk-test-data/mock-responses"),

0 commit comments

Comments
 (0)