File tree Expand file tree Collapse file tree 5 files changed +63
-7
lines changed Expand file tree Collapse file tree 5 files changed +63
-7
lines changed Original file line number Diff line number Diff line change @@ -344,7 +344,7 @@ export class GenerativeModel extends VertexAIModel {
344344}
345345
346346// @public
347- export function getGenerativeModel(vertexAI : VertexAI , modelParams : ModelParams , requestOptions ? : RequestOptions ): GenerativeModel ;
347+ export function getGenerativeModel(vertexAI : VertexAI , onCloudOrHybridParams : ModelParams | HybridParams , requestOptions ? : RequestOptions ): GenerativeModel ;
348348
349349// @beta
350350export function getImagenModel(vertexAI : VertexAI , modelParams : ImagenModelParams , requestOptions ? : RequestOptions ): ImagenModel ;
@@ -500,6 +500,28 @@ export interface ImagenSafetySettings {
500500 safetyFilterLevel? : ImagenSafetyFilterLevel ;
501501}
502502
503+ // @public
504+ export interface HybridParams {
505+ // (undocumented)
506+ mode? : InferenceMode ;
507+ // (undocumented)
508+ onCloudParams? : ModelParams ;
509+ // Warning: (ae-forgotten-export) The symbol "AILanguageModelCreateOptionsWithSystemPrompt" needs to be exported by the entry point index.d.ts
510+ //
511+ // (undocumented)
512+ onDeviceParams? : AILanguageModelCreateOptionsWithSystemPrompt ;
513+ }
514+
515+ // @public
516+ export enum InferenceMode {
517+ // (undocumented)
518+ ONLY_ON_CLOUD = " ONLY_ON_CLOUD" ,
519+ // (undocumented)
520+ ONLY_ON_DEVICE = " ONLY_ON_DEVICE" ,
521+ // (undocumented)
522+ PREFER_ON_DEVICE = " PREFER_ON_DEVICE"
523+ }
524+
503525// @public
504526export interface InlineDataPart {
505527 // (undocumented)
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { VertexAIService } from './service';
2323import { VertexAI , VertexAIOptions } from './public-types' ;
2424import {
2525 ImagenModelParams ,
26+ HybridParams ,
2627 ModelParams ,
2728 RequestOptions ,
2829 VertexAIErrorCode
@@ -70,16 +71,27 @@ export function getVertexAI(
7071 */
7172export function getGenerativeModel (
7273 vertexAI : VertexAI ,
73- modelParams : ModelParams ,
74+ onCloudOrHybridParams : ModelParams | HybridParams ,
7475 requestOptions ?: RequestOptions
7576) : GenerativeModel {
76- if ( ! modelParams . model ) {
77+ // Disambiguates onCloudOrHybridParams input.
78+ const hybridParams = onCloudOrHybridParams as HybridParams ;
79+ let onCloudParams : ModelParams ;
80+ if ( hybridParams . mode ) {
81+ onCloudParams = hybridParams . onCloudParams || {
82+ model : 'gemini-2.0-flash-lite'
83+ } ;
84+ } else {
85+ onCloudParams = onCloudOrHybridParams as ModelParams ;
86+ }
87+
88+ if ( ! onCloudParams . model ) {
7789 throw new VertexAIError (
7890 VertexAIErrorCode . NO_MODEL ,
7991 `Must provide a model name. Example: getGenerativeModel({ model: 'my-model-name' })`
8092 ) ;
8193 }
82- return new GenerativeModel ( vertexAI , modelParams , requestOptions ) ;
94+ return new GenerativeModel ( vertexAI , onCloudParams , requestOptions ) ;
8395}
8496
8597/**
Original file line number Diff line number Diff line change @@ -240,3 +240,13 @@ export enum Modality {
240240 */
241241 DOCUMENT = 'DOCUMENT'
242242}
243+
244+ /**
245+ * Determines whether inference happens on-device or on-cloud.
246+ * @public
247+ */
248+ export enum InferenceMode {
249+ PREFER_ON_DEVICE = 'PREFER_ON_DEVICE' ,
250+ ONLY_ON_DEVICE = 'ONLY_ON_DEVICE' ,
251+ ONLY_ON_CLOUD = 'ONLY_ON_CLOUD'
252+ }
Original file line number Diff line number Diff line change @@ -38,12 +38,12 @@ enum Availability {
3838 'downloading' ,
3939 'available'
4040}
41- interface LanguageModelCreateCoreOptions {
41+ export interface LanguageModelCreateCoreOptions {
4242 topK ?: number ;
4343 temperature ?: number ;
4444 expectedInputs ?: LanguageModelExpectedInput [ ] ;
4545}
46- interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
46+ export interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
4747 signal ?: AbortSignal ;
4848 systemPrompt ?: string ;
4949 initialPrompts ?: LanguageModelInitialPrompts ;
Original file line number Diff line number Diff line change 1717
1818import { TypedSchema } from '../requests/schema-builder' ;
1919import { Content , Part } from './content' ;
20+ import { LanguageModelCreateOptions } from './language-model' ;
2021import {
2122 FunctionCallingMode ,
2223 HarmBlockMethod ,
2324 HarmBlockThreshold ,
24- HarmCategory
25+ HarmCategory ,
26+ InferenceMode
2527} from './enums' ;
2628import { ObjectSchemaInterface , SchemaRequest } from './schema' ;
2729
@@ -213,3 +215,13 @@ export interface FunctionCallingConfig {
213215 mode ?: FunctionCallingMode ;
214216 allowedFunctionNames ?: string [ ] ;
215217}
218+
219+ /**
220+ * Configures on-device and on-cloud inference.
221+ * @public
222+ */
223+ export interface HybridParams {
224+ mode ?: InferenceMode ;
225+ onDeviceParams ?: LanguageModelCreateOptions ;
226+ onCloudParams ?: ModelParams ;
227+ }
You can’t perform that action at this time.
0 commit comments