@@ -57,8 +57,9 @@ class VertexComponentTests: XCTestCase {
57
57
XCTAssertNotNil ( vertex)
58
58
XCTAssertEqual ( vertex. firebaseInfo. projectID, VertexComponentTests . projectID)
59
59
XCTAssertEqual ( vertex. firebaseInfo. apiKey, VertexComponentTests . apiKey)
60
- XCTAssertEqual ( vertex. location, " us-central1 " )
61
- XCTAssertEqual ( vertex. apiConfig. service, . vertexAI( endpoint: . firebaseProxyProd) )
60
+ XCTAssertEqual (
61
+ vertex. apiConfig. service, . vertexAI( endpoint: . firebaseProxyProd, location: " us-central1 " )
62
+ )
62
63
XCTAssertEqual ( vertex. apiConfig. service. endpoint, . firebaseProxyProd)
63
64
XCTAssertEqual ( vertex. apiConfig. version, . v1beta)
64
65
}
@@ -71,8 +72,9 @@ class VertexComponentTests: XCTestCase {
71
72
XCTAssertNotNil ( vertex)
72
73
XCTAssertEqual ( vertex. firebaseInfo. projectID, VertexComponentTests . projectID)
73
74
XCTAssertEqual ( vertex. firebaseInfo. apiKey, VertexComponentTests . apiKey)
74
- XCTAssertEqual ( vertex. location, location)
75
- XCTAssertEqual ( vertex. apiConfig. service, . vertexAI( endpoint: . firebaseProxyProd) )
75
+ XCTAssertEqual (
76
+ vertex. apiConfig. service, . vertexAI( endpoint: . firebaseProxyProd, location: location)
77
+ )
76
78
XCTAssertEqual ( vertex. apiConfig. service. endpoint, . firebaseProxyProd)
77
79
XCTAssertEqual ( vertex. apiConfig. version, . v1beta)
78
80
}
@@ -87,8 +89,9 @@ class VertexComponentTests: XCTestCase {
87
89
XCTAssertNotNil ( vertex)
88
90
XCTAssertEqual ( vertex. firebaseInfo. projectID, VertexComponentTests . projectID)
89
91
XCTAssertEqual ( vertex. firebaseInfo. apiKey, VertexComponentTests . apiKey)
90
- XCTAssertEqual ( vertex. location, location)
91
- XCTAssertEqual ( vertex. apiConfig. service, . vertexAI( endpoint: . firebaseProxyProd) )
92
+ XCTAssertEqual (
93
+ vertex. apiConfig. service, . vertexAI( endpoint: . firebaseProxyProd, location: location)
94
+ )
92
95
XCTAssertEqual ( vertex. apiConfig. service. endpoint, . firebaseProxyProd)
93
96
XCTAssertEqual ( vertex. apiConfig. version, . v1beta)
94
97
}
@@ -154,14 +157,17 @@ class VertexComponentTests: XCTestCase {
154
157
func testSameAppAndDifferentAPI_newInstanceCreated( ) throws {
155
158
let vertex1 = FirebaseAI . createInstance (
156
159
app: VertexComponentTests . app,
157
- location: location,
158
- apiConfig: APIConfig ( service: . vertexAI( endpoint: . firebaseProxyProd) , version: . v1beta) ,
160
+ apiConfig: APIConfig (
161
+ service: . vertexAI( endpoint: . firebaseProxyProd, location: location) ,
162
+ version: . v1beta
163
+ ) ,
159
164
useLimitedUseAppCheckTokens: false
160
165
)
161
166
let vertex2 = FirebaseAI . createInstance (
162
167
app: VertexComponentTests . app,
163
- location: location,
164
- apiConfig: APIConfig ( service: . vertexAI( endpoint: . firebaseProxyProd) , version: . v1) ,
168
+ apiConfig: APIConfig (
169
+ service: . vertexAI( endpoint: . firebaseProxyProd, location: location) , version: . v1
170
+ ) ,
165
171
useLimitedUseAppCheckTokens: false
166
172
)
167
173
@@ -182,8 +188,10 @@ class VertexComponentTests: XCTestCase {
182
188
weakApp = try XCTUnwrap ( app1)
183
189
let vertex = FirebaseAI (
184
190
app: app1,
185
- location: " transitory location " ,
186
- apiConfig: FirebaseAI . defaultVertexAIAPIConfig,
191
+ apiConfig: APIConfig (
192
+ service: . vertexAI( endpoint: . firebaseProxyProd, location: " transitory location " ) ,
193
+ version: . v1beta,
194
+ ) ,
187
195
useLimitedUseAppCheckTokens: false
188
196
)
189
197
weakVertex = vertex
@@ -195,13 +203,13 @@ class VertexComponentTests: XCTestCase {
195
203
196
204
func testModelResourceName_vertexAI( ) throws {
197
205
let app = try XCTUnwrap ( VertexComponentTests . app)
206
+ let location = " test-location "
198
207
let vertex = FirebaseAI . firebaseAI ( app: app, backend: . vertexAI( location: location) )
199
208
let model = " test-model-name "
200
209
let projectID = vertex. firebaseInfo. projectID
201
210
202
211
let modelResourceName = vertex. modelResourceName ( modelName: model)
203
212
204
- let location = try XCTUnwrap ( vertex. location)
205
213
XCTAssertEqual (
206
214
modelResourceName,
207
215
" projects/ \( projectID) /locations/ \( location) /publishers/google/models/ \( model) "
@@ -212,10 +220,7 @@ class VertexComponentTests: XCTestCase {
212
220
let app = try XCTUnwrap ( VertexComponentTests . app)
213
221
let apiConfig = APIConfig ( service: . googleAI( endpoint: . googleAIBypassProxy) , version: . v1beta)
214
222
let vertex = FirebaseAI . createInstance (
215
- app: app,
216
- location: nil ,
217
- apiConfig: apiConfig,
218
- useLimitedUseAppCheckTokens: false
223
+ app: app, apiConfig: apiConfig, useLimitedUseAppCheckTokens: false
219
224
)
220
225
let model = " test-model-name "
221
226
@@ -231,10 +236,7 @@ class VertexComponentTests: XCTestCase {
231
236
version: . v1beta
232
237
)
233
238
let vertex = FirebaseAI . createInstance (
234
- app: app,
235
- location: nil ,
236
- apiConfig: apiConfig,
237
- useLimitedUseAppCheckTokens: false
239
+ app: app, apiConfig: apiConfig, useLimitedUseAppCheckTokens: false
238
240
)
239
241
let model = " test-model-name "
240
242
let projectID = vertex. firebaseInfo. projectID
@@ -244,33 +246,47 @@ class VertexComponentTests: XCTestCase {
244
246
XCTAssertEqual ( modelResourceName, " projects/ \( projectID) /models/ \( model) " )
245
247
}
246
248
247
- func testGenerativeModel_vertexAI ( ) async throws {
249
+ func testGenerativeModel_vertexAI_defaultLocation ( ) async throws {
248
250
let app = try XCTUnwrap ( VertexComponentTests . app)
249
- let vertex = FirebaseAI . firebaseAI ( app: app, backend: . vertexAI( location : location ) )
251
+ let vertex = FirebaseAI . firebaseAI ( app: app, backend: . vertexAI( ) )
250
252
let modelResourceName = vertex. modelResourceName ( modelName: modelName)
251
253
let expectedSystemInstruction = ModelContent ( role: nil , parts: systemInstruction. parts)
252
254
253
255
let generativeModel = vertex. generativeModel (
254
- modelName: modelName,
255
- systemInstruction: systemInstruction
256
+ modelName: modelName, systemInstruction: systemInstruction
256
257
)
257
258
258
259
XCTAssertEqual ( generativeModel. modelResourceName, modelResourceName)
259
260
XCTAssertEqual ( generativeModel. systemInstruction, expectedSystemInstruction)
260
261
XCTAssertEqual ( generativeModel. apiConfig, FirebaseAI . defaultVertexAIAPIConfig)
261
262
}
262
263
264
+ func testGenerativeModel_vertexAI_customLocation( ) async throws {
265
+ let app = try XCTUnwrap ( VertexComponentTests . app)
266
+ let vertex = FirebaseAI . firebaseAI ( app: app, backend: . vertexAI( location: location) )
267
+ let modelResourceName = vertex. modelResourceName ( modelName: modelName)
268
+ let expectedAPIConfig = APIConfig (
269
+ service: . vertexAI( endpoint: . firebaseProxyProd, location: location) , version: . v1beta
270
+ )
271
+ let expectedSystemInstruction = ModelContent ( role: nil , parts: systemInstruction. parts)
272
+
273
+ let generativeModel = vertex. generativeModel (
274
+ modelName: modelName, systemInstruction: systemInstruction
275
+ )
276
+
277
+ XCTAssertEqual ( generativeModel. modelResourceName, modelResourceName)
278
+ XCTAssertEqual ( generativeModel. systemInstruction, expectedSystemInstruction)
279
+ XCTAssertEqual ( generativeModel. apiConfig, expectedAPIConfig)
280
+ }
281
+
263
282
func testGenerativeModel_developerAPI( ) async throws {
264
283
let app = try XCTUnwrap ( VertexComponentTests . app)
265
284
let apiConfig = APIConfig (
266
285
service: . googleAI( endpoint: . firebaseProxyStaging) ,
267
286
version: . v1beta
268
287
)
269
288
let vertex = FirebaseAI . createInstance (
270
- app: app,
271
- location: nil ,
272
- apiConfig: apiConfig,
273
- useLimitedUseAppCheckTokens: false
289
+ app: app, apiConfig: apiConfig, useLimitedUseAppCheckTokens: false
274
290
)
275
291
let modelResourceName = vertex. modelResourceName ( modelName: modelName)
276
292
let expectedSystemInstruction = ModelContent ( role: nil , parts: systemInstruction. parts)
0 commit comments