@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.
@@ -151,7 +151,16 @@ function setValueByPath(data, keys, value) {
151
151
  }
152
152
  }
153
153
  else {
154
- data[keyToSet] = value;
154
+ if (keyToSet === '_self' &&
155
+ typeof value === 'object' &&
156
+ value !== null &&
157
+ !Array.isArray(value)) {
158
+ const valueAsRecord = value;
159
+ Object.assign(data, valueAsRecord);
160
+ }
161
+ else {
162
+ data[keyToSet] = value;
163
+ }
155
164
  }
156
165
  }
157
166
  function getValueByPath(data, keys) {
@@ -1672,6 +1681,12 @@ class DeleteFileResponse {
1672
1681
  /** Config for `inlined_responses` parameter. */
1673
1682
  class InlinedResponse {
1674
1683
  }
1684
+ /** Config for `response` parameter. */
1685
+ class SingleEmbedContentResponse {
1686
+ }
1687
+ /** Config for `inlined_embedding_responses` parameter. */
1688
+ class InlinedEmbedContentResponse {
1689
+ }
1675
1690
  /** Config for batches.list return value. */
1676
1691
  class ListBatchJobsResponse {
1677
1692
  }
@@ -2523,51 +2538,59 @@ function mcpToolsToGeminiTool(mcpTools, config = {}) {
2523
2538
  return { functionDeclarations: functionDeclarations };
2524
2539
  }
2525
2540
  // Transforms a source input into a BatchJobSource object with validation.
2526
- function tBatchJobSource(apiClient, src) {
2527
- if (typeof src !== 'string' && !Array.isArray(src)) {
2528
- if (apiClient && apiClient.isVertexAI()) {
2529
- if (src.gcsUri && src.bigqueryUri) {
2530
- throw new Error('Only one of `gcsUri` or `bigqueryUri` can be set.');
2541
+ function tBatchJobSource(client, src) {
2542
+ let sourceObj;
2543
+ if (typeof src === 'string') {
2544
+ if (client.isVertexAI()) {
2545
+ if (src.startsWith('gs://')) {
2546
+ sourceObj = { format: 'jsonl', gcsUri: [src] };
2547
+ }
2548
+ else if (src.startsWith('bq://')) {
2549
+ sourceObj = { format: 'bigquery', bigqueryUri: src };
2531
2550
  }
2532
- else if (!src.gcsUri && !src.bigqueryUri) {
2533
- throw new Error('One of `gcsUri` or `bigqueryUri` must be set.');
2551
+ else {
2552
+ throw new Error(`Unsupported string source for Vertex AI: ${src}`);
2534
2553
  }
2535
2554
  }
2536
2555
  else {
2537
- // Logic for non-Vertex AI client (inlined_requests, file_name)
2538
- if (src.inlinedRequests && src.fileName) {
2539
- throw new Error('Only one of `inlinedRequests` or `fileName` can be set.');
2556
+ // MLDEV
2557
+ if (src.startsWith('files/')) {
2558
+ sourceObj = { fileName: src }; // Default to fileName for string input
2540
2559
  }
2541
- else if (!src.inlinedRequests && !src.fileName) {
2542
- throw new Error('One of `inlinedRequests` or `fileName` must be set.');
2560
+ else {
2561
+ throw new Error(`Unsupported string source for Gemini API: ${src}`);
2543
2562
  }
2544
2563
  }
2545
- return src;
2546
2564
  }
2547
- // If src is an array (list in Python)
2548
2565
  else if (Array.isArray(src)) {
2549
- return { inlinedRequests: src };
2550
- }
2551
- else if (typeof src === 'string') {
2552
- if (src.startsWith('gs://')) {
2553
- return {
2554
- format: 'jsonl',
2555
- gcsUri: [src], // GCS URI is expected as an array
2556
- };
2566
+ if (client.isVertexAI()) {
2567
+ throw new Error('InlinedRequest[] is not supported in Vertex AI.');
2557
2568
  }
2558
- else if (src.startsWith('bq://')) {
2559
- return {
2560
- format: 'bigquery',
2561
- bigqueryUri: src,
2562
- };
2569
+ sourceObj = { inlinedRequests: src };
2570
+ }
2571
+ else {
2572
+ // It's already a BatchJobSource object
2573
+ sourceObj = src;
2574
+ }
2575
+ // Validation logic
2576
+ const vertexSourcesCount = [sourceObj.gcsUri, sourceObj.bigqueryUri].filter(Boolean).length;
2577
+ const mldevSourcesCount = [
2578
+ sourceObj.inlinedRequests,
2579
+ sourceObj.fileName,
2580
+ ].filter(Boolean).length;
2581
+ if (client.isVertexAI()) {
2582
+ if (mldevSourcesCount > 0 || vertexSourcesCount !== 1) {
2583
+ throw new Error('Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.');
2563
2584
  }
2564
- else if (src.startsWith('files/')) {
2565
- return {
2566
- fileName: src,
2567
- };
2585
+ }
2586
+ else {
2587
+ // MLDEV
2588
+ if (vertexSourcesCount > 0 || mldevSourcesCount !== 1) {
2589
+ throw new Error('Exactly one of `inlinedRequests`, `fileName`, ' +
2590
+ 'must be set for Gemini API.');
2568
2591
  }
2569
2592
  }
2570
- throw new Error(`Unsupported source: ${src}`);
2593
+ return sourceObj;
2571
2594
  }
2572
2595
  function tBatchJobDestination(dest) {
2573
2596
  if (typeof dest !== 'string') {
@@ -2590,6 +2613,52 @@ function tBatchJobDestination(dest) {
2590
2613
  throw new Error(`Unsupported destination: ${destString}`);
2591
2614
  }
2592
2615
  }
2616
+ function tRecvBatchJobDestination(dest) {
2617
+ // Ensure dest is a non-null object before proceeding.
2618
+ if (typeof dest !== 'object' || dest === null) {
2619
+ // If the input is not an object, it cannot be a valid BatchJobDestination
2620
+ // based on the operations performed. Return it cast, or handle as an error.
2621
+ // Casting an empty object might be a safe default.
2622
+ return {};
2623
+ }
2624
+ // Cast to Record<string, unknown> to allow string property access.
2625
+ const obj = dest;
2626
+ // Safely access nested properties.
2627
+ const inlineResponsesVal = obj['inlinedResponses'];
2628
+ if (typeof inlineResponsesVal !== 'object' || inlineResponsesVal === null) {
2629
+ return dest;
2630
+ }
2631
+ const inlineResponsesObj = inlineResponsesVal;
2632
+ const responsesArray = inlineResponsesObj['inlinedResponses'];
2633
+ if (!Array.isArray(responsesArray) || responsesArray.length === 0) {
2634
+ return dest;
2635
+ }
2636
+ // Check if any response has the 'embedding' property.
2637
+ let hasEmbedding = false;
2638
+ for (const responseItem of responsesArray) {
2639
+ if (typeof responseItem !== 'object' || responseItem === null) {
2640
+ continue;
2641
+ }
2642
+ const responseItemObj = responseItem;
2643
+ const responseVal = responseItemObj['response'];
2644
+ if (typeof responseVal !== 'object' || responseVal === null) {
2645
+ continue;
2646
+ }
2647
+ const responseObj = responseVal;
2648
+ // Check for the existence of the 'embedding' key.
2649
+ if (responseObj['embedding'] !== undefined) {
2650
+ hasEmbedding = true;
2651
+ break;
2652
+ }
2653
+ }
2654
+ // Perform the transformation if an embedding was found.
2655
+ if (hasEmbedding) {
2656
+ obj['inlinedEmbedContentResponses'] = obj['inlinedResponses'];
2657
+ delete obj['inlinedResponses'];
2658
+ }
2659
+ // Cast the (potentially) modified object to the target type.
2660
+ return dest;
2661
+ }
2593
2662
  function tBatchJobName(apiClient, name) {
2594
2663
  const nameString = name;
2595
2664
  if (!apiClient.isVertexAI()) {
@@ -2685,6 +2754,22 @@ function fileDataToMldev$4(fromObject) {
2685
2754
  }
2686
2755
  return toObject;
2687
2756
  }
2757
+ function functionCallToMldev$4(fromObject) {
2758
+ const toObject = {};
2759
+ const fromId = getValueByPath(fromObject, ['id']);
2760
+ if (fromId != null) {
2761
+ setValueByPath(toObject, ['id'], fromId);
2762
+ }
2763
+ const fromArgs = getValueByPath(fromObject, ['args']);
2764
+ if (fromArgs != null) {
2765
+ setValueByPath(toObject, ['args'], fromArgs);
2766
+ }
2767
+ const fromName = getValueByPath(fromObject, ['name']);
2768
+ if (fromName != null) {
2769
+ setValueByPath(toObject, ['name'], fromName);
2770
+ }
2771
+ return toObject;
2772
+ }
2688
2773
  function partToMldev$4(fromObject) {
2689
2774
  const toObject = {};
2690
2775
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -2711,6 +2796,10 @@ function partToMldev$4(fromObject) {
2711
2796
  if (fromThoughtSignature != null) {
2712
2797
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
2713
2798
  }
2799
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2800
+ if (fromFunctionCall != null) {
2801
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
2802
+ }
2714
2803
  const fromCodeExecutionResult = getValueByPath(fromObject, [
2715
2804
  'codeExecutionResult',
2716
2805
  ]);
@@ -2723,10 +2812,6 @@ function partToMldev$4(fromObject) {
2723
2812
  if (fromExecutableCode != null) {
2724
2813
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
2725
2814
  }
2726
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2727
- if (fromFunctionCall != null) {
2728
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
2729
- }
2730
2815
  const fromFunctionResponse = getValueByPath(fromObject, [
2731
2816
  'functionResponse',
2732
2817
  ]);
@@ -3378,6 +3463,80 @@ function createBatchJobParametersToMldev(apiClient, fromObject) {
3378
3463
  }
3379
3464
  return toObject;
3380
3465
  }
3466
+ function embedContentConfigToMldev$1(fromObject, parentObject) {
3467
+ const toObject = {};
3468
+ const fromTaskType = getValueByPath(fromObject, ['taskType']);
3469
+ if (parentObject !== undefined && fromTaskType != null) {
3470
+ setValueByPath(parentObject, ['requests[]', 'taskType'], fromTaskType);
3471
+ }
3472
+ const fromTitle = getValueByPath(fromObject, ['title']);
3473
+ if (parentObject !== undefined && fromTitle != null) {
3474
+ setValueByPath(parentObject, ['requests[]', 'title'], fromTitle);
3475
+ }
3476
+ const fromOutputDimensionality = getValueByPath(fromObject, [
3477
+ 'outputDimensionality',
3478
+ ]);
3479
+ if (parentObject !== undefined && fromOutputDimensionality != null) {
3480
+ setValueByPath(parentObject, ['requests[]', 'outputDimensionality'], fromOutputDimensionality);
3481
+ }
3482
+ if (getValueByPath(fromObject, ['mimeType']) !== undefined) {
3483
+ throw new Error('mimeType parameter is not supported in Gemini API.');
3484
+ }
3485
+ if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
3486
+ throw new Error('autoTruncate parameter is not supported in Gemini API.');
3487
+ }
3488
+ return toObject;
3489
+ }
3490
+ function embedContentBatchToMldev(apiClient, fromObject) {
3491
+ const toObject = {};
3492
+ const fromContents = getValueByPath(fromObject, ['contents']);
3493
+ if (fromContents != null) {
3494
+ setValueByPath(toObject, ['requests[]', 'request', 'content'], tContentsForEmbed(apiClient, fromContents));
3495
+ }
3496
+ const fromConfig = getValueByPath(fromObject, ['config']);
3497
+ if (fromConfig != null) {
3498
+ setValueByPath(toObject, ['config'], embedContentConfigToMldev$1(fromConfig, toObject));
3499
+ }
3500
+ return toObject;
3501
+ }
3502
+ function embeddingsBatchJobSourceToMldev(apiClient, fromObject) {
3503
+ const toObject = {};
3504
+ const fromFileName = getValueByPath(fromObject, ['fileName']);
3505
+ if (fromFileName != null) {
3506
+ setValueByPath(toObject, ['file_name'], fromFileName);
3507
+ }
3508
+ const fromInlinedRequests = getValueByPath(fromObject, [
3509
+ 'inlinedRequests',
3510
+ ]);
3511
+ if (fromInlinedRequests != null) {
3512
+ setValueByPath(toObject, ['requests'], embedContentBatchToMldev(apiClient, fromInlinedRequests));
3513
+ }
3514
+ return toObject;
3515
+ }
3516
+ function createEmbeddingsBatchJobConfigToMldev(fromObject, parentObject) {
3517
+ const toObject = {};
3518
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3519
+ if (parentObject !== undefined && fromDisplayName != null) {
3520
+ setValueByPath(parentObject, ['batch', 'displayName'], fromDisplayName);
3521
+ }
3522
+ return toObject;
3523
+ }
3524
+ function createEmbeddingsBatchJobParametersToMldev(apiClient, fromObject) {
3525
+ const toObject = {};
3526
+ const fromModel = getValueByPath(fromObject, ['model']);
3527
+ if (fromModel != null) {
3528
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3529
+ }
3530
+ const fromSrc = getValueByPath(fromObject, ['src']);
3531
+ if (fromSrc != null) {
3532
+ setValueByPath(toObject, ['batch', 'inputConfig'], embeddingsBatchJobSourceToMldev(apiClient, fromSrc));
3533
+ }
3534
+ const fromConfig = getValueByPath(fromObject, ['config']);
3535
+ if (fromConfig != null) {
3536
+ setValueByPath(toObject, ['config'], createEmbeddingsBatchJobConfigToMldev(fromConfig, toObject));
3537
+ }
3538
+ return toObject;
3539
+ }
3381
3540
  function getBatchJobParametersToMldev(apiClient, fromObject) {
3382
3541
  const toObject = {};
3383
3542
  const fromName = getValueByPath(fromObject, ['name']);
@@ -3479,6 +3638,10 @@ function batchJobDestinationToVertex(fromObject) {
3479
3638
  if (getValueByPath(fromObject, ['inlinedResponses']) !== undefined) {
3480
3639
  throw new Error('inlinedResponses parameter is not supported in Vertex AI.');
3481
3640
  }
3641
+ if (getValueByPath(fromObject, ['inlinedEmbedContentResponses']) !==
3642
+ undefined) {
3643
+ throw new Error('inlinedEmbedContentResponses parameter is not supported in Vertex AI.');
3644
+ }
3482
3645
  return toObject;
3483
3646
  }
3484
3647
  function createBatchJobConfigToVertex(fromObject, parentObject) {
@@ -3609,6 +3772,22 @@ function fileDataFromMldev$2(fromObject) {
3609
3772
  }
3610
3773
  return toObject;
3611
3774
  }
3775
+ function functionCallFromMldev$2(fromObject) {
3776
+ const toObject = {};
3777
+ const fromId = getValueByPath(fromObject, ['id']);
3778
+ if (fromId != null) {
3779
+ setValueByPath(toObject, ['id'], fromId);
3780
+ }
3781
+ const fromArgs = getValueByPath(fromObject, ['args']);
3782
+ if (fromArgs != null) {
3783
+ setValueByPath(toObject, ['args'], fromArgs);
3784
+ }
3785
+ const fromName = getValueByPath(fromObject, ['name']);
3786
+ if (fromName != null) {
3787
+ setValueByPath(toObject, ['name'], fromName);
3788
+ }
3789
+ return toObject;
3790
+ }
3612
3791
  function partFromMldev$2(fromObject) {
3613
3792
  const toObject = {};
3614
3793
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -3635,6 +3814,10 @@ function partFromMldev$2(fromObject) {
3635
3814
  if (fromThoughtSignature != null) {
3636
3815
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
3637
3816
  }
3817
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3818
+ if (fromFunctionCall != null) {
3819
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$2(fromFunctionCall));
3820
+ }
3638
3821
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3639
3822
  'codeExecutionResult',
3640
3823
  ]);
@@ -3647,10 +3830,6 @@ function partFromMldev$2(fromObject) {
3647
3830
  if (fromExecutableCode != null) {
3648
3831
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
3649
3832
  }
3650
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3651
- if (fromFunctionCall != null) {
3652
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
3653
- }
3654
3833
  const fromFunctionResponse = getValueByPath(fromObject, [
3655
3834
  'functionResponse',
3656
3835
  ]);
@@ -3839,6 +4018,38 @@ function inlinedResponseFromMldev(fromObject) {
3839
4018
  }
3840
4019
  return toObject;
3841
4020
  }
4021
+ function contentEmbeddingFromMldev$1(fromObject) {
4022
+ const toObject = {};
4023
+ const fromValues = getValueByPath(fromObject, ['values']);
4024
+ if (fromValues != null) {
4025
+ setValueByPath(toObject, ['values'], fromValues);
4026
+ }
4027
+ return toObject;
4028
+ }
4029
+ function singleEmbedContentResponseFromMldev(fromObject) {
4030
+ const toObject = {};
4031
+ const fromEmbedding = getValueByPath(fromObject, ['embedding']);
4032
+ if (fromEmbedding != null) {
4033
+ setValueByPath(toObject, ['embedding'], contentEmbeddingFromMldev$1(fromEmbedding));
4034
+ }
4035
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
4036
+ if (fromTokenCount != null) {
4037
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
4038
+ }
4039
+ return toObject;
4040
+ }
4041
+ function inlinedEmbedContentResponseFromMldev(fromObject) {
4042
+ const toObject = {};
4043
+ const fromResponse = getValueByPath(fromObject, ['response']);
4044
+ if (fromResponse != null) {
4045
+ setValueByPath(toObject, ['response'], singleEmbedContentResponseFromMldev(fromResponse));
4046
+ }
4047
+ const fromError = getValueByPath(fromObject, ['error']);
4048
+ if (fromError != null) {
4049
+ setValueByPath(toObject, ['error'], jobErrorFromMldev(fromError));
4050
+ }
4051
+ return toObject;
4052
+ }
3842
4053
  function batchJobDestinationFromMldev(fromObject) {
3843
4054
  const toObject = {};
3844
4055
  const fromFileName = getValueByPath(fromObject, ['responsesFile']);
@@ -3858,6 +4069,19 @@ function batchJobDestinationFromMldev(fromObject) {
3858
4069
  }
3859
4070
  setValueByPath(toObject, ['inlinedResponses'], transformedList);
3860
4071
  }
4072
+ const fromInlinedEmbedContentResponses = getValueByPath(fromObject, [
4073
+ 'inlinedEmbedContentResponses',
4074
+ 'inlinedResponses',
4075
+ ]);
4076
+ if (fromInlinedEmbedContentResponses != null) {
4077
+ let transformedList = fromInlinedEmbedContentResponses;
4078
+ if (Array.isArray(transformedList)) {
4079
+ transformedList = transformedList.map((item) => {
4080
+ return inlinedEmbedContentResponseFromMldev(item);
4081
+ });
4082
+ }
4083
+ setValueByPath(toObject, ['inlinedEmbedContentResponses'], transformedList);
4084
+ }
3861
4085
  return toObject;
3862
4086
  }
3863
4087
  function batchJobFromMldev(fromObject) {
@@ -3904,7 +4128,7 @@ function batchJobFromMldev(fromObject) {
3904
4128
  }
3905
4129
  const fromDest = getValueByPath(fromObject, ['metadata', 'output']);
3906
4130
  if (fromDest != null) {
3907
- setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(fromDest));
4131
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(tRecvBatchJobDestination(fromDest)));
3908
4132
  }
3909
4133
  return toObject;
3910
4134
  }
@@ -4057,7 +4281,7 @@ function batchJobFromVertex(fromObject) {
4057
4281
  }
4058
4282
  const fromDest = getValueByPath(fromObject, ['outputConfig']);
4059
4283
  if (fromDest != null) {
4060
- setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(fromDest));
4284
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
4061
4285
  }
4062
4286
  return toObject;
4063
4287
  }
@@ -4323,79 +4547,87 @@ class Batches extends BaseModule {
4323
4547
  this.create = async (params) => {
4324
4548
  var _a, _b;
4325
4549
  if (this.apiClient.isVertexAI()) {
4326
- const timestamp = Date.now();
4327
- const timestampStr = timestamp.toString();
4328
- if (Array.isArray(params.src)) {
4329
- throw new Error('InlinedRequest[] is not supported in Vertex AI. Please use ' +
4330
- 'Google Cloud Storage URI or BigQuery URI instead.');
4331
- }
4332
- params.config = params.config || {};
4333
- if (params.config.displayName === undefined) {
4334
- params.config.displayName = 'genaiBatchJob_${timestampStr}';
4335
- }
4336
- if (params.config.dest === undefined && typeof params.src === 'string') {
4337
- if (params.src.startsWith('gs://') && params.src.endsWith('.jsonl')) {
4338
- params.config.dest = `${params.src.slice(0, -6)}/dest`;
4339
- }
4340
- else if (params.src.startsWith('bq://')) {
4341
- params.config.dest =
4342
- `${params.src}_dest_${timestampStr}`;
4343
- }
4344
- else {
4345
- throw new Error('Unsupported source:' + params.src);
4346
- }
4347
- }
4550
+ // Format destination if not provided
4551
+ // Cast params.src as Vertex AI path does not handle InlinedRequest[]
4552
+ params.config = this.formatDestination(params.src, params.config);
4553
+ return this.createInternal(params);
4348
4554
  }
4349
- else {
4350
- if (Array.isArray(params.src) ||
4351
- (typeof params.src !== 'string' && params.src.inlinedRequests)) {
4352
- // Move system instruction to httpOptions extraBody.
4353
- let path = '';
4354
- let queryParams = {};
4355
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4356
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4357
- queryParams = body['_query'];
4358
- // Move system instruction to 'request':
4359
- // {'systemInstruction': system_instruction}
4360
- const batch = body['batch'];
4361
- const inputConfig = batch['inputConfig'];
4362
- const requestsWrapper = inputConfig['requests'];
4363
- const requests = requestsWrapper['requests'];
4364
- const newRequests = [];
4365
- for (const request of requests) {
4366
- const requestDict = request;
4367
- if (requestDict['systemInstruction']) {
4368
- const systemInstructionValue = requestDict['systemInstruction'];
4369
- delete requestDict['systemInstruction'];
4370
- const requestContent = requestDict['request'];
4371
- requestContent['systemInstruction'] = systemInstructionValue;
4372
- requestDict['request'] = requestContent;
4373
- }
4374
- newRequests.push(requestDict);
4375
- }
4376
- requestsWrapper['requests'] = newRequests;
4377
- delete body['config'];
4378
- delete body['_url'];
4379
- delete body['_query'];
4380
- const response = this.apiClient
4381
- .request({
4382
- path: path,
4383
- queryParams: queryParams,
4384
- body: JSON.stringify(body),
4385
- httpMethod: 'POST',
4386
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4387
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4388
- })
4389
- .then((httpResponse) => {
4390
- return httpResponse.json();
4391
- });
4392
- return response.then((apiResponse) => {
4393
- const resp = batchJobFromMldev(apiResponse);
4394
- return resp;
4395
- });
4396
- }
4555
+ // MLDEV
4556
+ const src = params.src;
4557
+ const is_inlined = Array.isArray(params.src) || src.inlinedRequests !== undefined;
4558
+ if (!is_inlined) {
4559
+ return this.createInternal(params);
4397
4560
  }
4398
- return await this.createInternal(params);
4561
+ // Inlined generate content requests handling
4562
+ const result = this.createInlinedGenerateContentRequest(params);
4563
+ const path = result.path;
4564
+ const requestBody = result.body;
4565
+ const queryParams = createBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4566
+ const response = this.apiClient
4567
+ .request({
4568
+ path: path,
4569
+ queryParams: queryParams,
4570
+ body: JSON.stringify(requestBody),
4571
+ httpMethod: 'POST',
4572
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4573
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4574
+ })
4575
+ .then((httpResponse) => {
4576
+ return httpResponse.json();
4577
+ });
4578
+ return response.then((apiResponse) => {
4579
+ const resp = batchJobFromMldev(apiResponse);
4580
+ return resp;
4581
+ });
4582
+ };
4583
+ /**
4584
+ * **Experimental** Creates an embedding batch job.
4585
+ *
4586
+ * @param params - The parameters for create embedding batch job request.
4587
+ * @return The created batch job.
4588
+ *
4589
+ * @example
4590
+ * ```ts
4591
+ * const response = await ai.batches.createEmbeddings({
4592
+ * model: 'text-embedding-004',
4593
+ * src: {fileName: 'files/my_embedding_input'},
4594
+ * });
4595
+ * console.log(response);
4596
+ * ```
4597
+ */
4598
+ this.createEmbeddings = async (params) => {
4599
+ var _a, _b;
4600
+ console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4601
+ if (this.apiClient.isVertexAI()) {
4602
+ throw new Error('Vertex AI does not support batches.createEmbeddings.');
4603
+ }
4604
+ // MLDEV
4605
+ const src = params.src;
4606
+ const is_inlined = src.inlinedRequests !== undefined;
4607
+ if (!is_inlined) {
4608
+ return this.createEmbeddingsInternal(params); // Fixed typo here
4609
+ }
4610
+ // Inlined embed content requests handling
4611
+ const result = this.createInlinedEmbedContentRequest(params);
4612
+ const path = result.path;
4613
+ const requestBody = result.body;
4614
+ const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4615
+ const response = this.apiClient
4616
+ .request({
4617
+ path: path,
4618
+ queryParams: queryParams,
4619
+ body: JSON.stringify(requestBody),
4620
+ httpMethod: 'POST',
4621
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4622
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4623
+ })
4624
+ .then((httpResponse) => {
4625
+ return httpResponse.json();
4626
+ });
4627
+ return response.then((apiResponse) => {
4628
+ const resp = batchJobFromMldev(apiResponse);
4629
+ return resp;
4630
+ });
4399
4631
  };
4400
4632
  /**
4401
4633
  * Lists batch job configurations.
@@ -4415,6 +4647,112 @@ class Batches extends BaseModule {
4415
4647
  return new Pager(PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4416
4648
  };
4417
4649
  }
4650
+ // Helper function to handle inlined generate content requests
4651
+ createInlinedGenerateContentRequest(params) {
4652
+ const body = createBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4653
+ params);
4654
+ const urlParams = body['_url'];
4655
+ const path = formatMap('{model}:batchGenerateContent', urlParams);
4656
+ const batch = body['batch'];
4657
+ const inputConfig = batch['inputConfig'];
4658
+ const requestsWrapper = inputConfig['requests'];
4659
+ const requests = requestsWrapper['requests'];
4660
+ const newRequests = [];
4661
+ for (const request of requests) {
4662
+ const requestDict = Object.assign({}, request); // Clone
4663
+ if (requestDict['systemInstruction']) {
4664
+ const systemInstructionValue = requestDict['systemInstruction'];
4665
+ delete requestDict['systemInstruction'];
4666
+ const requestContent = requestDict['request'];
4667
+ requestContent['systemInstruction'] = systemInstructionValue;
4668
+ requestDict['request'] = requestContent;
4669
+ }
4670
+ newRequests.push(requestDict);
4671
+ }
4672
+ requestsWrapper['requests'] = newRequests;
4673
+ delete body['config'];
4674
+ delete body['_url'];
4675
+ delete body['_query'];
4676
+ return { path, body };
4677
+ }
4678
+ // Helper function to handle inlined embedding requests
4679
+ createInlinedEmbedContentRequest(params) {
4680
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4681
+ params);
4682
+ const urlParams = body['_url'];
4683
+ const path = formatMap('{model}:asyncBatchEmbedContent', urlParams);
4684
+ const batch = body['batch'];
4685
+ const inputConfig = batch['inputConfig'];
4686
+ const requestsWrapper = inputConfig['requests'];
4687
+ const requests = requestsWrapper['requests'];
4688
+ const newRequests = [];
4689
+ delete requestsWrapper['config']; // Remove top-level config
4690
+ for (const request of requests) {
4691
+ const requestDict = Object.assign({}, request); // Clone
4692
+ const innerRequest = requestDict['request'];
4693
+ for (const key in requestDict) {
4694
+ if (key !== 'request') {
4695
+ innerRequest[key] = requestDict[key];
4696
+ delete requestDict[key];
4697
+ }
4698
+ }
4699
+ newRequests.push(requestDict);
4700
+ }
4701
+ requestsWrapper['requests'] = newRequests;
4702
+ delete body['config'];
4703
+ delete body['_url'];
4704
+ delete body['_query'];
4705
+ return { path, body };
4706
+ }
4707
+ // Helper function to get the first GCS URI
4708
+ getGcsUri(src) {
4709
+ if (typeof src === 'string') {
4710
+ return src.startsWith('gs://') ? src : undefined;
4711
+ }
4712
+ if (!Array.isArray(src) && src.gcsUri && src.gcsUri.length > 0) {
4713
+ return src.gcsUri[0];
4714
+ }
4715
+ return undefined;
4716
+ }
4717
+ // Helper function to get the BigQuery URI
4718
+ getBigqueryUri(src) {
4719
+ if (typeof src === 'string') {
4720
+ return src.startsWith('bq://') ? src : undefined;
4721
+ }
4722
+ if (!Array.isArray(src)) {
4723
+ return src.bigqueryUri;
4724
+ }
4725
+ return undefined;
4726
+ }
4727
+ // Function to format the destination configuration for Vertex AI
4728
+ formatDestination(src, config) {
4729
+ const newConfig = config ? Object.assign({}, config) : {};
4730
+ const timestampStr = Date.now().toString();
4731
+ if (!newConfig.displayName) {
4732
+ newConfig.displayName = `genaiBatchJob_${timestampStr}`;
4733
+ }
4734
+ if (newConfig.dest === undefined) {
4735
+ const gcsUri = this.getGcsUri(src);
4736
+ const bigqueryUri = this.getBigqueryUri(src);
4737
+ if (gcsUri) {
4738
+ if (gcsUri.endsWith('.jsonl')) {
4739
+ // For .jsonl files, remove suffix and add /dest
4740
+ newConfig.dest = `${gcsUri.slice(0, -6)}/dest`;
4741
+ }
4742
+ else {
4743
+ // Fallback for other GCS URIs
4744
+ newConfig.dest = `${gcsUri}_dest_${timestampStr}`;
4745
+ }
4746
+ }
4747
+ else if (bigqueryUri) {
4748
+ newConfig.dest = `${bigqueryUri}_dest_${timestampStr}`;
4749
+ }
4750
+ else {
4751
+ throw new Error('Unsupported source for Vertex AI: No GCS or BigQuery URI found.');
4752
+ }
4753
+ }
4754
+ return newConfig;
4755
+ }
4418
4756
  /**
4419
4757
  * Internal method to create batch job.
4420
4758
  *
@@ -4452,8 +4790,48 @@ class Batches extends BaseModule {
4452
4790
  });
4453
4791
  }
4454
4792
  else {
4455
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4456
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4793
+ const body = createBatchJobParametersToMldev(this.apiClient, params);
4794
+ path = formatMap('{model}:batchGenerateContent', body['_url']);
4795
+ queryParams = body['_query'];
4796
+ delete body['config'];
4797
+ delete body['_url'];
4798
+ delete body['_query'];
4799
+ response = this.apiClient
4800
+ .request({
4801
+ path: path,
4802
+ queryParams: queryParams,
4803
+ body: JSON.stringify(body),
4804
+ httpMethod: 'POST',
4805
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4806
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4807
+ })
4808
+ .then((httpResponse) => {
4809
+ return httpResponse.json();
4810
+ });
4811
+ return response.then((apiResponse) => {
4812
+ const resp = batchJobFromMldev(apiResponse);
4813
+ return resp;
4814
+ });
4815
+ }
4816
+ }
4817
+ /**
4818
+ * Internal method to create batch job.
4819
+ *
4820
+ * @param params - The parameters for create batch job request.
4821
+ * @return The created batch job.
4822
+ *
4823
+ */
4824
+ async createEmbeddingsInternal(params) {
4825
+ var _a, _b;
4826
+ let response;
4827
+ let path = '';
4828
+ let queryParams = {};
4829
+ if (this.apiClient.isVertexAI()) {
4830
+ throw new Error('This method is only supported by the Gemini Developer API.');
4831
+ }
4832
+ else {
4833
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params);
4834
+ path = formatMap('{model}:asyncBatchEmbedContent', body['_url']);
4457
4835
  queryParams = body['_query'];
4458
4836
  delete body['config'];
4459
4837
  delete body['_url'];
@@ -4464,8 +4842,8 @@ class Batches extends BaseModule {
4464
4842
  queryParams: queryParams,
4465
4843
  body: JSON.stringify(body),
4466
4844
  httpMethod: 'POST',
4467
- httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4468
- abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4845
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4846
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4469
4847
  })
4470
4848
  .then((httpResponse) => {
4471
4849
  return httpResponse.json();
@@ -4789,6 +5167,22 @@ function fileDataToMldev$3(fromObject) {
4789
5167
  }
4790
5168
  return toObject;
4791
5169
  }
5170
+ function functionCallToMldev$3(fromObject) {
5171
+ const toObject = {};
5172
+ const fromId = getValueByPath(fromObject, ['id']);
5173
+ if (fromId != null) {
5174
+ setValueByPath(toObject, ['id'], fromId);
5175
+ }
5176
+ const fromArgs = getValueByPath(fromObject, ['args']);
5177
+ if (fromArgs != null) {
5178
+ setValueByPath(toObject, ['args'], fromArgs);
5179
+ }
5180
+ const fromName = getValueByPath(fromObject, ['name']);
5181
+ if (fromName != null) {
5182
+ setValueByPath(toObject, ['name'], fromName);
5183
+ }
5184
+ return toObject;
5185
+ }
4792
5186
  function partToMldev$3(fromObject) {
4793
5187
  const toObject = {};
4794
5188
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -4815,6 +5209,10 @@ function partToMldev$3(fromObject) {
4815
5209
  if (fromThoughtSignature != null) {
4816
5210
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
4817
5211
  }
5212
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5213
+ if (fromFunctionCall != null) {
5214
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5215
+ }
4818
5216
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4819
5217
  'codeExecutionResult',
4820
5218
  ]);
@@ -4827,10 +5225,6 @@ function partToMldev$3(fromObject) {
4827
5225
  if (fromExecutableCode != null) {
4828
5226
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
4829
5227
  }
4830
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4831
- if (fromFunctionCall != null) {
4832
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4833
- }
4834
5228
  const fromFunctionResponse = getValueByPath(fromObject, [
4835
5229
  'functionResponse',
4836
5230
  ]);
@@ -5238,6 +5632,21 @@ function fileDataToVertex$2(fromObject) {
5238
5632
  }
5239
5633
  return toObject;
5240
5634
  }
5635
+ function functionCallToVertex$2(fromObject) {
5636
+ const toObject = {};
5637
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
5638
+ throw new Error('id parameter is not supported in Vertex AI.');
5639
+ }
5640
+ const fromArgs = getValueByPath(fromObject, ['args']);
5641
+ if (fromArgs != null) {
5642
+ setValueByPath(toObject, ['args'], fromArgs);
5643
+ }
5644
+ const fromName = getValueByPath(fromObject, ['name']);
5645
+ if (fromName != null) {
5646
+ setValueByPath(toObject, ['name'], fromName);
5647
+ }
5648
+ return toObject;
5649
+ }
5241
5650
  function partToVertex$2(fromObject) {
5242
5651
  const toObject = {};
5243
5652
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -5264,6 +5673,10 @@ function partToVertex$2(fromObject) {
5264
5673
  if (fromThoughtSignature != null) {
5265
5674
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
5266
5675
  }
5676
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5677
+ if (fromFunctionCall != null) {
5678
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$2(fromFunctionCall));
5679
+ }
5267
5680
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5268
5681
  'codeExecutionResult',
5269
5682
  ]);
@@ -5276,10 +5689,6 @@ function partToVertex$2(fromObject) {
5276
5689
  if (fromExecutableCode != null) {
5277
5690
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
5278
5691
  }
5279
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5280
- if (fromFunctionCall != null) {
5281
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5282
- }
5283
5692
  const fromFunctionResponse = getValueByPath(fromObject, [
5284
5693
  'functionResponse',
5285
5694
  ]);
@@ -7309,6 +7718,22 @@ function fileDataToMldev$2(fromObject) {
7309
7718
  }
7310
7719
  return toObject;
7311
7720
  }
7721
+ function functionCallToMldev$2(fromObject) {
7722
+ const toObject = {};
7723
+ const fromId = getValueByPath(fromObject, ['id']);
7724
+ if (fromId != null) {
7725
+ setValueByPath(toObject, ['id'], fromId);
7726
+ }
7727
+ const fromArgs = getValueByPath(fromObject, ['args']);
7728
+ if (fromArgs != null) {
7729
+ setValueByPath(toObject, ['args'], fromArgs);
7730
+ }
7731
+ const fromName = getValueByPath(fromObject, ['name']);
7732
+ if (fromName != null) {
7733
+ setValueByPath(toObject, ['name'], fromName);
7734
+ }
7735
+ return toObject;
7736
+ }
7312
7737
  function partToMldev$2(fromObject) {
7313
7738
  const toObject = {};
7314
7739
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -7335,6 +7760,10 @@ function partToMldev$2(fromObject) {
7335
7760
  if (fromThoughtSignature != null) {
7336
7761
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
7337
7762
  }
7763
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7764
+ if (fromFunctionCall != null) {
7765
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
7766
+ }
7338
7767
  const fromCodeExecutionResult = getValueByPath(fromObject, [
7339
7768
  'codeExecutionResult',
7340
7769
  ]);
@@ -7347,10 +7776,6 @@ function partToMldev$2(fromObject) {
7347
7776
  if (fromExecutableCode != null) {
7348
7777
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
7349
7778
  }
7350
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7351
- if (fromFunctionCall != null) {
7352
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
7353
- }
7354
7779
  const fromFunctionResponse = getValueByPath(fromObject, [
7355
7780
  'functionResponse',
7356
7781
  ]);
@@ -8013,6 +8438,21 @@ function fileDataToVertex$1(fromObject) {
8013
8438
  }
8014
8439
  return toObject;
8015
8440
  }
8441
+ function functionCallToVertex$1(fromObject) {
8442
+ const toObject = {};
8443
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
8444
+ throw new Error('id parameter is not supported in Vertex AI.');
8445
+ }
8446
+ const fromArgs = getValueByPath(fromObject, ['args']);
8447
+ if (fromArgs != null) {
8448
+ setValueByPath(toObject, ['args'], fromArgs);
8449
+ }
8450
+ const fromName = getValueByPath(fromObject, ['name']);
8451
+ if (fromName != null) {
8452
+ setValueByPath(toObject, ['name'], fromName);
8453
+ }
8454
+ return toObject;
8455
+ }
8016
8456
  function partToVertex$1(fromObject) {
8017
8457
  const toObject = {};
8018
8458
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8039,6 +8479,10 @@ function partToVertex$1(fromObject) {
8039
8479
  if (fromThoughtSignature != null) {
8040
8480
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8041
8481
  }
8482
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8483
+ if (fromFunctionCall != null) {
8484
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$1(fromFunctionCall));
8485
+ }
8042
8486
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8043
8487
  'codeExecutionResult',
8044
8488
  ]);
@@ -8051,10 +8495,6 @@ function partToVertex$1(fromObject) {
8051
8495
  if (fromExecutableCode != null) {
8052
8496
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8053
8497
  }
8054
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8055
- if (fromFunctionCall != null) {
8056
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8057
- }
8058
8498
  const fromFunctionResponse = getValueByPath(fromObject, [
8059
8499
  'functionResponse',
8060
8500
  ]);
@@ -8602,6 +9042,22 @@ function fileDataFromMldev$1(fromObject) {
8602
9042
  }
8603
9043
  return toObject;
8604
9044
  }
9045
+ function functionCallFromMldev$1(fromObject) {
9046
+ const toObject = {};
9047
+ const fromId = getValueByPath(fromObject, ['id']);
9048
+ if (fromId != null) {
9049
+ setValueByPath(toObject, ['id'], fromId);
9050
+ }
9051
+ const fromArgs = getValueByPath(fromObject, ['args']);
9052
+ if (fromArgs != null) {
9053
+ setValueByPath(toObject, ['args'], fromArgs);
9054
+ }
9055
+ const fromName = getValueByPath(fromObject, ['name']);
9056
+ if (fromName != null) {
9057
+ setValueByPath(toObject, ['name'], fromName);
9058
+ }
9059
+ return toObject;
9060
+ }
8605
9061
  function partFromMldev$1(fromObject) {
8606
9062
  const toObject = {};
8607
9063
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8628,6 +9084,10 @@ function partFromMldev$1(fromObject) {
8628
9084
  if (fromThoughtSignature != null) {
8629
9085
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8630
9086
  }
9087
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9088
+ if (fromFunctionCall != null) {
9089
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$1(fromFunctionCall));
9090
+ }
8631
9091
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8632
9092
  'codeExecutionResult',
8633
9093
  ]);
@@ -8640,10 +9100,6 @@ function partFromMldev$1(fromObject) {
8640
9100
  if (fromExecutableCode != null) {
8641
9101
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8642
9102
  }
8643
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8644
- if (fromFunctionCall != null) {
8645
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8646
- }
8647
9103
  const fromFunctionResponse = getValueByPath(fromObject, [
8648
9104
  'functionResponse',
8649
9105
  ]);
@@ -8760,22 +9216,6 @@ function liveServerContentFromMldev(fromObject) {
8760
9216
  }
8761
9217
  return toObject;
8762
9218
  }
8763
- function functionCallFromMldev(fromObject) {
8764
- const toObject = {};
8765
- const fromId = getValueByPath(fromObject, ['id']);
8766
- if (fromId != null) {
8767
- setValueByPath(toObject, ['id'], fromId);
8768
- }
8769
- const fromArgs = getValueByPath(fromObject, ['args']);
8770
- if (fromArgs != null) {
8771
- setValueByPath(toObject, ['args'], fromArgs);
8772
- }
8773
- const fromName = getValueByPath(fromObject, ['name']);
8774
- if (fromName != null) {
8775
- setValueByPath(toObject, ['name'], fromName);
8776
- }
8777
- return toObject;
8778
- }
8779
9219
  function liveServerToolCallFromMldev(fromObject) {
8780
9220
  const toObject = {};
8781
9221
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -8785,7 +9225,7 @@ function liveServerToolCallFromMldev(fromObject) {
8785
9225
  let transformedList = fromFunctionCalls;
8786
9226
  if (Array.isArray(transformedList)) {
8787
9227
  transformedList = transformedList.map((item) => {
8788
- return functionCallFromMldev(item);
9228
+ return functionCallFromMldev$1(item);
8789
9229
  });
8790
9230
  }
8791
9231
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9196,6 +9636,18 @@ function fileDataFromVertex$1(fromObject) {
9196
9636
  }
9197
9637
  return toObject;
9198
9638
  }
9639
+ function functionCallFromVertex$1(fromObject) {
9640
+ const toObject = {};
9641
+ const fromArgs = getValueByPath(fromObject, ['args']);
9642
+ if (fromArgs != null) {
9643
+ setValueByPath(toObject, ['args'], fromArgs);
9644
+ }
9645
+ const fromName = getValueByPath(fromObject, ['name']);
9646
+ if (fromName != null) {
9647
+ setValueByPath(toObject, ['name'], fromName);
9648
+ }
9649
+ return toObject;
9650
+ }
9199
9651
  function partFromVertex$1(fromObject) {
9200
9652
  const toObject = {};
9201
9653
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9222,6 +9674,10 @@ function partFromVertex$1(fromObject) {
9222
9674
  if (fromThoughtSignature != null) {
9223
9675
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9224
9676
  }
9677
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9678
+ if (fromFunctionCall != null) {
9679
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex$1(fromFunctionCall));
9680
+ }
9225
9681
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9226
9682
  'codeExecutionResult',
9227
9683
  ]);
@@ -9234,10 +9690,6 @@ function partFromVertex$1(fromObject) {
9234
9690
  if (fromExecutableCode != null) {
9235
9691
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9236
9692
  }
9237
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9238
- if (fromFunctionCall != null) {
9239
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9240
- }
9241
9693
  const fromFunctionResponse = getValueByPath(fromObject, [
9242
9694
  'functionResponse',
9243
9695
  ]);
@@ -9320,18 +9772,6 @@ function liveServerContentFromVertex(fromObject) {
9320
9772
  }
9321
9773
  return toObject;
9322
9774
  }
9323
- function functionCallFromVertex(fromObject) {
9324
- const toObject = {};
9325
- const fromArgs = getValueByPath(fromObject, ['args']);
9326
- if (fromArgs != null) {
9327
- setValueByPath(toObject, ['args'], fromArgs);
9328
- }
9329
- const fromName = getValueByPath(fromObject, ['name']);
9330
- if (fromName != null) {
9331
- setValueByPath(toObject, ['name'], fromName);
9332
- }
9333
- return toObject;
9334
- }
9335
9775
  function liveServerToolCallFromVertex(fromObject) {
9336
9776
  const toObject = {};
9337
9777
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -9341,7 +9781,7 @@ function liveServerToolCallFromVertex(fromObject) {
9341
9781
  let transformedList = fromFunctionCalls;
9342
9782
  if (Array.isArray(transformedList)) {
9343
9783
  transformedList = transformedList.map((item) => {
9344
- return functionCallFromVertex(item);
9784
+ return functionCallFromVertex$1(item);
9345
9785
  });
9346
9786
  }
9347
9787
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9580,6 +10020,22 @@ function fileDataToMldev$1(fromObject) {
9580
10020
  }
9581
10021
  return toObject;
9582
10022
  }
10023
+ function functionCallToMldev$1(fromObject) {
10024
+ const toObject = {};
10025
+ const fromId = getValueByPath(fromObject, ['id']);
10026
+ if (fromId != null) {
10027
+ setValueByPath(toObject, ['id'], fromId);
10028
+ }
10029
+ const fromArgs = getValueByPath(fromObject, ['args']);
10030
+ if (fromArgs != null) {
10031
+ setValueByPath(toObject, ['args'], fromArgs);
10032
+ }
10033
+ const fromName = getValueByPath(fromObject, ['name']);
10034
+ if (fromName != null) {
10035
+ setValueByPath(toObject, ['name'], fromName);
10036
+ }
10037
+ return toObject;
10038
+ }
9583
10039
  function partToMldev$1(fromObject) {
9584
10040
  const toObject = {};
9585
10041
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9606,6 +10062,10 @@ function partToMldev$1(fromObject) {
9606
10062
  if (fromThoughtSignature != null) {
9607
10063
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9608
10064
  }
10065
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10066
+ if (fromFunctionCall != null) {
10067
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
10068
+ }
9609
10069
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9610
10070
  'codeExecutionResult',
9611
10071
  ]);
@@ -9618,10 +10078,6 @@ function partToMldev$1(fromObject) {
9618
10078
  if (fromExecutableCode != null) {
9619
10079
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9620
10080
  }
9621
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9622
- if (fromFunctionCall != null) {
9623
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9624
- }
9625
10081
  const fromFunctionResponse = getValueByPath(fromObject, [
9626
10082
  'functionResponse',
9627
10083
  ]);
@@ -10644,6 +11100,21 @@ function fileDataToVertex(fromObject) {
10644
11100
  }
10645
11101
  return toObject;
10646
11102
  }
11103
+ function functionCallToVertex(fromObject) {
11104
+ const toObject = {};
11105
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
11106
+ throw new Error('id parameter is not supported in Vertex AI.');
11107
+ }
11108
+ const fromArgs = getValueByPath(fromObject, ['args']);
11109
+ if (fromArgs != null) {
11110
+ setValueByPath(toObject, ['args'], fromArgs);
11111
+ }
11112
+ const fromName = getValueByPath(fromObject, ['name']);
11113
+ if (fromName != null) {
11114
+ setValueByPath(toObject, ['name'], fromName);
11115
+ }
11116
+ return toObject;
11117
+ }
10647
11118
  function partToVertex(fromObject) {
10648
11119
  const toObject = {};
10649
11120
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -10670,6 +11141,10 @@ function partToVertex(fromObject) {
10670
11141
  if (fromThoughtSignature != null) {
10671
11142
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
10672
11143
  }
11144
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11145
+ if (fromFunctionCall != null) {
11146
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex(fromFunctionCall));
11147
+ }
10673
11148
  const fromCodeExecutionResult = getValueByPath(fromObject, [
10674
11149
  'codeExecutionResult',
10675
11150
  ]);
@@ -10682,10 +11157,6 @@ function partToVertex(fromObject) {
10682
11157
  if (fromExecutableCode != null) {
10683
11158
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
10684
11159
  }
10685
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10686
- if (fromFunctionCall != null) {
10687
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
10688
- }
10689
11160
  const fromFunctionResponse = getValueByPath(fromObject, [
10690
11161
  'functionResponse',
10691
11162
  ]);
@@ -12310,6 +12781,22 @@ function fileDataFromMldev(fromObject) {
12310
12781
  }
12311
12782
  return toObject;
12312
12783
  }
12784
+ function functionCallFromMldev(fromObject) {
12785
+ const toObject = {};
12786
+ const fromId = getValueByPath(fromObject, ['id']);
12787
+ if (fromId != null) {
12788
+ setValueByPath(toObject, ['id'], fromId);
12789
+ }
12790
+ const fromArgs = getValueByPath(fromObject, ['args']);
12791
+ if (fromArgs != null) {
12792
+ setValueByPath(toObject, ['args'], fromArgs);
12793
+ }
12794
+ const fromName = getValueByPath(fromObject, ['name']);
12795
+ if (fromName != null) {
12796
+ setValueByPath(toObject, ['name'], fromName);
12797
+ }
12798
+ return toObject;
12799
+ }
12313
12800
  function partFromMldev(fromObject) {
12314
12801
  const toObject = {};
12315
12802
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12336,6 +12823,10 @@ function partFromMldev(fromObject) {
12336
12823
  if (fromThoughtSignature != null) {
12337
12824
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
12338
12825
  }
12826
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12827
+ if (fromFunctionCall != null) {
12828
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev(fromFunctionCall));
12829
+ }
12339
12830
  const fromCodeExecutionResult = getValueByPath(fromObject, [
12340
12831
  'codeExecutionResult',
12341
12832
  ]);
@@ -12348,10 +12839,6 @@ function partFromMldev(fromObject) {
12348
12839
  if (fromExecutableCode != null) {
12349
12840
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
12350
12841
  }
12351
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12352
- if (fromFunctionCall != null) {
12353
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
12354
- }
12355
12842
  const fromFunctionResponse = getValueByPath(fromObject, [
12356
12843
  'functionResponse',
12357
12844
  ]);
@@ -12874,6 +13361,18 @@ function fileDataFromVertex(fromObject) {
12874
13361
  }
12875
13362
  return toObject;
12876
13363
  }
13364
+ function functionCallFromVertex(fromObject) {
13365
+ const toObject = {};
13366
+ const fromArgs = getValueByPath(fromObject, ['args']);
13367
+ if (fromArgs != null) {
13368
+ setValueByPath(toObject, ['args'], fromArgs);
13369
+ }
13370
+ const fromName = getValueByPath(fromObject, ['name']);
13371
+ if (fromName != null) {
13372
+ setValueByPath(toObject, ['name'], fromName);
13373
+ }
13374
+ return toObject;
13375
+ }
12877
13376
  function partFromVertex(fromObject) {
12878
13377
  const toObject = {};
12879
13378
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12900,6 +13399,10 @@ function partFromVertex(fromObject) {
12900
13399
  if (fromThoughtSignature != null) {
12901
13400
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
12902
13401
  }
13402
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
13403
+ if (fromFunctionCall != null) {
13404
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex(fromFunctionCall));
13405
+ }
12903
13406
  const fromCodeExecutionResult = getValueByPath(fromObject, [
12904
13407
  'codeExecutionResult',
12905
13408
  ]);
@@ -12912,10 +13415,6 @@ function partFromVertex(fromObject) {
12912
13415
  if (fromExecutableCode != null) {
12913
13416
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
12914
13417
  }
12915
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12916
- if (fromFunctionCall != null) {
12917
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
12918
- }
12919
13418
  const fromFunctionResponse = getValueByPath(fromObject, [
12920
13419
  'functionResponse',
12921
13420
  ]);
@@ -13590,7 +14089,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13590
14089
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13591
14090
  const USER_AGENT_HEADER = 'User-Agent';
13592
14091
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13593
- const SDK_VERSION = '1.17.0'; // x-release-please-version
14092
+ const SDK_VERSION = '1.18.0'; // x-release-please-version
13594
14093
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13595
14094
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13596
14095
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -16911,6 +17410,22 @@ function fileDataToMldev(fromObject) {
16911
17410
  }
16912
17411
  return toObject;
16913
17412
  }
17413
+ function functionCallToMldev(fromObject) {
17414
+ const toObject = {};
17415
+ const fromId = getValueByPath(fromObject, ['id']);
17416
+ if (fromId != null) {
17417
+ setValueByPath(toObject, ['id'], fromId);
17418
+ }
17419
+ const fromArgs = getValueByPath(fromObject, ['args']);
17420
+ if (fromArgs != null) {
17421
+ setValueByPath(toObject, ['args'], fromArgs);
17422
+ }
17423
+ const fromName = getValueByPath(fromObject, ['name']);
17424
+ if (fromName != null) {
17425
+ setValueByPath(toObject, ['name'], fromName);
17426
+ }
17427
+ return toObject;
17428
+ }
16914
17429
  function partToMldev(fromObject) {
16915
17430
  const toObject = {};
16916
17431
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -16937,6 +17452,10 @@ function partToMldev(fromObject) {
16937
17452
  if (fromThoughtSignature != null) {
16938
17453
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
16939
17454
  }
17455
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
17456
+ if (fromFunctionCall != null) {
17457
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
17458
+ }
16940
17459
  const fromCodeExecutionResult = getValueByPath(fromObject, [
16941
17460
  'codeExecutionResult',
16942
17461
  ]);
@@ -16949,10 +17468,6 @@ function partToMldev(fromObject) {
16949
17468
  if (fromExecutableCode != null) {
16950
17469
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
16951
17470
  }
16952
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
16953
- if (fromFunctionCall != null) {
16954
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
16955
- }
16956
17471
  const fromFunctionResponse = getValueByPath(fromObject, [
16957
17472
  'functionResponse',
16958
17473
  ]);
@@ -19228,5 +19743,5 @@ function getApiKeyFromEnv() {
19228
19743
  return envGoogleApiKey || envGeminiApiKey || undefined;
19229
19744
  }
19230
19745
 
19231
- export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationReferenceType, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
19746
+ export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationReferenceType, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
19232
19747
  //# sourceMappingURL=index.mjs.map