@google/genai 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -173,7 +173,16 @@ function setValueByPath(data, keys, value) {
173
173
  }
174
174
  }
175
175
  else {
176
- data[keyToSet] = value;
176
+ if (keyToSet === '_self' &&
177
+ typeof value === 'object' &&
178
+ value !== null &&
179
+ !Array.isArray(value)) {
180
+ const valueAsRecord = value;
181
+ Object.assign(data, valueAsRecord);
182
+ }
183
+ else {
184
+ data[keyToSet] = value;
185
+ }
177
186
  }
178
187
  }
179
188
  function getValueByPath(data, keys) {
@@ -1694,6 +1703,12 @@ class DeleteFileResponse {
1694
1703
  /** Config for `inlined_responses` parameter. */
1695
1704
  class InlinedResponse {
1696
1705
  }
1706
+ /** Config for `response` parameter. */
1707
+ class SingleEmbedContentResponse {
1708
+ }
1709
+ /** Config for `inlined_embedding_responses` parameter. */
1710
+ class InlinedEmbedContentResponse {
1711
+ }
1697
1712
  /** Config for batches.list return value. */
1698
1713
  class ListBatchJobsResponse {
1699
1714
  }
@@ -2545,51 +2560,59 @@ function mcpToolsToGeminiTool(mcpTools, config = {}) {
2545
2560
  return { functionDeclarations: functionDeclarations };
2546
2561
  }
2547
2562
  // Transforms a source input into a BatchJobSource object with validation.
2548
- function tBatchJobSource(apiClient, src) {
2549
- if (typeof src !== 'string' && !Array.isArray(src)) {
2550
- if (apiClient && apiClient.isVertexAI()) {
2551
- if (src.gcsUri && src.bigqueryUri) {
2552
- throw new Error('Only one of `gcsUri` or `bigqueryUri` can be set.');
2563
+ function tBatchJobSource(client, src) {
2564
+ let sourceObj;
2565
+ if (typeof src === 'string') {
2566
+ if (client.isVertexAI()) {
2567
+ if (src.startsWith('gs://')) {
2568
+ sourceObj = { format: 'jsonl', gcsUri: [src] };
2569
+ }
2570
+ else if (src.startsWith('bq://')) {
2571
+ sourceObj = { format: 'bigquery', bigqueryUri: src };
2553
2572
  }
2554
- else if (!src.gcsUri && !src.bigqueryUri) {
2555
- throw new Error('One of `gcsUri` or `bigqueryUri` must be set.');
2573
+ else {
2574
+ throw new Error(`Unsupported string source for Vertex AI: ${src}`);
2556
2575
  }
2557
2576
  }
2558
2577
  else {
2559
- // Logic for non-Vertex AI client (inlined_requests, file_name)
2560
- if (src.inlinedRequests && src.fileName) {
2561
- throw new Error('Only one of `inlinedRequests` or `fileName` can be set.');
2578
+ // MLDEV
2579
+ if (src.startsWith('files/')) {
2580
+ sourceObj = { fileName: src }; // Default to fileName for string input
2562
2581
  }
2563
- else if (!src.inlinedRequests && !src.fileName) {
2564
- throw new Error('One of `inlinedRequests` or `fileName` must be set.');
2582
+ else {
2583
+ throw new Error(`Unsupported string source for Gemini API: ${src}`);
2565
2584
  }
2566
2585
  }
2567
- return src;
2568
2586
  }
2569
- // If src is an array (list in Python)
2570
2587
  else if (Array.isArray(src)) {
2571
- return { inlinedRequests: src };
2572
- }
2573
- else if (typeof src === 'string') {
2574
- if (src.startsWith('gs://')) {
2575
- return {
2576
- format: 'jsonl',
2577
- gcsUri: [src], // GCS URI is expected as an array
2578
- };
2588
+ if (client.isVertexAI()) {
2589
+ throw new Error('InlinedRequest[] is not supported in Vertex AI.');
2579
2590
  }
2580
- else if (src.startsWith('bq://')) {
2581
- return {
2582
- format: 'bigquery',
2583
- bigqueryUri: src,
2584
- };
2591
+ sourceObj = { inlinedRequests: src };
2592
+ }
2593
+ else {
2594
+ // It's already a BatchJobSource object
2595
+ sourceObj = src;
2596
+ }
2597
+ // Validation logic
2598
+ const vertexSourcesCount = [sourceObj.gcsUri, sourceObj.bigqueryUri].filter(Boolean).length;
2599
+ const mldevSourcesCount = [
2600
+ sourceObj.inlinedRequests,
2601
+ sourceObj.fileName,
2602
+ ].filter(Boolean).length;
2603
+ if (client.isVertexAI()) {
2604
+ if (mldevSourcesCount > 0 || vertexSourcesCount !== 1) {
2605
+ throw new Error('Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.');
2585
2606
  }
2586
- else if (src.startsWith('files/')) {
2587
- return {
2588
- fileName: src,
2589
- };
2607
+ }
2608
+ else {
2609
+ // MLDEV
2610
+ if (vertexSourcesCount > 0 || mldevSourcesCount !== 1) {
2611
+ throw new Error('Exactly one of `inlinedRequests`, `fileName`, ' +
2612
+ 'must be set for Gemini API.');
2590
2613
  }
2591
2614
  }
2592
- throw new Error(`Unsupported source: ${src}`);
2615
+ return sourceObj;
2593
2616
  }
2594
2617
  function tBatchJobDestination(dest) {
2595
2618
  if (typeof dest !== 'string') {
@@ -2612,6 +2635,52 @@ function tBatchJobDestination(dest) {
2612
2635
  throw new Error(`Unsupported destination: ${destString}`);
2613
2636
  }
2614
2637
  }
2638
+ function tRecvBatchJobDestination(dest) {
2639
+ // Ensure dest is a non-null object before proceeding.
2640
+ if (typeof dest !== 'object' || dest === null) {
2641
+ // If the input is not an object, it cannot be a valid BatchJobDestination
2642
+ // based on the operations performed. Return it cast, or handle as an error.
2643
+ // Casting an empty object might be a safe default.
2644
+ return {};
2645
+ }
2646
+ // Cast to Record<string, unknown> to allow string property access.
2647
+ const obj = dest;
2648
+ // Safely access nested properties.
2649
+ const inlineResponsesVal = obj['inlinedResponses'];
2650
+ if (typeof inlineResponsesVal !== 'object' || inlineResponsesVal === null) {
2651
+ return dest;
2652
+ }
2653
+ const inlineResponsesObj = inlineResponsesVal;
2654
+ const responsesArray = inlineResponsesObj['inlinedResponses'];
2655
+ if (!Array.isArray(responsesArray) || responsesArray.length === 0) {
2656
+ return dest;
2657
+ }
2658
+ // Check if any response has the 'embedding' property.
2659
+ let hasEmbedding = false;
2660
+ for (const responseItem of responsesArray) {
2661
+ if (typeof responseItem !== 'object' || responseItem === null) {
2662
+ continue;
2663
+ }
2664
+ const responseItemObj = responseItem;
2665
+ const responseVal = responseItemObj['response'];
2666
+ if (typeof responseVal !== 'object' || responseVal === null) {
2667
+ continue;
2668
+ }
2669
+ const responseObj = responseVal;
2670
+ // Check for the existence of the 'embedding' key.
2671
+ if (responseObj['embedding'] !== undefined) {
2672
+ hasEmbedding = true;
2673
+ break;
2674
+ }
2675
+ }
2676
+ // Perform the transformation if an embedding was found.
2677
+ if (hasEmbedding) {
2678
+ obj['inlinedEmbedContentResponses'] = obj['inlinedResponses'];
2679
+ delete obj['inlinedResponses'];
2680
+ }
2681
+ // Cast the (potentially) modified object to the target type.
2682
+ return dest;
2683
+ }
2615
2684
  function tBatchJobName(apiClient, name) {
2616
2685
  const nameString = name;
2617
2686
  if (!apiClient.isVertexAI()) {
@@ -2707,6 +2776,22 @@ function fileDataToMldev$4(fromObject) {
2707
2776
  }
2708
2777
  return toObject;
2709
2778
  }
2779
+ function functionCallToMldev$4(fromObject) {
2780
+ const toObject = {};
2781
+ const fromId = getValueByPath(fromObject, ['id']);
2782
+ if (fromId != null) {
2783
+ setValueByPath(toObject, ['id'], fromId);
2784
+ }
2785
+ const fromArgs = getValueByPath(fromObject, ['args']);
2786
+ if (fromArgs != null) {
2787
+ setValueByPath(toObject, ['args'], fromArgs);
2788
+ }
2789
+ const fromName = getValueByPath(fromObject, ['name']);
2790
+ if (fromName != null) {
2791
+ setValueByPath(toObject, ['name'], fromName);
2792
+ }
2793
+ return toObject;
2794
+ }
2710
2795
  function partToMldev$4(fromObject) {
2711
2796
  const toObject = {};
2712
2797
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -2733,6 +2818,10 @@ function partToMldev$4(fromObject) {
2733
2818
  if (fromThoughtSignature != null) {
2734
2819
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
2735
2820
  }
2821
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2822
+ if (fromFunctionCall != null) {
2823
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
2824
+ }
2736
2825
  const fromCodeExecutionResult = getValueByPath(fromObject, [
2737
2826
  'codeExecutionResult',
2738
2827
  ]);
@@ -2745,10 +2834,6 @@ function partToMldev$4(fromObject) {
2745
2834
  if (fromExecutableCode != null) {
2746
2835
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
2747
2836
  }
2748
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2749
- if (fromFunctionCall != null) {
2750
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
2751
- }
2752
2837
  const fromFunctionResponse = getValueByPath(fromObject, [
2753
2838
  'functionResponse',
2754
2839
  ]);
@@ -3400,6 +3485,80 @@ function createBatchJobParametersToMldev(apiClient, fromObject) {
3400
3485
  }
3401
3486
  return toObject;
3402
3487
  }
3488
+ function embedContentConfigToMldev$1(fromObject, parentObject) {
3489
+ const toObject = {};
3490
+ const fromTaskType = getValueByPath(fromObject, ['taskType']);
3491
+ if (parentObject !== undefined && fromTaskType != null) {
3492
+ setValueByPath(parentObject, ['requests[]', 'taskType'], fromTaskType);
3493
+ }
3494
+ const fromTitle = getValueByPath(fromObject, ['title']);
3495
+ if (parentObject !== undefined && fromTitle != null) {
3496
+ setValueByPath(parentObject, ['requests[]', 'title'], fromTitle);
3497
+ }
3498
+ const fromOutputDimensionality = getValueByPath(fromObject, [
3499
+ 'outputDimensionality',
3500
+ ]);
3501
+ if (parentObject !== undefined && fromOutputDimensionality != null) {
3502
+ setValueByPath(parentObject, ['requests[]', 'outputDimensionality'], fromOutputDimensionality);
3503
+ }
3504
+ if (getValueByPath(fromObject, ['mimeType']) !== undefined) {
3505
+ throw new Error('mimeType parameter is not supported in Gemini API.');
3506
+ }
3507
+ if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
3508
+ throw new Error('autoTruncate parameter is not supported in Gemini API.');
3509
+ }
3510
+ return toObject;
3511
+ }
3512
+ function embedContentBatchToMldev(apiClient, fromObject) {
3513
+ const toObject = {};
3514
+ const fromContents = getValueByPath(fromObject, ['contents']);
3515
+ if (fromContents != null) {
3516
+ setValueByPath(toObject, ['requests[]', 'request', 'content'], tContentsForEmbed(apiClient, fromContents));
3517
+ }
3518
+ const fromConfig = getValueByPath(fromObject, ['config']);
3519
+ if (fromConfig != null) {
3520
+ setValueByPath(toObject, ['config'], embedContentConfigToMldev$1(fromConfig, toObject));
3521
+ }
3522
+ return toObject;
3523
+ }
3524
+ function embeddingsBatchJobSourceToMldev(apiClient, fromObject) {
3525
+ const toObject = {};
3526
+ const fromFileName = getValueByPath(fromObject, ['fileName']);
3527
+ if (fromFileName != null) {
3528
+ setValueByPath(toObject, ['file_name'], fromFileName);
3529
+ }
3530
+ const fromInlinedRequests = getValueByPath(fromObject, [
3531
+ 'inlinedRequests',
3532
+ ]);
3533
+ if (fromInlinedRequests != null) {
3534
+ setValueByPath(toObject, ['requests'], embedContentBatchToMldev(apiClient, fromInlinedRequests));
3535
+ }
3536
+ return toObject;
3537
+ }
3538
+ function createEmbeddingsBatchJobConfigToMldev(fromObject, parentObject) {
3539
+ const toObject = {};
3540
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3541
+ if (parentObject !== undefined && fromDisplayName != null) {
3542
+ setValueByPath(parentObject, ['batch', 'displayName'], fromDisplayName);
3543
+ }
3544
+ return toObject;
3545
+ }
3546
+ function createEmbeddingsBatchJobParametersToMldev(apiClient, fromObject) {
3547
+ const toObject = {};
3548
+ const fromModel = getValueByPath(fromObject, ['model']);
3549
+ if (fromModel != null) {
3550
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3551
+ }
3552
+ const fromSrc = getValueByPath(fromObject, ['src']);
3553
+ if (fromSrc != null) {
3554
+ setValueByPath(toObject, ['batch', 'inputConfig'], embeddingsBatchJobSourceToMldev(apiClient, fromSrc));
3555
+ }
3556
+ const fromConfig = getValueByPath(fromObject, ['config']);
3557
+ if (fromConfig != null) {
3558
+ setValueByPath(toObject, ['config'], createEmbeddingsBatchJobConfigToMldev(fromConfig, toObject));
3559
+ }
3560
+ return toObject;
3561
+ }
3403
3562
  function getBatchJobParametersToMldev(apiClient, fromObject) {
3404
3563
  const toObject = {};
3405
3564
  const fromName = getValueByPath(fromObject, ['name']);
@@ -3501,6 +3660,10 @@ function batchJobDestinationToVertex(fromObject) {
3501
3660
  if (getValueByPath(fromObject, ['inlinedResponses']) !== undefined) {
3502
3661
  throw new Error('inlinedResponses parameter is not supported in Vertex AI.');
3503
3662
  }
3663
+ if (getValueByPath(fromObject, ['inlinedEmbedContentResponses']) !==
3664
+ undefined) {
3665
+ throw new Error('inlinedEmbedContentResponses parameter is not supported in Vertex AI.');
3666
+ }
3504
3667
  return toObject;
3505
3668
  }
3506
3669
  function createBatchJobConfigToVertex(fromObject, parentObject) {
@@ -3631,6 +3794,22 @@ function fileDataFromMldev$2(fromObject) {
3631
3794
  }
3632
3795
  return toObject;
3633
3796
  }
3797
+ function functionCallFromMldev$2(fromObject) {
3798
+ const toObject = {};
3799
+ const fromId = getValueByPath(fromObject, ['id']);
3800
+ if (fromId != null) {
3801
+ setValueByPath(toObject, ['id'], fromId);
3802
+ }
3803
+ const fromArgs = getValueByPath(fromObject, ['args']);
3804
+ if (fromArgs != null) {
3805
+ setValueByPath(toObject, ['args'], fromArgs);
3806
+ }
3807
+ const fromName = getValueByPath(fromObject, ['name']);
3808
+ if (fromName != null) {
3809
+ setValueByPath(toObject, ['name'], fromName);
3810
+ }
3811
+ return toObject;
3812
+ }
3634
3813
  function partFromMldev$2(fromObject) {
3635
3814
  const toObject = {};
3636
3815
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -3657,6 +3836,10 @@ function partFromMldev$2(fromObject) {
3657
3836
  if (fromThoughtSignature != null) {
3658
3837
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
3659
3838
  }
3839
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3840
+ if (fromFunctionCall != null) {
3841
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$2(fromFunctionCall));
3842
+ }
3660
3843
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3661
3844
  'codeExecutionResult',
3662
3845
  ]);
@@ -3669,10 +3852,6 @@ function partFromMldev$2(fromObject) {
3669
3852
  if (fromExecutableCode != null) {
3670
3853
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
3671
3854
  }
3672
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3673
- if (fromFunctionCall != null) {
3674
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
3675
- }
3676
3855
  const fromFunctionResponse = getValueByPath(fromObject, [
3677
3856
  'functionResponse',
3678
3857
  ]);
@@ -3861,6 +4040,38 @@ function inlinedResponseFromMldev(fromObject) {
3861
4040
  }
3862
4041
  return toObject;
3863
4042
  }
4043
+ function contentEmbeddingFromMldev$1(fromObject) {
4044
+ const toObject = {};
4045
+ const fromValues = getValueByPath(fromObject, ['values']);
4046
+ if (fromValues != null) {
4047
+ setValueByPath(toObject, ['values'], fromValues);
4048
+ }
4049
+ return toObject;
4050
+ }
4051
+ function singleEmbedContentResponseFromMldev(fromObject) {
4052
+ const toObject = {};
4053
+ const fromEmbedding = getValueByPath(fromObject, ['embedding']);
4054
+ if (fromEmbedding != null) {
4055
+ setValueByPath(toObject, ['embedding'], contentEmbeddingFromMldev$1(fromEmbedding));
4056
+ }
4057
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
4058
+ if (fromTokenCount != null) {
4059
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
4060
+ }
4061
+ return toObject;
4062
+ }
4063
+ function inlinedEmbedContentResponseFromMldev(fromObject) {
4064
+ const toObject = {};
4065
+ const fromResponse = getValueByPath(fromObject, ['response']);
4066
+ if (fromResponse != null) {
4067
+ setValueByPath(toObject, ['response'], singleEmbedContentResponseFromMldev(fromResponse));
4068
+ }
4069
+ const fromError = getValueByPath(fromObject, ['error']);
4070
+ if (fromError != null) {
4071
+ setValueByPath(toObject, ['error'], jobErrorFromMldev(fromError));
4072
+ }
4073
+ return toObject;
4074
+ }
3864
4075
  function batchJobDestinationFromMldev(fromObject) {
3865
4076
  const toObject = {};
3866
4077
  const fromFileName = getValueByPath(fromObject, ['responsesFile']);
@@ -3880,6 +4091,19 @@ function batchJobDestinationFromMldev(fromObject) {
3880
4091
  }
3881
4092
  setValueByPath(toObject, ['inlinedResponses'], transformedList);
3882
4093
  }
4094
+ const fromInlinedEmbedContentResponses = getValueByPath(fromObject, [
4095
+ 'inlinedEmbedContentResponses',
4096
+ 'inlinedResponses',
4097
+ ]);
4098
+ if (fromInlinedEmbedContentResponses != null) {
4099
+ let transformedList = fromInlinedEmbedContentResponses;
4100
+ if (Array.isArray(transformedList)) {
4101
+ transformedList = transformedList.map((item) => {
4102
+ return inlinedEmbedContentResponseFromMldev(item);
4103
+ });
4104
+ }
4105
+ setValueByPath(toObject, ['inlinedEmbedContentResponses'], transformedList);
4106
+ }
3883
4107
  return toObject;
3884
4108
  }
3885
4109
  function batchJobFromMldev(fromObject) {
@@ -3926,7 +4150,7 @@ function batchJobFromMldev(fromObject) {
3926
4150
  }
3927
4151
  const fromDest = getValueByPath(fromObject, ['metadata', 'output']);
3928
4152
  if (fromDest != null) {
3929
- setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(fromDest));
4153
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(tRecvBatchJobDestination(fromDest)));
3930
4154
  }
3931
4155
  return toObject;
3932
4156
  }
@@ -4079,7 +4303,7 @@ function batchJobFromVertex(fromObject) {
4079
4303
  }
4080
4304
  const fromDest = getValueByPath(fromObject, ['outputConfig']);
4081
4305
  if (fromDest != null) {
4082
- setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(fromDest));
4306
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
4083
4307
  }
4084
4308
  return toObject;
4085
4309
  }
@@ -4345,79 +4569,87 @@ class Batches extends BaseModule {
4345
4569
  this.create = async (params) => {
4346
4570
  var _a, _b;
4347
4571
  if (this.apiClient.isVertexAI()) {
4348
- const timestamp = Date.now();
4349
- const timestampStr = timestamp.toString();
4350
- if (Array.isArray(params.src)) {
4351
- throw new Error('InlinedRequest[] is not supported in Vertex AI. Please use ' +
4352
- 'Google Cloud Storage URI or BigQuery URI instead.');
4353
- }
4354
- params.config = params.config || {};
4355
- if (params.config.displayName === undefined) {
4356
- params.config.displayName = 'genaiBatchJob_${timestampStr}';
4357
- }
4358
- if (params.config.dest === undefined && typeof params.src === 'string') {
4359
- if (params.src.startsWith('gs://') && params.src.endsWith('.jsonl')) {
4360
- params.config.dest = `${params.src.slice(0, -6)}/dest`;
4361
- }
4362
- else if (params.src.startsWith('bq://')) {
4363
- params.config.dest =
4364
- `${params.src}_dest_${timestampStr}`;
4365
- }
4366
- else {
4367
- throw new Error('Unsupported source:' + params.src);
4368
- }
4369
- }
4572
+ // Format destination if not provided
4573
+ // Cast params.src as Vertex AI path does not handle InlinedRequest[]
4574
+ params.config = this.formatDestination(params.src, params.config);
4575
+ return this.createInternal(params);
4370
4576
  }
4371
- else {
4372
- if (Array.isArray(params.src) ||
4373
- (typeof params.src !== 'string' && params.src.inlinedRequests)) {
4374
- // Move system instruction to httpOptions extraBody.
4375
- let path = '';
4376
- let queryParams = {};
4377
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4378
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4379
- queryParams = body['_query'];
4380
- // Move system instruction to 'request':
4381
- // {'systemInstruction': system_instruction}
4382
- const batch = body['batch'];
4383
- const inputConfig = batch['inputConfig'];
4384
- const requestsWrapper = inputConfig['requests'];
4385
- const requests = requestsWrapper['requests'];
4386
- const newRequests = [];
4387
- for (const request of requests) {
4388
- const requestDict = request;
4389
- if (requestDict['systemInstruction']) {
4390
- const systemInstructionValue = requestDict['systemInstruction'];
4391
- delete requestDict['systemInstruction'];
4392
- const requestContent = requestDict['request'];
4393
- requestContent['systemInstruction'] = systemInstructionValue;
4394
- requestDict['request'] = requestContent;
4395
- }
4396
- newRequests.push(requestDict);
4397
- }
4398
- requestsWrapper['requests'] = newRequests;
4399
- delete body['config'];
4400
- delete body['_url'];
4401
- delete body['_query'];
4402
- const response = this.apiClient
4403
- .request({
4404
- path: path,
4405
- queryParams: queryParams,
4406
- body: JSON.stringify(body),
4407
- httpMethod: 'POST',
4408
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4409
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4410
- })
4411
- .then((httpResponse) => {
4412
- return httpResponse.json();
4413
- });
4414
- return response.then((apiResponse) => {
4415
- const resp = batchJobFromMldev(apiResponse);
4416
- return resp;
4417
- });
4418
- }
4577
+ // MLDEV
4578
+ const src = params.src;
4579
+ const is_inlined = Array.isArray(params.src) || src.inlinedRequests !== undefined;
4580
+ if (!is_inlined) {
4581
+ return this.createInternal(params);
4419
4582
  }
4420
- return await this.createInternal(params);
4583
+ // Inlined generate content requests handling
4584
+ const result = this.createInlinedGenerateContentRequest(params);
4585
+ const path = result.path;
4586
+ const requestBody = result.body;
4587
+ const queryParams = createBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4588
+ const response = this.apiClient
4589
+ .request({
4590
+ path: path,
4591
+ queryParams: queryParams,
4592
+ body: JSON.stringify(requestBody),
4593
+ httpMethod: 'POST',
4594
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4595
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4596
+ })
4597
+ .then((httpResponse) => {
4598
+ return httpResponse.json();
4599
+ });
4600
+ return response.then((apiResponse) => {
4601
+ const resp = batchJobFromMldev(apiResponse);
4602
+ return resp;
4603
+ });
4604
+ };
4605
+ /**
4606
+ * **Experimental** Creates an embedding batch job.
4607
+ *
4608
+ * @param params - The parameters for create embedding batch job request.
4609
+ * @return The created batch job.
4610
+ *
4611
+ * @example
4612
+ * ```ts
4613
+ * const response = await ai.batches.createEmbeddings({
4614
+ * model: 'text-embedding-004',
4615
+ * src: {fileName: 'files/my_embedding_input'},
4616
+ * });
4617
+ * console.log(response);
4618
+ * ```
4619
+ */
4620
+ this.createEmbeddings = async (params) => {
4621
+ var _a, _b;
4622
+ console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4623
+ if (this.apiClient.isVertexAI()) {
4624
+ throw new Error('Vertex AI does not support batches.createEmbeddings.');
4625
+ }
4626
+ // MLDEV
4627
+ const src = params.src;
4628
+ const is_inlined = src.inlinedRequests !== undefined;
4629
+ if (!is_inlined) {
4630
+ return this.createEmbeddingsInternal(params); // Fixed typo here
4631
+ }
4632
+ // Inlined embed content requests handling
4633
+ const result = this.createInlinedEmbedContentRequest(params);
4634
+ const path = result.path;
4635
+ const requestBody = result.body;
4636
+ const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4637
+ const response = this.apiClient
4638
+ .request({
4639
+ path: path,
4640
+ queryParams: queryParams,
4641
+ body: JSON.stringify(requestBody),
4642
+ httpMethod: 'POST',
4643
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4644
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4645
+ })
4646
+ .then((httpResponse) => {
4647
+ return httpResponse.json();
4648
+ });
4649
+ return response.then((apiResponse) => {
4650
+ const resp = batchJobFromMldev(apiResponse);
4651
+ return resp;
4652
+ });
4421
4653
  };
4422
4654
  /**
4423
4655
  * Lists batch job configurations.
@@ -4437,6 +4669,112 @@ class Batches extends BaseModule {
4437
4669
  return new Pager(exports.PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4438
4670
  };
4439
4671
  }
4672
+ // Helper function to handle inlined generate content requests
4673
+ createInlinedGenerateContentRequest(params) {
4674
+ const body = createBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4675
+ params);
4676
+ const urlParams = body['_url'];
4677
+ const path = formatMap('{model}:batchGenerateContent', urlParams);
4678
+ const batch = body['batch'];
4679
+ const inputConfig = batch['inputConfig'];
4680
+ const requestsWrapper = inputConfig['requests'];
4681
+ const requests = requestsWrapper['requests'];
4682
+ const newRequests = [];
4683
+ for (const request of requests) {
4684
+ const requestDict = Object.assign({}, request); // Clone
4685
+ if (requestDict['systemInstruction']) {
4686
+ const systemInstructionValue = requestDict['systemInstruction'];
4687
+ delete requestDict['systemInstruction'];
4688
+ const requestContent = requestDict['request'];
4689
+ requestContent['systemInstruction'] = systemInstructionValue;
4690
+ requestDict['request'] = requestContent;
4691
+ }
4692
+ newRequests.push(requestDict);
4693
+ }
4694
+ requestsWrapper['requests'] = newRequests;
4695
+ delete body['config'];
4696
+ delete body['_url'];
4697
+ delete body['_query'];
4698
+ return { path, body };
4699
+ }
4700
+ // Helper function to handle inlined embedding requests
4701
+ createInlinedEmbedContentRequest(params) {
4702
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4703
+ params);
4704
+ const urlParams = body['_url'];
4705
+ const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
4706
+ const batch = body['batch'];
4707
+ const inputConfig = batch['inputConfig'];
4708
+ const requestsWrapper = inputConfig['requests'];
4709
+ const requests = requestsWrapper['requests'];
4710
+ const newRequests = [];
4711
+ delete requestsWrapper['config']; // Remove top-level config
4712
+ for (const request of requests) {
4713
+ const requestDict = Object.assign({}, request); // Clone
4714
+ const innerRequest = requestDict['request'];
4715
+ for (const key in requestDict) {
4716
+ if (key !== 'request') {
4717
+ innerRequest[key] = requestDict[key];
4718
+ delete requestDict[key];
4719
+ }
4720
+ }
4721
+ newRequests.push(requestDict);
4722
+ }
4723
+ requestsWrapper['requests'] = newRequests;
4724
+ delete body['config'];
4725
+ delete body['_url'];
4726
+ delete body['_query'];
4727
+ return { path, body };
4728
+ }
4729
+ // Helper function to get the first GCS URI
4730
+ getGcsUri(src) {
4731
+ if (typeof src === 'string') {
4732
+ return src.startsWith('gs://') ? src : undefined;
4733
+ }
4734
+ if (!Array.isArray(src) && src.gcsUri && src.gcsUri.length > 0) {
4735
+ return src.gcsUri[0];
4736
+ }
4737
+ return undefined;
4738
+ }
4739
+ // Helper function to get the BigQuery URI
4740
+ getBigqueryUri(src) {
4741
+ if (typeof src === 'string') {
4742
+ return src.startsWith('bq://') ? src : undefined;
4743
+ }
4744
+ if (!Array.isArray(src)) {
4745
+ return src.bigqueryUri;
4746
+ }
4747
+ return undefined;
4748
+ }
4749
+ // Function to format the destination configuration for Vertex AI
4750
+ formatDestination(src, config) {
4751
+ const newConfig = config ? Object.assign({}, config) : {};
4752
+ const timestampStr = Date.now().toString();
4753
+ if (!newConfig.displayName) {
4754
+ newConfig.displayName = `genaiBatchJob_${timestampStr}`;
4755
+ }
4756
+ if (newConfig.dest === undefined) {
4757
+ const gcsUri = this.getGcsUri(src);
4758
+ const bigqueryUri = this.getBigqueryUri(src);
4759
+ if (gcsUri) {
4760
+ if (gcsUri.endsWith('.jsonl')) {
4761
+ // For .jsonl files, remove suffix and add /dest
4762
+ newConfig.dest = `${gcsUri.slice(0, -6)}/dest`;
4763
+ }
4764
+ else {
4765
+ // Fallback for other GCS URIs
4766
+ newConfig.dest = `${gcsUri}_dest_${timestampStr}`;
4767
+ }
4768
+ }
4769
+ else if (bigqueryUri) {
4770
+ newConfig.dest = `${bigqueryUri}_dest_${timestampStr}`;
4771
+ }
4772
+ else {
4773
+ throw new Error('Unsupported source for Vertex AI: No GCS or BigQuery URI found.');
4774
+ }
4775
+ }
4776
+ return newConfig;
4777
+ }
4440
4778
  /**
4441
4779
  * Internal method to create batch job.
4442
4780
  *
@@ -4474,8 +4812,48 @@ class Batches extends BaseModule {
4474
4812
  });
4475
4813
  }
4476
4814
  else {
4477
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4478
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4815
+ const body = createBatchJobParametersToMldev(this.apiClient, params);
4816
+ path = formatMap('{model}:batchGenerateContent', body['_url']);
4817
+ queryParams = body['_query'];
4818
+ delete body['config'];
4819
+ delete body['_url'];
4820
+ delete body['_query'];
4821
+ response = this.apiClient
4822
+ .request({
4823
+ path: path,
4824
+ queryParams: queryParams,
4825
+ body: JSON.stringify(body),
4826
+ httpMethod: 'POST',
4827
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4828
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4829
+ })
4830
+ .then((httpResponse) => {
4831
+ return httpResponse.json();
4832
+ });
4833
+ return response.then((apiResponse) => {
4834
+ const resp = batchJobFromMldev(apiResponse);
4835
+ return resp;
4836
+ });
4837
+ }
4838
+ }
4839
+ /**
4840
+ * Internal method to create batch job.
4841
+ *
4842
+ * @param params - The parameters for create batch job request.
4843
+ * @return The created batch job.
4844
+ *
4845
+ */
4846
+ async createEmbeddingsInternal(params) {
4847
+ var _a, _b;
4848
+ let response;
4849
+ let path = '';
4850
+ let queryParams = {};
4851
+ if (this.apiClient.isVertexAI()) {
4852
+ throw new Error('This method is only supported by the Gemini Developer API.');
4853
+ }
4854
+ else {
4855
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params);
4856
+ path = formatMap('{model}:asyncBatchEmbedContent', body['_url']);
4479
4857
  queryParams = body['_query'];
4480
4858
  delete body['config'];
4481
4859
  delete body['_url'];
@@ -4486,8 +4864,8 @@ class Batches extends BaseModule {
4486
4864
  queryParams: queryParams,
4487
4865
  body: JSON.stringify(body),
4488
4866
  httpMethod: 'POST',
4489
- httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4490
- abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4867
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4868
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4491
4869
  })
4492
4870
  .then((httpResponse) => {
4493
4871
  return httpResponse.json();
@@ -4811,6 +5189,22 @@ function fileDataToMldev$3(fromObject) {
4811
5189
  }
4812
5190
  return toObject;
4813
5191
  }
5192
+ function functionCallToMldev$3(fromObject) {
5193
+ const toObject = {};
5194
+ const fromId = getValueByPath(fromObject, ['id']);
5195
+ if (fromId != null) {
5196
+ setValueByPath(toObject, ['id'], fromId);
5197
+ }
5198
+ const fromArgs = getValueByPath(fromObject, ['args']);
5199
+ if (fromArgs != null) {
5200
+ setValueByPath(toObject, ['args'], fromArgs);
5201
+ }
5202
+ const fromName = getValueByPath(fromObject, ['name']);
5203
+ if (fromName != null) {
5204
+ setValueByPath(toObject, ['name'], fromName);
5205
+ }
5206
+ return toObject;
5207
+ }
4814
5208
  function partToMldev$3(fromObject) {
4815
5209
  const toObject = {};
4816
5210
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -4837,6 +5231,10 @@ function partToMldev$3(fromObject) {
4837
5231
  if (fromThoughtSignature != null) {
4838
5232
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
4839
5233
  }
5234
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5235
+ if (fromFunctionCall != null) {
5236
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5237
+ }
4840
5238
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4841
5239
  'codeExecutionResult',
4842
5240
  ]);
@@ -4849,10 +5247,6 @@ function partToMldev$3(fromObject) {
4849
5247
  if (fromExecutableCode != null) {
4850
5248
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
4851
5249
  }
4852
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4853
- if (fromFunctionCall != null) {
4854
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4855
- }
4856
5250
  const fromFunctionResponse = getValueByPath(fromObject, [
4857
5251
  'functionResponse',
4858
5252
  ]);
@@ -5260,6 +5654,21 @@ function fileDataToVertex$2(fromObject) {
5260
5654
  }
5261
5655
  return toObject;
5262
5656
  }
5657
+ function functionCallToVertex$2(fromObject) {
5658
+ const toObject = {};
5659
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
5660
+ throw new Error('id parameter is not supported in Vertex AI.');
5661
+ }
5662
+ const fromArgs = getValueByPath(fromObject, ['args']);
5663
+ if (fromArgs != null) {
5664
+ setValueByPath(toObject, ['args'], fromArgs);
5665
+ }
5666
+ const fromName = getValueByPath(fromObject, ['name']);
5667
+ if (fromName != null) {
5668
+ setValueByPath(toObject, ['name'], fromName);
5669
+ }
5670
+ return toObject;
5671
+ }
5263
5672
  function partToVertex$2(fromObject) {
5264
5673
  const toObject = {};
5265
5674
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -5286,6 +5695,10 @@ function partToVertex$2(fromObject) {
5286
5695
  if (fromThoughtSignature != null) {
5287
5696
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
5288
5697
  }
5698
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5699
+ if (fromFunctionCall != null) {
5700
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$2(fromFunctionCall));
5701
+ }
5289
5702
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5290
5703
  'codeExecutionResult',
5291
5704
  ]);
@@ -5298,10 +5711,6 @@ function partToVertex$2(fromObject) {
5298
5711
  if (fromExecutableCode != null) {
5299
5712
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
5300
5713
  }
5301
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5302
- if (fromFunctionCall != null) {
5303
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5304
- }
5305
5714
  const fromFunctionResponse = getValueByPath(fromObject, [
5306
5715
  'functionResponse',
5307
5716
  ]);
@@ -7331,6 +7740,22 @@ function fileDataToMldev$2(fromObject) {
7331
7740
  }
7332
7741
  return toObject;
7333
7742
  }
7743
+ function functionCallToMldev$2(fromObject) {
7744
+ const toObject = {};
7745
+ const fromId = getValueByPath(fromObject, ['id']);
7746
+ if (fromId != null) {
7747
+ setValueByPath(toObject, ['id'], fromId);
7748
+ }
7749
+ const fromArgs = getValueByPath(fromObject, ['args']);
7750
+ if (fromArgs != null) {
7751
+ setValueByPath(toObject, ['args'], fromArgs);
7752
+ }
7753
+ const fromName = getValueByPath(fromObject, ['name']);
7754
+ if (fromName != null) {
7755
+ setValueByPath(toObject, ['name'], fromName);
7756
+ }
7757
+ return toObject;
7758
+ }
7334
7759
  function partToMldev$2(fromObject) {
7335
7760
  const toObject = {};
7336
7761
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -7357,6 +7782,10 @@ function partToMldev$2(fromObject) {
7357
7782
  if (fromThoughtSignature != null) {
7358
7783
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
7359
7784
  }
7785
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7786
+ if (fromFunctionCall != null) {
7787
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
7788
+ }
7360
7789
  const fromCodeExecutionResult = getValueByPath(fromObject, [
7361
7790
  'codeExecutionResult',
7362
7791
  ]);
@@ -7369,10 +7798,6 @@ function partToMldev$2(fromObject) {
7369
7798
  if (fromExecutableCode != null) {
7370
7799
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
7371
7800
  }
7372
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7373
- if (fromFunctionCall != null) {
7374
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
7375
- }
7376
7801
  const fromFunctionResponse = getValueByPath(fromObject, [
7377
7802
  'functionResponse',
7378
7803
  ]);
@@ -8035,6 +8460,21 @@ function fileDataToVertex$1(fromObject) {
8035
8460
  }
8036
8461
  return toObject;
8037
8462
  }
8463
+ function functionCallToVertex$1(fromObject) {
8464
+ const toObject = {};
8465
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
8466
+ throw new Error('id parameter is not supported in Vertex AI.');
8467
+ }
8468
+ const fromArgs = getValueByPath(fromObject, ['args']);
8469
+ if (fromArgs != null) {
8470
+ setValueByPath(toObject, ['args'], fromArgs);
8471
+ }
8472
+ const fromName = getValueByPath(fromObject, ['name']);
8473
+ if (fromName != null) {
8474
+ setValueByPath(toObject, ['name'], fromName);
8475
+ }
8476
+ return toObject;
8477
+ }
8038
8478
  function partToVertex$1(fromObject) {
8039
8479
  const toObject = {};
8040
8480
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8061,6 +8501,10 @@ function partToVertex$1(fromObject) {
8061
8501
  if (fromThoughtSignature != null) {
8062
8502
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8063
8503
  }
8504
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8505
+ if (fromFunctionCall != null) {
8506
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$1(fromFunctionCall));
8507
+ }
8064
8508
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8065
8509
  'codeExecutionResult',
8066
8510
  ]);
@@ -8073,10 +8517,6 @@ function partToVertex$1(fromObject) {
8073
8517
  if (fromExecutableCode != null) {
8074
8518
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8075
8519
  }
8076
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8077
- if (fromFunctionCall != null) {
8078
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8079
- }
8080
8520
  const fromFunctionResponse = getValueByPath(fromObject, [
8081
8521
  'functionResponse',
8082
8522
  ]);
@@ -8624,6 +9064,22 @@ function fileDataFromMldev$1(fromObject) {
8624
9064
  }
8625
9065
  return toObject;
8626
9066
  }
9067
+ function functionCallFromMldev$1(fromObject) {
9068
+ const toObject = {};
9069
+ const fromId = getValueByPath(fromObject, ['id']);
9070
+ if (fromId != null) {
9071
+ setValueByPath(toObject, ['id'], fromId);
9072
+ }
9073
+ const fromArgs = getValueByPath(fromObject, ['args']);
9074
+ if (fromArgs != null) {
9075
+ setValueByPath(toObject, ['args'], fromArgs);
9076
+ }
9077
+ const fromName = getValueByPath(fromObject, ['name']);
9078
+ if (fromName != null) {
9079
+ setValueByPath(toObject, ['name'], fromName);
9080
+ }
9081
+ return toObject;
9082
+ }
8627
9083
  function partFromMldev$1(fromObject) {
8628
9084
  const toObject = {};
8629
9085
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8650,6 +9106,10 @@ function partFromMldev$1(fromObject) {
8650
9106
  if (fromThoughtSignature != null) {
8651
9107
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8652
9108
  }
9109
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9110
+ if (fromFunctionCall != null) {
9111
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$1(fromFunctionCall));
9112
+ }
8653
9113
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8654
9114
  'codeExecutionResult',
8655
9115
  ]);
@@ -8662,10 +9122,6 @@ function partFromMldev$1(fromObject) {
8662
9122
  if (fromExecutableCode != null) {
8663
9123
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8664
9124
  }
8665
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8666
- if (fromFunctionCall != null) {
8667
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8668
- }
8669
9125
  const fromFunctionResponse = getValueByPath(fromObject, [
8670
9126
  'functionResponse',
8671
9127
  ]);
@@ -8782,22 +9238,6 @@ function liveServerContentFromMldev(fromObject) {
8782
9238
  }
8783
9239
  return toObject;
8784
9240
  }
8785
- function functionCallFromMldev(fromObject) {
8786
- const toObject = {};
8787
- const fromId = getValueByPath(fromObject, ['id']);
8788
- if (fromId != null) {
8789
- setValueByPath(toObject, ['id'], fromId);
8790
- }
8791
- const fromArgs = getValueByPath(fromObject, ['args']);
8792
- if (fromArgs != null) {
8793
- setValueByPath(toObject, ['args'], fromArgs);
8794
- }
8795
- const fromName = getValueByPath(fromObject, ['name']);
8796
- if (fromName != null) {
8797
- setValueByPath(toObject, ['name'], fromName);
8798
- }
8799
- return toObject;
8800
- }
8801
9241
  function liveServerToolCallFromMldev(fromObject) {
8802
9242
  const toObject = {};
8803
9243
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -8807,7 +9247,7 @@ function liveServerToolCallFromMldev(fromObject) {
8807
9247
  let transformedList = fromFunctionCalls;
8808
9248
  if (Array.isArray(transformedList)) {
8809
9249
  transformedList = transformedList.map((item) => {
8810
- return functionCallFromMldev(item);
9250
+ return functionCallFromMldev$1(item);
8811
9251
  });
8812
9252
  }
8813
9253
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9218,6 +9658,18 @@ function fileDataFromVertex$1(fromObject) {
9218
9658
  }
9219
9659
  return toObject;
9220
9660
  }
9661
+ function functionCallFromVertex$1(fromObject) {
9662
+ const toObject = {};
9663
+ const fromArgs = getValueByPath(fromObject, ['args']);
9664
+ if (fromArgs != null) {
9665
+ setValueByPath(toObject, ['args'], fromArgs);
9666
+ }
9667
+ const fromName = getValueByPath(fromObject, ['name']);
9668
+ if (fromName != null) {
9669
+ setValueByPath(toObject, ['name'], fromName);
9670
+ }
9671
+ return toObject;
9672
+ }
9221
9673
  function partFromVertex$1(fromObject) {
9222
9674
  const toObject = {};
9223
9675
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9244,6 +9696,10 @@ function partFromVertex$1(fromObject) {
9244
9696
  if (fromThoughtSignature != null) {
9245
9697
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9246
9698
  }
9699
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9700
+ if (fromFunctionCall != null) {
9701
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex$1(fromFunctionCall));
9702
+ }
9247
9703
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9248
9704
  'codeExecutionResult',
9249
9705
  ]);
@@ -9256,10 +9712,6 @@ function partFromVertex$1(fromObject) {
9256
9712
  if (fromExecutableCode != null) {
9257
9713
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9258
9714
  }
9259
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9260
- if (fromFunctionCall != null) {
9261
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9262
- }
9263
9715
  const fromFunctionResponse = getValueByPath(fromObject, [
9264
9716
  'functionResponse',
9265
9717
  ]);
@@ -9342,18 +9794,6 @@ function liveServerContentFromVertex(fromObject) {
9342
9794
  }
9343
9795
  return toObject;
9344
9796
  }
9345
- function functionCallFromVertex(fromObject) {
9346
- const toObject = {};
9347
- const fromArgs = getValueByPath(fromObject, ['args']);
9348
- if (fromArgs != null) {
9349
- setValueByPath(toObject, ['args'], fromArgs);
9350
- }
9351
- const fromName = getValueByPath(fromObject, ['name']);
9352
- if (fromName != null) {
9353
- setValueByPath(toObject, ['name'], fromName);
9354
- }
9355
- return toObject;
9356
- }
9357
9797
  function liveServerToolCallFromVertex(fromObject) {
9358
9798
  const toObject = {};
9359
9799
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -9363,7 +9803,7 @@ function liveServerToolCallFromVertex(fromObject) {
9363
9803
  let transformedList = fromFunctionCalls;
9364
9804
  if (Array.isArray(transformedList)) {
9365
9805
  transformedList = transformedList.map((item) => {
9366
- return functionCallFromVertex(item);
9806
+ return functionCallFromVertex$1(item);
9367
9807
  });
9368
9808
  }
9369
9809
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9602,6 +10042,22 @@ function fileDataToMldev$1(fromObject) {
9602
10042
  }
9603
10043
  return toObject;
9604
10044
  }
10045
+ function functionCallToMldev$1(fromObject) {
10046
+ const toObject = {};
10047
+ const fromId = getValueByPath(fromObject, ['id']);
10048
+ if (fromId != null) {
10049
+ setValueByPath(toObject, ['id'], fromId);
10050
+ }
10051
+ const fromArgs = getValueByPath(fromObject, ['args']);
10052
+ if (fromArgs != null) {
10053
+ setValueByPath(toObject, ['args'], fromArgs);
10054
+ }
10055
+ const fromName = getValueByPath(fromObject, ['name']);
10056
+ if (fromName != null) {
10057
+ setValueByPath(toObject, ['name'], fromName);
10058
+ }
10059
+ return toObject;
10060
+ }
9605
10061
  function partToMldev$1(fromObject) {
9606
10062
  const toObject = {};
9607
10063
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9628,6 +10084,10 @@ function partToMldev$1(fromObject) {
9628
10084
  if (fromThoughtSignature != null) {
9629
10085
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9630
10086
  }
10087
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10088
+ if (fromFunctionCall != null) {
10089
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
10090
+ }
9631
10091
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9632
10092
  'codeExecutionResult',
9633
10093
  ]);
@@ -9640,10 +10100,6 @@ function partToMldev$1(fromObject) {
9640
10100
  if (fromExecutableCode != null) {
9641
10101
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9642
10102
  }
9643
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9644
- if (fromFunctionCall != null) {
9645
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9646
- }
9647
10103
  const fromFunctionResponse = getValueByPath(fromObject, [
9648
10104
  'functionResponse',
9649
10105
  ]);
@@ -10666,6 +11122,21 @@ function fileDataToVertex(fromObject) {
10666
11122
  }
10667
11123
  return toObject;
10668
11124
  }
11125
+ function functionCallToVertex(fromObject) {
11126
+ const toObject = {};
11127
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
11128
+ throw new Error('id parameter is not supported in Vertex AI.');
11129
+ }
11130
+ const fromArgs = getValueByPath(fromObject, ['args']);
11131
+ if (fromArgs != null) {
11132
+ setValueByPath(toObject, ['args'], fromArgs);
11133
+ }
11134
+ const fromName = getValueByPath(fromObject, ['name']);
11135
+ if (fromName != null) {
11136
+ setValueByPath(toObject, ['name'], fromName);
11137
+ }
11138
+ return toObject;
11139
+ }
10669
11140
  function partToVertex(fromObject) {
10670
11141
  const toObject = {};
10671
11142
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -10692,6 +11163,10 @@ function partToVertex(fromObject) {
10692
11163
  if (fromThoughtSignature != null) {
10693
11164
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
10694
11165
  }
11166
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11167
+ if (fromFunctionCall != null) {
11168
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex(fromFunctionCall));
11169
+ }
10695
11170
  const fromCodeExecutionResult = getValueByPath(fromObject, [
10696
11171
  'codeExecutionResult',
10697
11172
  ]);
@@ -10704,10 +11179,6 @@ function partToVertex(fromObject) {
10704
11179
  if (fromExecutableCode != null) {
10705
11180
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
10706
11181
  }
10707
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10708
- if (fromFunctionCall != null) {
10709
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
10710
- }
10711
11182
  const fromFunctionResponse = getValueByPath(fromObject, [
10712
11183
  'functionResponse',
10713
11184
  ]);
@@ -12332,6 +12803,22 @@ function fileDataFromMldev(fromObject) {
12332
12803
  }
12333
12804
  return toObject;
12334
12805
  }
12806
+ function functionCallFromMldev(fromObject) {
12807
+ const toObject = {};
12808
+ const fromId = getValueByPath(fromObject, ['id']);
12809
+ if (fromId != null) {
12810
+ setValueByPath(toObject, ['id'], fromId);
12811
+ }
12812
+ const fromArgs = getValueByPath(fromObject, ['args']);
12813
+ if (fromArgs != null) {
12814
+ setValueByPath(toObject, ['args'], fromArgs);
12815
+ }
12816
+ const fromName = getValueByPath(fromObject, ['name']);
12817
+ if (fromName != null) {
12818
+ setValueByPath(toObject, ['name'], fromName);
12819
+ }
12820
+ return toObject;
12821
+ }
12335
12822
  function partFromMldev(fromObject) {
12336
12823
  const toObject = {};
12337
12824
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12358,6 +12845,10 @@ function partFromMldev(fromObject) {
12358
12845
  if (fromThoughtSignature != null) {
12359
12846
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
12360
12847
  }
12848
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12849
+ if (fromFunctionCall != null) {
12850
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev(fromFunctionCall));
12851
+ }
12361
12852
  const fromCodeExecutionResult = getValueByPath(fromObject, [
12362
12853
  'codeExecutionResult',
12363
12854
  ]);
@@ -12370,10 +12861,6 @@ function partFromMldev(fromObject) {
12370
12861
  if (fromExecutableCode != null) {
12371
12862
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
12372
12863
  }
12373
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12374
- if (fromFunctionCall != null) {
12375
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
12376
- }
12377
12864
  const fromFunctionResponse = getValueByPath(fromObject, [
12378
12865
  'functionResponse',
12379
12866
  ]);
@@ -12896,6 +13383,18 @@ function fileDataFromVertex(fromObject) {
12896
13383
  }
12897
13384
  return toObject;
12898
13385
  }
13386
+ function functionCallFromVertex(fromObject) {
13387
+ const toObject = {};
13388
+ const fromArgs = getValueByPath(fromObject, ['args']);
13389
+ if (fromArgs != null) {
13390
+ setValueByPath(toObject, ['args'], fromArgs);
13391
+ }
13392
+ const fromName = getValueByPath(fromObject, ['name']);
13393
+ if (fromName != null) {
13394
+ setValueByPath(toObject, ['name'], fromName);
13395
+ }
13396
+ return toObject;
13397
+ }
12899
13398
  function partFromVertex(fromObject) {
12900
13399
  const toObject = {};
12901
13400
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12922,6 +13421,10 @@ function partFromVertex(fromObject) {
12922
13421
  if (fromThoughtSignature != null) {
12923
13422
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
12924
13423
  }
13424
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
13425
+ if (fromFunctionCall != null) {
13426
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex(fromFunctionCall));
13427
+ }
12925
13428
  const fromCodeExecutionResult = getValueByPath(fromObject, [
12926
13429
  'codeExecutionResult',
12927
13430
  ]);
@@ -12934,10 +13437,6 @@ function partFromVertex(fromObject) {
12934
13437
  if (fromExecutableCode != null) {
12935
13438
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
12936
13439
  }
12937
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12938
- if (fromFunctionCall != null) {
12939
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
12940
- }
12941
13440
  const fromFunctionResponse = getValueByPath(fromObject, [
12942
13441
  'functionResponse',
12943
13442
  ]);
@@ -13612,7 +14111,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13612
14111
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13613
14112
  const USER_AGENT_HEADER = 'User-Agent';
13614
14113
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13615
- const SDK_VERSION = '1.17.0'; // x-release-please-version
14114
+ const SDK_VERSION = '1.18.0'; // x-release-please-version
13616
14115
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13617
14116
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13618
14117
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -16933,6 +17432,22 @@ function fileDataToMldev(fromObject) {
16933
17432
  }
16934
17433
  return toObject;
16935
17434
  }
17435
+ function functionCallToMldev(fromObject) {
17436
+ const toObject = {};
17437
+ const fromId = getValueByPath(fromObject, ['id']);
17438
+ if (fromId != null) {
17439
+ setValueByPath(toObject, ['id'], fromId);
17440
+ }
17441
+ const fromArgs = getValueByPath(fromObject, ['args']);
17442
+ if (fromArgs != null) {
17443
+ setValueByPath(toObject, ['args'], fromArgs);
17444
+ }
17445
+ const fromName = getValueByPath(fromObject, ['name']);
17446
+ if (fromName != null) {
17447
+ setValueByPath(toObject, ['name'], fromName);
17448
+ }
17449
+ return toObject;
17450
+ }
16936
17451
  function partToMldev(fromObject) {
16937
17452
  const toObject = {};
16938
17453
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -16959,6 +17474,10 @@ function partToMldev(fromObject) {
16959
17474
  if (fromThoughtSignature != null) {
16960
17475
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
16961
17476
  }
17477
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
17478
+ if (fromFunctionCall != null) {
17479
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
17480
+ }
16962
17481
  const fromCodeExecutionResult = getValueByPath(fromObject, [
16963
17482
  'codeExecutionResult',
16964
17483
  ]);
@@ -16971,10 +17490,6 @@ function partToMldev(fromObject) {
16971
17490
  if (fromExecutableCode != null) {
16972
17491
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
16973
17492
  }
16974
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
16975
- if (fromFunctionCall != null) {
16976
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
16977
- }
16978
17493
  const fromFunctionResponse = getValueByPath(fromObject, [
16979
17494
  'functionResponse',
16980
17495
  ]);
@@ -19274,6 +19789,7 @@ exports.GenerateVideosOperation = GenerateVideosOperation;
19274
19789
  exports.GenerateVideosResponse = GenerateVideosResponse;
19275
19790
  exports.GoogleGenAI = GoogleGenAI;
19276
19791
  exports.HttpResponse = HttpResponse;
19792
+ exports.InlinedEmbedContentResponse = InlinedEmbedContentResponse;
19277
19793
  exports.InlinedResponse = InlinedResponse;
19278
19794
  exports.ListBatchJobsResponse = ListBatchJobsResponse;
19279
19795
  exports.ListCachedContentsResponse = ListCachedContentsResponse;
@@ -19294,6 +19810,7 @@ exports.RecontextImageResponse = RecontextImageResponse;
19294
19810
  exports.ReplayResponse = ReplayResponse;
19295
19811
  exports.SegmentImageResponse = SegmentImageResponse;
19296
19812
  exports.Session = Session;
19813
+ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
19297
19814
  exports.StyleReferenceImage = StyleReferenceImage;
19298
19815
  exports.SubjectReferenceImage = SubjectReferenceImage;
19299
19816
  exports.Tokens = Tokens;