Skip to content

Commit 6aa848e

Browse files
cleop-googlecopybara-github
authored andcommitted
feat: Add Vertex Dataset input and output options for batch jobs
PiperOrigin-RevId: 902490891
1 parent 1a54ace commit 6aa848e

File tree

6 files changed

+152
-6
lines changed

6 files changed

+152
-6
lines changed

api-report/genai-node.api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export interface BatchJobDestination {
239239
gcsUri?: string;
240240
inlinedEmbedContentResponses?: InlinedEmbedContentResponse[];
241241
inlinedResponses?: InlinedResponse[];
242+
vertexDataset?: VertexMultimodalDatasetDestination;
242243
}
243244

244245
// @public (undocumented)
@@ -251,6 +252,7 @@ export interface BatchJobSource {
251252
format?: string;
252253
gcsUri?: string[];
253254
inlinedRequests?: InlinedRequest[];
255+
vertexDatasetName?: string;
254256
}
255257

256258
// @public (undocumented)
@@ -4127,6 +4129,12 @@ export interface VertexAISearchDataStoreSpec {
41274129
filter?: string;
41284130
}
41294131

4132+
// @public
4133+
export interface VertexMultimodalDatasetDestination {
4134+
bigqueryDestination?: string;
4135+
displayName?: string;
4136+
}
4137+
41304138
// @public
41314139
export interface VertexRagStore {
41324140
ragCorpora?: string[];

api-report/genai-web.api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export interface BatchJobDestination {
239239
gcsUri?: string;
240240
inlinedEmbedContentResponses?: InlinedEmbedContentResponse[];
241241
inlinedResponses?: InlinedResponse[];
242+
vertexDataset?: VertexMultimodalDatasetDestination;
242243
}
243244

244245
// @public (undocumented)
@@ -251,6 +252,7 @@ export interface BatchJobSource {
251252
format?: string;
252253
gcsUri?: string[];
253254
inlinedRequests?: InlinedRequest[];
255+
vertexDatasetName?: string;
254256
}
255257

256258
// @public (undocumented)
@@ -4127,6 +4129,12 @@ export interface VertexAISearchDataStoreSpec {
41274129
filter?: string;
41284130
}
41294131

4132+
// @public
4133+
export interface VertexMultimodalDatasetDestination {
4134+
bigqueryDestination?: string;
4135+
displayName?: string;
4136+
}
4137+
41304138
// @public
41314139
export interface VertexRagStore {
41324140
ragCorpora?: string[];

api-report/genai.api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export interface BatchJobDestination {
239239
gcsUri?: string;
240240
inlinedEmbedContentResponses?: InlinedEmbedContentResponse[];
241241
inlinedResponses?: InlinedResponse[];
242+
vertexDataset?: VertexMultimodalDatasetDestination;
242243
}
243244

244245
// @public (undocumented)
@@ -251,6 +252,7 @@ export interface BatchJobSource {
251252
format?: string;
252253
gcsUri?: string[];
253254
inlinedRequests?: InlinedRequest[];
255+
vertexDatasetName?: string;
254256
}
255257

256258
// @public (undocumented)
@@ -4127,6 +4129,12 @@ export interface VertexAISearchDataStoreSpec {
41274129
filter?: string;
41284130
}
41294131

4132+
// @public
4133+
export interface VertexMultimodalDatasetDestination {
4134+
bigqueryDestination?: string;
4135+
displayName?: string;
4136+
}
4137+
41304138
// @public
41314139
export interface VertexRagStore {
41324140
ragCorpora?: string[];

src/_transformers.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,10 @@ export function tBatchJobSource(
789789
sourceObj = {format: 'jsonl', gcsUri: [src]};
790790
} else if (src.startsWith('bq://')) {
791791
sourceObj = {format: 'bigquery', bigqueryUri: src};
792+
} else if (
793+
/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(src)
794+
) {
795+
sourceObj = {format: 'vertex-dataset', vertexDatasetName: src};
792796
} else {
793797
throw new Error(`Unsupported string source for Vertex AI: ${src}`);
794798
}
@@ -811,9 +815,11 @@ export function tBatchJobSource(
811815
}
812816

813817
// Validation logic
814-
const vertexSourcesCount = [sourceObj.gcsUri, sourceObj.bigqueryUri].filter(
815-
Boolean,
816-
).length;
818+
const vertexSourcesCount = [
819+
sourceObj.gcsUri,
820+
sourceObj.bigqueryUri,
821+
sourceObj.vertexDatasetName,
822+
].filter(Boolean).length;
817823

818824
const mldevSourcesCount = [
819825
sourceObj.inlinedRequests,
@@ -823,7 +829,7 @@ export function tBatchJobSource(
823829
if (client.isVertexAI()) {
824830
if (mldevSourcesCount > 0 || vertexSourcesCount !== 1) {
825831
throw new Error(
826-
'Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.',
832+
'Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.',
827833
);
828834
}
829835
} else {

src/converters/_batches_converters.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ export function batchJobDestinationFromVertex(
128128
common.setValueByPath(toObject, ['bigqueryUri'], fromBigqueryUri);
129129
}
130130

131+
const fromVertexDataset = common.getValueByPath(fromObject, [
132+
'vertexMultimodalDatasetDestination',
133+
]);
134+
if (fromVertexDataset != null) {
135+
common.setValueByPath(
136+
toObject,
137+
['vertexDataset'],
138+
vertexMultimodalDatasetDestinationFromVertex(fromVertexDataset),
139+
);
140+
}
141+
131142
return toObject;
132143
}
133144

@@ -178,6 +189,17 @@ export function batchJobDestinationToVertex(
178189
);
179190
}
180191

192+
const fromVertexDataset = common.getValueByPath(fromObject, [
193+
'vertexDataset',
194+
]);
195+
if (fromVertexDataset != null) {
196+
common.setValueByPath(
197+
toObject,
198+
['vertexMultimodalDatasetDestination'],
199+
vertexMultimodalDatasetDestinationToVertex(fromVertexDataset),
200+
);
201+
}
202+
181203
return toObject;
182204
}
183205

@@ -342,6 +364,18 @@ export function batchJobSourceFromVertex(
342364
common.setValueByPath(toObject, ['bigqueryUri'], fromBigqueryUri);
343365
}
344366

367+
const fromVertexDatasetName = common.getValueByPath(fromObject, [
368+
'vertexMultimodalDatasetSource',
369+
'datasetName',
370+
]);
371+
if (fromVertexDatasetName != null) {
372+
common.setValueByPath(
373+
toObject,
374+
['vertexDatasetName'],
375+
fromVertexDatasetName,
376+
);
377+
}
378+
345379
return toObject;
346380
}
347381

@@ -381,6 +415,12 @@ export function batchJobSourceToMldev(
381415
common.setValueByPath(toObject, ['requests', 'requests'], transformedList);
382416
}
383417

418+
if (common.getValueByPath(fromObject, ['vertexDatasetName']) !== undefined) {
419+
throw new Error(
420+
'vertexDatasetName parameter is not supported in Gemini API.',
421+
);
422+
}
423+
384424
return toObject;
385425
}
386426

@@ -416,6 +456,17 @@ export function batchJobSourceToVertex(
416456
throw new Error('inlinedRequests parameter is not supported in Vertex AI.');
417457
}
418458

459+
const fromVertexDatasetName = common.getValueByPath(fromObject, [
460+
'vertexDatasetName',
461+
]);
462+
if (fromVertexDatasetName != null) {
463+
common.setValueByPath(
464+
toObject,
465+
['vertexMultimodalDatasetSource', 'datasetName'],
466+
fromVertexDatasetName,
467+
);
468+
}
469+
419470
return toObject;
420471
}
421472

