File tree Expand file tree Collapse file tree 6 files changed +21
-10
lines changed Expand file tree Collapse file tree 6 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,7 @@ export interface GenerativeContentBlob {
326
326
export class GenerativeModel extends VertexAIModel {
327
327
constructor (vertexAI : VertexAI , modelParams : ModelParams , requestOptions ? : RequestOptions );
328
328
countTokens(request : CountTokensRequest | string | Array <string | Part >): Promise <CountTokensResponse >;
329
+ static DEFAULT_HYBRID_IN_CLOUD_MODEL: string ;
329
330
generateContent(request : GenerateContentRequest | string | Array <string | Part >): Promise <GenerateContentResult >;
330
331
generateContentStream(request : GenerateContentRequest | string | Array <string | Part >): Promise <GenerateContentStreamResult >;
331
332
// (undocumented)
@@ -418,8 +419,8 @@ export enum HarmSeverity {
418
419
419
420
// @public
420
421
export interface HybridParams {
421
- mode ? : InferenceMode ;
422
- onCloudParams ? : ModelParams ;
422
+ inCloudParams ? : ModelParams ;
423
+ mode : InferenceMode ;
423
424
onDeviceParams? : AILanguageModelCreateOptionsWithSystemPrompt ;
424
425
}
425
426
@@ -509,7 +510,7 @@ export interface ImagenSafetySettings {
509
510
510
511
// @public
511
512
export enum InferenceMode {
512
- ONLY_ON_CLOUD = " ONLY_ON_CLOUD " ,
513
+ ONLY_IN_CLOUD = " ONLY_IN_CLOUD " ,
513
514
ONLY_ON_DEVICE = " ONLY_ON_DEVICE" ,
514
515
PREFER_ON_DEVICE = " PREFER_ON_DEVICE"
515
516
}
Original file line number Diff line number Diff line change @@ -106,7 +106,15 @@ describe('Top level API', () => {
106
106
expect ( genModel ) . to . be . an . instanceOf ( GenerativeModel ) ;
107
107
expect ( genModel . model ) . to . equal ( 'publishers/google/models/my-model' ) ;
108
108
} ) ;
109
- it ( 'getGenerativeModel with HybridParams sets the model' , ( ) => {
109
+ it ( 'getGenerativeModel with HybridParams sets a default model' , ( ) => {
110
+ const genModel = getGenerativeModel ( fakeVertexAI , {
111
+ mode : InferenceMode . ONLY_ON_DEVICE
112
+ } ) ;
113
+ expect ( genModel . model ) . to . equal (
114
+ `publishers/google/models/${ GenerativeModel . DEFAULT_HYBRID_IN_CLOUD_MODEL } `
115
+ ) ;
116
+ } ) ;
117
+ it ( 'getGenerativeModel with HybridParams honors a model override' , ( ) => {
110
118
const genModel = getGenerativeModel ( fakeVertexAI , {
111
119
mode : InferenceMode . ONLY_IN_CLOUD ,
112
120
inCloudParams : { model : 'my-model' }
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export function getGenerativeModel(
79
79
let inCloudParams : ModelParams ;
80
80
if ( hybridParams . mode ) {
81
81
inCloudParams = hybridParams . inCloudParams || {
82
- model : 'gemini-2.0-flash-lite'
82
+ model : GenerativeModel . DEFAULT_HYBRID_IN_CLOUD_MODEL
83
83
} ;
84
84
} else {
85
85
inCloudParams = modelParams as ModelParams ;
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ import { VertexAIModel } from './vertexai-model';
49
49
* @public
50
50
*/
51
51
export class GenerativeModel extends VertexAIModel {
52
+ /**
53
+ * Defines the name of the default in-cloud model to use for hybrid inference.
54
+ */
55
+ static DEFAULT_HYBRID_IN_CLOUD_MODEL = 'gemini-2.0-flash-lite' ;
52
56
generationConfig : GenerationConfig ;
53
57
safetySettings : SafetySetting [ ] ;
54
58
requestOptions ?: RequestOptions ;
Original file line number Diff line number Diff line change @@ -243,7 +243,6 @@ export enum Modality {
243
243
244
244
/**
245
245
* Determines whether inference happens on-device or in-cloud.
246
- * @public
247
246
*/
248
247
export enum InferenceMode {
249
248
/**
Original file line number Diff line number Diff line change @@ -216,14 +216,13 @@ export interface FunctionCallingConfig {
216
216
}
217
217
218
218
/**
219
- * Configures on-device and in-cloud inference.
220
- * @public
219
+ * Toggles hybrid inference.
221
220
*/
222
221
export interface HybridParams {
223
222
/**
224
- * Optional. Specifies on-device or in-cloud inference. Defaults to prefer on-device.
223
+ * Specifies on-device or in-cloud inference. Defaults to prefer on-device.
225
224
*/
226
- mode ? : InferenceMode ;
225
+ mode : InferenceMode ;
227
226
/**
228
227
* Optional. Specifies advanced params for on-device inference.
229
228
*/
You can’t perform that action at this time.
0 commit comments