Skip to content

Commit 559bd13

Browse files
committed
Parameterize default in-cloud model name
1 parent ae1c254 commit 559bd13

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

common/api-review/vertexai.api.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ export interface GenerativeContentBlob {
326326
export 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
420421
export 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
511512
export 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
}

packages/vertexai/src/api.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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' }

packages/vertexai/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;

packages/vertexai/src/models/generative-model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ import { VertexAIModel } from './vertexai-model';
4949
* @public
5050
*/
5151
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';
5256
generationConfig: GenerationConfig;
5357
safetySettings: SafetySetting[];
5458
requestOptions?: RequestOptions;

packages/vertexai/src/types/enums.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ export enum Modality {
243243

244244
/**
245245
* Determines whether inference happens on-device or in-cloud.
246-
* @public
247246
*/
248247
export enum InferenceMode {
249248
/**

packages/vertexai/src/types/requests.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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
*/
222221
export 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
*/

0 commit comments

Comments
 (0)