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 {
326326export class GenerativeModel extends VertexAIModel {
327327 constructor (vertexAI : VertexAI , modelParams : ModelParams , requestOptions ? : RequestOptions );
328328 countTokens(request : CountTokensRequest | string | Array <string | Part >): Promise <CountTokensResponse >;
329+ static DEFAULT_HYBRID_IN_CLOUD_MODEL: string ;
329330 generateContent(request : GenerateContentRequest | string | Array <string | Part >): Promise <GenerateContentResult >;
330331 generateContentStream(request : GenerateContentRequest | string | Array <string | Part >): Promise <GenerateContentStreamResult >;
331332 // (undocumented)
@@ -418,8 +419,8 @@ export enum HarmSeverity {
418419
419420// @public
420421export interface HybridParams {
421- mode ? : InferenceMode ;
422- onCloudParams ? : ModelParams ;
422+ inCloudParams ? : ModelParams ;
423+ mode : InferenceMode ;
423424 onDeviceParams? : AILanguageModelCreateOptionsWithSystemPrompt ;
424425}
425426
@@ -509,7 +510,7 @@ export interface ImagenSafetySettings {
509510
510511// @public
511512export enum InferenceMode {
512- ONLY_ON_CLOUD = " ONLY_ON_CLOUD " ,
513+ ONLY_IN_CLOUD = " ONLY_IN_CLOUD " ,
513514 ONLY_ON_DEVICE = " ONLY_ON_DEVICE" ,
514515 PREFER_ON_DEVICE = " PREFER_ON_DEVICE"
515516}
Original file line number Diff line number Diff line change @@ -106,7 +106,15 @@ describe('Top level API', () => {
106106 expect ( genModel ) . to . be . an . instanceOf ( GenerativeModel ) ;
107107 expect ( genModel . model ) . to . equal ( 'publishers/google/models/my-model' ) ;
108108 } ) ;
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' , ( ) => {
110118 const genModel = getGenerativeModel ( fakeVertexAI , {
111119 mode : InferenceMode . ONLY_IN_CLOUD ,
112120 inCloudParams : { model : 'my-model' }
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export function getGenerativeModel(
7979 let inCloudParams : ModelParams ;
8080 if ( hybridParams . mode ) {
8181 inCloudParams = hybridParams . inCloudParams || {
82- model : 'gemini-2.0-flash-lite'
82+ model : GenerativeModel . DEFAULT_HYBRID_IN_CLOUD_MODEL
8383 } ;
8484 } else {
8585 inCloudParams = modelParams as ModelParams ;
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ import { VertexAIModel } from './vertexai-model';
4949 * @public
5050 */
5151export 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' ;
5256 generationConfig : GenerationConfig ;
5357 safetySettings : SafetySetting [ ] ;
5458 requestOptions ?: RequestOptions ;
Original file line number Diff line number Diff line change @@ -243,7 +243,6 @@ export enum Modality {
243243
244244/**
245245 * Determines whether inference happens on-device or in-cloud.
246- * @public
247246 */
248247export enum InferenceMode {
249248 /**
Original file line number Diff line number Diff line change @@ -216,14 +216,13 @@ export interface FunctionCallingConfig {
216216}
217217
218218/**
219- * Configures on-device and in-cloud inference.
220- * @public
219+ * Toggles hybrid inference.
221220 */
222221export interface HybridParams {
223222 /**
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.
225224 */
226- mode ? : InferenceMode ;
225+ mode : InferenceMode ;
227226 /**
228227 * Optional. Specifies advanced params for on-device inference.
229228 */
You can’t perform that action at this time.
0 commit comments