@@ -1989,3 +2040,52 @@ export function toolToMldev(fromObject: types.Tool): Record<string, unknown> {
19892040

19902041
return toObject;
19912042
}
2043+
2044+
export function vertexMultimodalDatasetDestinationFromVertex(
2045+
fromObject: types.VertexMultimodalDatasetDestination,
2046+
): Record<string, unknown> {
2047+
const toObject: Record<string, unknown> = {};
2048+
2049+
const fromBigqueryDestination = common.getValueByPath(fromObject, [
2050+
'bigqueryDestination',
2051+
'outputUri',
2052+
]);
2053+
if (fromBigqueryDestination != null) {
2054+
common.setValueByPath(
2055+
toObject,
2056+
['bigqueryDestination'],
2057+
fromBigqueryDestination,
2058+
);
2059+
}
2060+
2061+
const fromDisplayName = common.getValueByPath(fromObject, ['displayName']);
2062+
if (fromDisplayName != null) {
2063+
common.setValueByPath(toObject, ['displayName'], fromDisplayName);
2064+
}
2065+
2066+
return toObject;
2067+
}
2068+
2069+
export function vertexMultimodalDatasetDestinationToVertex(
2070+
fromObject: types.VertexMultimodalDatasetDestination,
2071+
): Record<string, unknown> {
2072+
const toObject: Record<string, unknown> = {};
2073+
2074+
const fromBigqueryDestination = common.getValueByPath(fromObject, [
2075+
'bigqueryDestination',
2076+
]);
2077+
if (fromBigqueryDestination != null) {
2078+
common.setValueByPath(
2079+
toObject,
2080+
['bigqueryDestination', 'outputUri'],
2081+
fromBigqueryDestination,
2082+
);
2083+
}
2084+
2085+
const fromDisplayName = common.getValueByPath(fromObject, ['displayName']);
2086+
if (fromDisplayName != null) {
2087+
common.setValueByPath(toObject, ['displayName'], fromDisplayName);
2088+
}
2089+
2090+
return toObject;
2091+
}

src/types.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6156,7 +6156,7 @@ export declare interface InlinedRequest {
61566156
/** Config for `src` parameter. */
61576157
export declare interface BatchJobSource {
61586158
/** Storage format of the input files. Must be one of:
6159-
'jsonl', 'bigquery'.
6159+
'jsonl', 'bigquery', 'vertex-dataset'.
61606160
*/
61616161
format?: string;
61626162
/** The Google Cloud Storage URIs to input files.
@@ -6172,6 +6172,19 @@ export declare interface BatchJobSource {
61726172
/** The Gemini Developer API's inlined input data to run batch job.
61736173
*/
61746174
inlinedRequests?: InlinedRequest[];
6175+
/** This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal.
6176+
*/
6177+
vertexDatasetName?: string;
6178+
}
6179+
6180+
/** This class is experimental and may change in future versions.
6181+
6182+
The specification for an output Vertex AI multimodal dataset. */
6183+
export declare interface VertexMultimodalDatasetDestination {
6184+
/** The BigQuery destination for the multimodal dataset. */
6185+
bigqueryDestination?: string;
6186+
/** The display name of the multimodal dataset. */
6187+
displayName?: string;
61756188
}
61766189

61776190
/** Job error. */
@@ -6219,7 +6232,7 @@ export class InlinedEmbedContentResponse {
62196232
/** Config for `des` parameter. */
62206233
export declare interface BatchJobDestination {
62216234
/** Storage format of the output files. Must be one of:
6222-
'jsonl', 'bigquery'.
6235+
'jsonl', 'bigquery', 'vertex-dataset'.
62236236
*/
62246237
format?: string;
62256238
/** The Google Cloud Storage URI to the output file.
@@ -6245,6 +6258,9 @@ export declare interface BatchJobDestination {
62456258
the input requests.
62466259
*/
62476260
inlinedEmbedContentResponses?: InlinedEmbedContentResponse[];
6261+
/** This field is experimental and may change in future versions. The Vertex AI dataset destination.
6262+
*/
6263+
vertexDataset?: VertexMultimodalDatasetDestination;
62486264
}
62496265

62506266
/** Config for optional parameters. */

0 commit comments

Comments
 (0)