@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.
@@ -145,7 +145,16 @@ function setValueByPath(data, keys, value) {
145
145
  }
146
146
  }
147
147
  else {
148
- data[keyToSet] = value;
148
+ if (keyToSet === '_self' &&
149
+ typeof value === 'object' &&
150
+ value !== null &&
151
+ !Array.isArray(value)) {
152
+ const valueAsRecord = value;
153
+ Object.assign(data, valueAsRecord);
154
+ }
155
+ else {
156
+ data[keyToSet] = value;
157
+ }
149
158
  }
150
159
  }
151
160
  function getValueByPath(data, keys) {
@@ -1666,6 +1675,12 @@ class DeleteFileResponse {
1666
1675
  /** Config for `inlined_responses` parameter. */
1667
1676
  class InlinedResponse {
1668
1677
  }
1678
+ /** Config for `response` parameter. */
1679
+ class SingleEmbedContentResponse {
1680
+ }
1681
+ /** Config for `inlined_embedding_responses` parameter. */
1682
+ class InlinedEmbedContentResponse {
1683
+ }
1669
1684
  /** Config for batches.list return value. */
1670
1685
  class ListBatchJobsResponse {
1671
1686
  }
@@ -2517,51 +2532,59 @@ function mcpToolsToGeminiTool(mcpTools, config = {}) {
2517
2532
  return { functionDeclarations: functionDeclarations };
2518
2533
  }
2519
2534
  // Transforms a source input into a BatchJobSource object with validation.
2520
- function tBatchJobSource(apiClient, src) {
2521
- if (typeof src !== 'string' && !Array.isArray(src)) {
2522
- if (apiClient && apiClient.isVertexAI()) {
2523
- if (src.gcsUri && src.bigqueryUri) {
2524
- throw new Error('Only one of `gcsUri` or `bigqueryUri` can be set.');
2535
+ function tBatchJobSource(client, src) {
2536
+ let sourceObj;
2537
+ if (typeof src === 'string') {
2538
+ if (client.isVertexAI()) {
2539
+ if (src.startsWith('gs://')) {
2540
+ sourceObj = { format: 'jsonl', gcsUri: [src] };
2541
+ }
2542
+ else if (src.startsWith('bq://')) {
2543
+ sourceObj = { format: 'bigquery', bigqueryUri: src };
2525
2544
  }
2526
- else if (!src.gcsUri && !src.bigqueryUri) {
2527
- throw new Error('One of `gcsUri` or `bigqueryUri` must be set.');
2545
+ else {
2546
+ throw new Error(`Unsupported string source for Vertex AI: ${src}`);
2528
2547
  }
2529
2548
  }
2530
2549
  else {
2531
- // Logic for non-Vertex AI client (inlined_requests, file_name)
2532
- if (src.inlinedRequests && src.fileName) {
2533
- throw new Error('Only one of `inlinedRequests` or `fileName` can be set.');
2550
+ // MLDEV
2551
+ if (src.startsWith('files/')) {
2552
+ sourceObj = { fileName: src }; // Default to fileName for string input
2534
2553
  }
2535
- else if (!src.inlinedRequests && !src.fileName) {
2536
- throw new Error('One of `inlinedRequests` or `fileName` must be set.');
2554
+ else {
2555
+ throw new Error(`Unsupported string source for Gemini API: ${src}`);
2537
2556
  }
2538
2557
  }
2539
- return src;
2540
2558
  }
2541
- // If src is an array (list in Python)
2542
2559
  else if (Array.isArray(src)) {
2543
- return { inlinedRequests: src };
2544
- }
2545
- else if (typeof src === 'string') {
2546
- if (src.startsWith('gs://')) {
2547
- return {
2548
- format: 'jsonl',
2549
- gcsUri: [src], // GCS URI is expected as an array
2550
- };
2560
+ if (client.isVertexAI()) {
2561
+ throw new Error('InlinedRequest[] is not supported in Vertex AI.');
2551
2562
  }
2552
- else if (src.startsWith('bq://')) {
2553
- return {
2554
- format: 'bigquery',
2555
- bigqueryUri: src,
2556
- };
2563
+ sourceObj = { inlinedRequests: src };
2564
+ }
2565
+ else {
2566
+ // It's already a BatchJobSource object
2567
+ sourceObj = src;
2568
+ }
2569
+ // Validation logic
2570
+ const vertexSourcesCount = [sourceObj.gcsUri, sourceObj.bigqueryUri].filter(Boolean).length;
2571
+ const mldevSourcesCount = [
2572
+ sourceObj.inlinedRequests,
2573
+ sourceObj.fileName,
2574
+ ].filter(Boolean).length;
2575
+ if (client.isVertexAI()) {
2576
+ if (mldevSourcesCount > 0 || vertexSourcesCount !== 1) {
2577
+ throw new Error('Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.');
2557
2578
  }
2558
- else if (src.startsWith('files/')) {
2559
- return {
2560
- fileName: src,
2561
- };
2579
+ }
2580
+ else {
2581
+ // MLDEV
2582
+ if (vertexSourcesCount > 0 || mldevSourcesCount !== 1) {
2583
+ throw new Error('Exactly one of `inlinedRequests`, `fileName`, ' +
2584
+ 'must be set for Gemini API.');
2562
2585
  }
2563
2586
  }
2564
- throw new Error(`Unsupported source: ${src}`);
2587
+ return sourceObj;
2565
2588
  }
2566
2589
  function tBatchJobDestination(dest) {
2567
2590
  if (typeof dest !== 'string') {
@@ -2584,6 +2607,52 @@ function tBatchJobDestination(dest) {
2584
2607
  throw new Error(`Unsupported destination: ${destString}`);
2585
2608
  }
2586
2609
  }
2610
+ function tRecvBatchJobDestination(dest) {
2611
+ // Ensure dest is a non-null object before proceeding.
2612
+ if (typeof dest !== 'object' || dest === null) {
2613
+ // If the input is not an object, it cannot be a valid BatchJobDestination
2614
+ // based on the operations performed. Return it cast, or handle as an error.
2615
+ // Casting an empty object might be a safe default.
2616
+ return {};
2617
+ }
2618
+ // Cast to Record<string, unknown> to allow string property access.
2619
+ const obj = dest;
2620
+ // Safely access nested properties.
2621
+ const inlineResponsesVal = obj['inlinedResponses'];
2622
+ if (typeof inlineResponsesVal !== 'object' || inlineResponsesVal === null) {
2623
+ return dest;
2624
+ }
2625
+ const inlineResponsesObj = inlineResponsesVal;
2626
+ const responsesArray = inlineResponsesObj['inlinedResponses'];
2627
+ if (!Array.isArray(responsesArray) || responsesArray.length === 0) {
2628
+ return dest;
2629
+ }
2630
+ // Check if any response has the 'embedding' property.
2631
+ let hasEmbedding = false;
2632
+ for (const responseItem of responsesArray) {
2633
+ if (typeof responseItem !== 'object' || responseItem === null) {
2634
+ continue;
2635
+ }
2636
+ const responseItemObj = responseItem;
2637
+ const responseVal = responseItemObj['response'];
2638
+ if (typeof responseVal !== 'object' || responseVal === null) {
2639
+ continue;
2640
+ }
2641
+ const responseObj = responseVal;
2642
+ // Check for the existence of the 'embedding' key.
2643
+ if (responseObj['embedding'] !== undefined) {
2644
+ hasEmbedding = true;
2645
+ break;
2646
+ }
2647
+ }
2648
+ // Perform the transformation if an embedding was found.
2649
+ if (hasEmbedding) {
2650
+ obj['inlinedEmbedContentResponses'] = obj['inlinedResponses'];
2651
+ delete obj['inlinedResponses'];
2652
+ }
2653
+ // Cast the (potentially) modified object to the target type.
2654
+ return dest;
2655
+ }
2587
2656
  function tBatchJobName(apiClient, name) {
2588
2657
  const nameString = name;
2589
2658
  if (!apiClient.isVertexAI()) {
@@ -2679,6 +2748,22 @@ function fileDataToMldev$4(fromObject) {
2679
2748
  }
2680
2749
  return toObject;
2681
2750
  }
2751
+ function functionCallToMldev$4(fromObject) {
2752
+ const toObject = {};
2753
+ const fromId = getValueByPath(fromObject, ['id']);
2754
+ if (fromId != null) {
2755
+ setValueByPath(toObject, ['id'], fromId);
2756
+ }
2757
+ const fromArgs = getValueByPath(fromObject, ['args']);
2758
+ if (fromArgs != null) {
2759
+ setValueByPath(toObject, ['args'], fromArgs);
2760
+ }
2761
+ const fromName = getValueByPath(fromObject, ['name']);
2762
+ if (fromName != null) {
2763
+ setValueByPath(toObject, ['name'], fromName);
2764
+ }
2765
+ return toObject;
2766
+ }
2682
2767
  function partToMldev$4(fromObject) {
2683
2768
  const toObject = {};
2684
2769
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -2705,6 +2790,10 @@ function partToMldev$4(fromObject) {
2705
2790
  if (fromThoughtSignature != null) {
2706
2791
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
2707
2792
  }
2793
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2794
+ if (fromFunctionCall != null) {
2795
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
2796
+ }
2708
2797
  const fromCodeExecutionResult = getValueByPath(fromObject, [
2709
2798
  'codeExecutionResult',
2710
2799
  ]);
@@ -2717,10 +2806,6 @@ function partToMldev$4(fromObject) {
2717
2806
  if (fromExecutableCode != null) {
2718
2807
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
2719
2808
  }
2720
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2721
- if (fromFunctionCall != null) {
2722
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
2723
- }
2724
2809
  const fromFunctionResponse = getValueByPath(fromObject, [
2725
2810
  'functionResponse',
2726
2811
  ]);
@@ -3372,6 +3457,80 @@ function createBatchJobParametersToMldev(apiClient, fromObject) {
3372
3457
  }
3373
3458
  return toObject;
3374
3459
  }
3460
+ function embedContentConfigToMldev$1(fromObject, parentObject) {
3461
+ const toObject = {};
3462
+ const fromTaskType = getValueByPath(fromObject, ['taskType']);
3463
+ if (parentObject !== undefined && fromTaskType != null) {
3464
+ setValueByPath(parentObject, ['requests[]', 'taskType'], fromTaskType);
3465
+ }
3466
+ const fromTitle = getValueByPath(fromObject, ['title']);
3467
+ if (parentObject !== undefined && fromTitle != null) {
3468
+ setValueByPath(parentObject, ['requests[]', 'title'], fromTitle);
3469
+ }
3470
+ const fromOutputDimensionality = getValueByPath(fromObject, [
3471
+ 'outputDimensionality',
3472
+ ]);
3473
+ if (parentObject !== undefined && fromOutputDimensionality != null) {
3474
+ setValueByPath(parentObject, ['requests[]', 'outputDimensionality'], fromOutputDimensionality);
3475
+ }
3476
+ if (getValueByPath(fromObject, ['mimeType']) !== undefined) {
3477
+ throw new Error('mimeType parameter is not supported in Gemini API.');
3478
+ }
3479
+ if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
3480
+ throw new Error('autoTruncate parameter is not supported in Gemini API.');
3481
+ }
3482
+ return toObject;
3483
+ }
3484
+ function embedContentBatchToMldev(apiClient, fromObject) {
3485
+ const toObject = {};
3486
+ const fromContents = getValueByPath(fromObject, ['contents']);
3487
+ if (fromContents != null) {
3488
+ setValueByPath(toObject, ['requests[]', 'request', 'content'], tContentsForEmbed(apiClient, fromContents));
3489
+ }
3490
+ const fromConfig = getValueByPath(fromObject, ['config']);
3491
+ if (fromConfig != null) {
3492
+ setValueByPath(toObject, ['config'], embedContentConfigToMldev$1(fromConfig, toObject));
3493
+ }
3494
+ return toObject;
3495
+ }
3496
+ function embeddingsBatchJobSourceToMldev(apiClient, fromObject) {
3497
+ const toObject = {};
3498
+ const fromFileName = getValueByPath(fromObject, ['fileName']);
3499
+ if (fromFileName != null) {
3500
+ setValueByPath(toObject, ['file_name'], fromFileName);
3501
+ }
3502
+ const fromInlinedRequests = getValueByPath(fromObject, [
3503
+ 'inlinedRequests',
3504
+ ]);
3505
+ if (fromInlinedRequests != null) {
3506
+ setValueByPath(toObject, ['requests'], embedContentBatchToMldev(apiClient, fromInlinedRequests));
3507
+ }
3508
+ return toObject;
3509
+ }
3510
+ function createEmbeddingsBatchJobConfigToMldev(fromObject, parentObject) {
3511
+ const toObject = {};
3512
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3513
+ if (parentObject !== undefined && fromDisplayName != null) {
3514
+ setValueByPath(parentObject, ['batch', 'displayName'], fromDisplayName);
3515
+ }
3516
+ return toObject;
3517
+ }
3518
+ function createEmbeddingsBatchJobParametersToMldev(apiClient, fromObject) {
3519
+ const toObject = {};
3520
+ const fromModel = getValueByPath(fromObject, ['model']);
3521
+ if (fromModel != null) {
3522
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3523
+ }
3524
+ const fromSrc = getValueByPath(fromObject, ['src']);
3525
+ if (fromSrc != null) {
3526
+ setValueByPath(toObject, ['batch', 'inputConfig'], embeddingsBatchJobSourceToMldev(apiClient, fromSrc));
3527
+ }
3528
+ const fromConfig = getValueByPath(fromObject, ['config']);
3529
+ if (fromConfig != null) {
3530
+ setValueByPath(toObject, ['config'], createEmbeddingsBatchJobConfigToMldev(fromConfig, toObject));
3531
+ }
3532
+ return toObject;
3533
+ }
3375
3534
  function getBatchJobParametersToMldev(apiClient, fromObject) {
3376
3535
  const toObject = {};
3377
3536
  const fromName = getValueByPath(fromObject, ['name']);
@@ -3473,6 +3632,10 @@ function batchJobDestinationToVertex(fromObject) {
3473
3632
  if (getValueByPath(fromObject, ['inlinedResponses']) !== undefined) {
3474
3633
  throw new Error('inlinedResponses parameter is not supported in Vertex AI.');
3475
3634
  }
3635
+ if (getValueByPath(fromObject, ['inlinedEmbedContentResponses']) !==
3636
+ undefined) {
3637
+ throw new Error('inlinedEmbedContentResponses parameter is not supported in Vertex AI.');
3638
+ }
3476
3639
  return toObject;
3477
3640
  }
3478
3641
  function createBatchJobConfigToVertex(fromObject, parentObject) {
@@ -3603,6 +3766,22 @@ function fileDataFromMldev$2(fromObject) {
3603
3766
  }
3604
3767
  return toObject;
3605
3768
  }
3769
+ function functionCallFromMldev$2(fromObject) {
3770
+ const toObject = {};
3771
+ const fromId = getValueByPath(fromObject, ['id']);
3772
+ if (fromId != null) {
3773
+ setValueByPath(toObject, ['id'], fromId);
3774
+ }
3775
+ const fromArgs = getValueByPath(fromObject, ['args']);
3776
+ if (fromArgs != null) {
3777
+ setValueByPath(toObject, ['args'], fromArgs);
3778
+ }
3779
+ const fromName = getValueByPath(fromObject, ['name']);
3780
+ if (fromName != null) {
3781
+ setValueByPath(toObject, ['name'], fromName);
3782
+ }
3783
+ return toObject;
3784
+ }
3606
3785
  function partFromMldev$2(fromObject) {
3607
3786
  const toObject = {};
3608
3787
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -3629,6 +3808,10 @@ function partFromMldev$2(fromObject) {
3629
3808
  if (fromThoughtSignature != null) {
3630
3809
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
3631
3810
  }
3811
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3812
+ if (fromFunctionCall != null) {
3813
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$2(fromFunctionCall));
3814
+ }
3632
3815
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3633
3816
  'codeExecutionResult',
3634
3817
  ]);
@@ -3641,10 +3824,6 @@ function partFromMldev$2(fromObject) {
3641
3824
  if (fromExecutableCode != null) {
3642
3825
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
3643
3826
  }
3644
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3645
- if (fromFunctionCall != null) {
3646
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
3647
- }
3648
3827
  const fromFunctionResponse = getValueByPath(fromObject, [
3649
3828
  'functionResponse',
3650
3829
  ]);
@@ -3833,6 +4012,38 @@ function inlinedResponseFromMldev(fromObject) {
3833
4012
  }
3834
4013
  return toObject;
3835
4014
  }
4015
+ function contentEmbeddingFromMldev$1(fromObject) {
4016
+ const toObject = {};
4017
+ const fromValues = getValueByPath(fromObject, ['values']);
4018
+ if (fromValues != null) {
4019
+ setValueByPath(toObject, ['values'], fromValues);
4020
+ }
4021
+ return toObject;
4022
+ }
4023
+ function singleEmbedContentResponseFromMldev(fromObject) {
4024
+ const toObject = {};
4025
+ const fromEmbedding = getValueByPath(fromObject, ['embedding']);
4026
+ if (fromEmbedding != null) {
4027
+ setValueByPath(toObject, ['embedding'], contentEmbeddingFromMldev$1(fromEmbedding));
4028
+ }
4029
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
4030
+ if (fromTokenCount != null) {
4031
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
4032
+ }
4033
+ return toObject;
4034
+ }
4035
+ function inlinedEmbedContentResponseFromMldev(fromObject) {
4036
+ const toObject = {};
4037
+ const fromResponse = getValueByPath(fromObject, ['response']);
4038
+ if (fromResponse != null) {
4039
+ setValueByPath(toObject, ['response'], singleEmbedContentResponseFromMldev(fromResponse));
4040
+ }
4041
+ const fromError = getValueByPath(fromObject, ['error']);
4042
+ if (fromError != null) {
4043
+ setValueByPath(toObject, ['error'], jobErrorFromMldev(fromError));
4044
+ }
4045
+ return toObject;
4046
+ }
3836
4047
  function batchJobDestinationFromMldev(fromObject) {
3837
4048
  const toObject = {};
3838
4049
  const fromFileName = getValueByPath(fromObject, ['responsesFile']);
@@ -3852,6 +4063,19 @@ function batchJobDestinationFromMldev(fromObject) {
3852
4063
  }
3853
4064
  setValueByPath(toObject, ['inlinedResponses'], transformedList);
3854
4065
  }
4066
+ const fromInlinedEmbedContentResponses = getValueByPath(fromObject, [
4067
+ 'inlinedEmbedContentResponses',
4068
+ 'inlinedResponses',
4069
+ ]);
4070
+ if (fromInlinedEmbedContentResponses != null) {
4071
+ let transformedList = fromInlinedEmbedContentResponses;
4072
+ if (Array.isArray(transformedList)) {
4073
+ transformedList = transformedList.map((item) => {
4074
+ return inlinedEmbedContentResponseFromMldev(item);
4075
+ });
4076
+ }
4077
+ setValueByPath(toObject, ['inlinedEmbedContentResponses'], transformedList);
4078
+ }
3855
4079
  return toObject;
3856
4080
  }
3857
4081
  function batchJobFromMldev(fromObject) {
@@ -3898,7 +4122,7 @@ function batchJobFromMldev(fromObject) {
3898
4122
  }
3899
4123
  const fromDest = getValueByPath(fromObject, ['metadata', 'output']);
3900
4124
  if (fromDest != null) {
3901
- setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(fromDest));
4125
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(tRecvBatchJobDestination(fromDest)));
3902
4126
  }
3903
4127
  return toObject;
3904
4128
  }
@@ -4051,7 +4275,7 @@ function batchJobFromVertex(fromObject) {
4051
4275
  }
4052
4276
  const fromDest = getValueByPath(fromObject, ['outputConfig']);
4053
4277
  if (fromDest != null) {
4054
- setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(fromDest));
4278
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
4055
4279
  }
4056
4280
  return toObject;
4057
4281
  }
@@ -4317,79 +4541,87 @@ class Batches extends BaseModule {
4317
4541
  this.create = async (params) => {
4318
4542
  var _a, _b;
4319
4543
  if (this.apiClient.isVertexAI()) {
4320
- const timestamp = Date.now();
4321
- const timestampStr = timestamp.toString();
4322
- if (Array.isArray(params.src)) {
4323
- throw new Error('InlinedRequest[] is not supported in Vertex AI. Please use ' +
4324
- 'Google Cloud Storage URI or BigQuery URI instead.');
4325
- }
4326
- params.config = params.config || {};
4327
- if (params.config.displayName === undefined) {
4328
- params.config.displayName = 'genaiBatchJob_${timestampStr}';
4329
- }
4330
- if (params.config.dest === undefined && typeof params.src === 'string') {
4331
- if (params.src.startsWith('gs://') && params.src.endsWith('.jsonl')) {
4332
- params.config.dest = `${params.src.slice(0, -6)}/dest`;
4333
- }
4334
- else if (params.src.startsWith('bq://')) {
4335
- params.config.dest =
4336
- `${params.src}_dest_${timestampStr}`;
4337
- }
4338
- else {
4339
- throw new Error('Unsupported source:' + params.src);
4340
- }
4341
- }
4544
+ // Format destination if not provided
4545
+ // Cast params.src as Vertex AI path does not handle InlinedRequest[]
4546
+ params.config = this.formatDestination(params.src, params.config);
4547
+ return this.createInternal(params);
4342
4548
  }
4343
- else {
4344
- if (Array.isArray(params.src) ||
4345
- (typeof params.src !== 'string' && params.src.inlinedRequests)) {
4346
- // Move system instruction to httpOptions extraBody.
4347
- let path = '';
4348
- let queryParams = {};
4349
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4350
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4351
- queryParams = body['_query'];
4352
- // Move system instruction to 'request':
4353
- // {'systemInstruction': system_instruction}
4354
- const batch = body['batch'];
4355
- const inputConfig = batch['inputConfig'];
4356
- const requestsWrapper = inputConfig['requests'];
4357
- const requests = requestsWrapper['requests'];
4358
- const newRequests = [];
4359
- for (const request of requests) {
4360
- const requestDict = request;
4361
- if (requestDict['systemInstruction']) {
4362
- const systemInstructionValue = requestDict['systemInstruction'];
4363
- delete requestDict['systemInstruction'];
4364
- const requestContent = requestDict['request'];
4365
- requestContent['systemInstruction'] = systemInstructionValue;
4366
- requestDict['request'] = requestContent;
4367
- }
4368
- newRequests.push(requestDict);
4369
- }
4370
- requestsWrapper['requests'] = newRequests;
4371
- delete body['config'];
4372
- delete body['_url'];
4373
- delete body['_query'];
4374
- const response = this.apiClient
4375
- .request({
4376
- path: path,
4377
- queryParams: queryParams,
4378
- body: JSON.stringify(body),
4379
- httpMethod: 'POST',
4380
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4381
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4382
- })
4383
- .then((httpResponse) => {
4384
- return httpResponse.json();
4385
- });
4386
- return response.then((apiResponse) => {
4387
- const resp = batchJobFromMldev(apiResponse);
4388
- return resp;
4389
- });
4390
- }
4549
+ // MLDEV
4550
+ const src = params.src;
4551
+ const is_inlined = Array.isArray(params.src) || src.inlinedRequests !== undefined;
4552
+ if (!is_inlined) {
4553
+ return this.createInternal(params);
4391
4554
  }
4392
- return await this.createInternal(params);
4555
+ // Inlined generate content requests handling
4556
+ const result = this.createInlinedGenerateContentRequest(params);
4557
+ const path = result.path;
4558
+ const requestBody = result.body;
4559
+ const queryParams = createBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4560
+ const response = this.apiClient
4561
+ .request({
4562
+ path: path,
4563
+ queryParams: queryParams,
4564
+ body: JSON.stringify(requestBody),
4565
+ httpMethod: 'POST',
4566
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4567
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4568
+ })
4569
+ .then((httpResponse) => {
4570
+ return httpResponse.json();
4571
+ });
4572
+ return response.then((apiResponse) => {
4573
+ const resp = batchJobFromMldev(apiResponse);
4574
+ return resp;
4575
+ });
4576
+ };
4577
+ /**
4578
+ * **Experimental** Creates an embedding batch job.
4579
+ *
4580
+ * @param params - The parameters for create embedding batch job request.
4581
+ * @return The created batch job.
4582
+ *
4583
+ * @example
4584
+ * ```ts
4585
+ * const response = await ai.batches.createEmbeddings({
4586
+ * model: 'text-embedding-004',
4587
+ * src: {fileName: 'files/my_embedding_input'},
4588
+ * });
4589
+ * console.log(response);
4590
+ * ```
4591
+ */
4592
+ this.createEmbeddings = async (params) => {
4593
+ var _a, _b;
4594
+ console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4595
+ if (this.apiClient.isVertexAI()) {
4596
+ throw new Error('Vertex AI does not support batches.createEmbeddings.');
4597
+ }
4598
+ // MLDEV
4599
+ const src = params.src;
4600
+ const is_inlined = src.inlinedRequests !== undefined;
4601
+ if (!is_inlined) {
4602
+ return this.createEmbeddingsInternal(params); // Fixed typo here
4603
+ }
4604
+ // Inlined embed content requests handling
4605
+ const result = this.createInlinedEmbedContentRequest(params);
4606
+ const path = result.path;
4607
+ const requestBody = result.body;
4608
+ const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4609
+ const response = this.apiClient
4610
+ .request({
4611
+ path: path,
4612
+ queryParams: queryParams,
4613
+ body: JSON.stringify(requestBody),
4614
+ httpMethod: 'POST',
4615
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4616
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4617
+ })
4618
+ .then((httpResponse) => {
4619
+ return httpResponse.json();
4620
+ });
4621
+ return response.then((apiResponse) => {
4622
+ const resp = batchJobFromMldev(apiResponse);
4623
+ return resp;
4624
+ });
4393
4625
  };
4394
4626
  /**
4395
4627
  * Lists batch job configurations.
@@ -4409,6 +4641,112 @@ class Batches extends BaseModule {
4409
4641
  return new Pager(PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4410
4642
  };
4411
4643
  }
4644
+ // Helper function to handle inlined generate content requests
4645
+ createInlinedGenerateContentRequest(params) {
4646
+ const body = createBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4647
+ params);
4648
+ const urlParams = body['_url'];
4649
+ const path = formatMap('{model}:batchGenerateContent', urlParams);
4650
+ const batch = body['batch'];
4651
+ const inputConfig = batch['inputConfig'];
4652
+ const requestsWrapper = inputConfig['requests'];
4653
+ const requests = requestsWrapper['requests'];
4654
+ const newRequests = [];
4655
+ for (const request of requests) {
4656
+ const requestDict = Object.assign({}, request); // Clone
4657
+ if (requestDict['systemInstruction']) {
4658
+ const systemInstructionValue = requestDict['systemInstruction'];
4659
+ delete requestDict['systemInstruction'];
4660
+ const requestContent = requestDict['request'];
4661
+ requestContent['systemInstruction'] = systemInstructionValue;
4662
+ requestDict['request'] = requestContent;
4663
+ }
4664
+ newRequests.push(requestDict);
4665
+ }
4666
+ requestsWrapper['requests'] = newRequests;
4667
+ delete body['config'];
4668
+ delete body['_url'];
4669
+ delete body['_query'];
4670
+ return { path, body };
4671
+ }
4672
+ // Helper function to handle inlined embedding requests
4673
+ createInlinedEmbedContentRequest(params) {
4674
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4675
+ params);
4676
+ const urlParams = body['_url'];
4677
+ const path = formatMap('{model}:asyncBatchEmbedContent', 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
+ delete requestsWrapper['config']; // Remove top-level config
4684
+ for (const request of requests) {
4685
+ const requestDict = Object.assign({}, request); // Clone
4686
+ const innerRequest = requestDict['request'];
4687
+ for (const key in requestDict) {
4688
+ if (key !== 'request') {
4689
+ innerRequest[key] = requestDict[key];
4690
+ delete requestDict[key];
4691
+ }
4692
+ }
4693
+ newRequests.push(requestDict);
4694
+ }
4695
+ requestsWrapper['requests'] = newRequests;
4696
+ delete body['config'];
4697
+ delete body['_url'];
4698
+ delete body['_query'];
4699
+ return { path, body };
4700
+ }
4701
+ // Helper function to get the first GCS URI
4702
+ getGcsUri(src) {
4703
+ if (typeof src === 'string') {
4704
+ return src.startsWith('gs://') ? src : undefined;
4705
+ }
4706
+ if (!Array.isArray(src) && src.gcsUri && src.gcsUri.length > 0) {
4707
+ return src.gcsUri[0];
4708
+ }
4709
+ return undefined;
4710
+ }
4711
+ // Helper function to get the BigQuery URI
4712
+ getBigqueryUri(src) {
4713
+ if (typeof src === 'string') {
4714
+ return src.startsWith('bq://') ? src : undefined;
4715
+ }
4716
+ if (!Array.isArray(src)) {
4717
+ return src.bigqueryUri;
4718
+ }
4719
+ return undefined;
4720
+ }
4721
+ // Function to format the destination configuration for Vertex AI
4722
+ formatDestination(src, config) {
4723
+ const newConfig = config ? Object.assign({}, config) : {};
4724
+ const timestampStr = Date.now().toString();
4725
+ if (!newConfig.displayName) {
4726
+ newConfig.displayName = `genaiBatchJob_${timestampStr}`;
4727
+ }
4728
+ if (newConfig.dest === undefined) {
4729
+ const gcsUri = this.getGcsUri(src);
4730
+ const bigqueryUri = this.getBigqueryUri(src);
4731
+ if (gcsUri) {
4732
+ if (gcsUri.endsWith('.jsonl')) {
4733
+ // For .jsonl files, remove suffix and add /dest
4734
+ newConfig.dest = `${gcsUri.slice(0, -6)}/dest`;
4735
+ }
4736
+ else {
4737
+ // Fallback for other GCS URIs
4738
+ newConfig.dest = `${gcsUri}_dest_${timestampStr}`;
4739
+ }
4740
+ }
4741
+ else if (bigqueryUri) {
4742
+ newConfig.dest = `${bigqueryUri}_dest_${timestampStr}`;
4743
+ }
4744
+ else {
4745
+ throw new Error('Unsupported source for Vertex AI: No GCS or BigQuery URI found.');
4746
+ }
4747
+ }
4748
+ return newConfig;
4749
+ }
4412
4750
  /**
4413
4751
  * Internal method to create batch job.
4414
4752
  *
@@ -4446,8 +4784,48 @@ class Batches extends BaseModule {
4446
4784
  });
4447
4785
  }
4448
4786
  else {
4449
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4450
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4787
+ const body = createBatchJobParametersToMldev(this.apiClient, params);
4788
+ path = formatMap('{model}:batchGenerateContent', body['_url']);
4789
+ queryParams = body['_query'];
4790
+ delete body['config'];
4791
+ delete body['_url'];
4792
+ delete body['_query'];
4793
+ response = this.apiClient
4794
+ .request({
4795
+ path: path,
4796
+ queryParams: queryParams,
4797
+ body: JSON.stringify(body),
4798
+ httpMethod: 'POST',
4799
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4800
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4801
+ })
4802
+ .then((httpResponse) => {
4803
+ return httpResponse.json();
4804
+ });
4805
+ return response.then((apiResponse) => {
4806
+ const resp = batchJobFromMldev(apiResponse);
4807
+ return resp;
4808
+ });
4809
+ }
4810
+ }
4811
+ /**
4812
+ * Internal method to create batch job.
4813
+ *
4814
+ * @param params - The parameters for create batch job request.
4815
+ * @return The created batch job.
4816
+ *
4817
+ */
4818
+ async createEmbeddingsInternal(params) {
4819
+ var _a, _b;
4820
+ let response;
4821
+ let path = '';
4822
+ let queryParams = {};
4823
+ if (this.apiClient.isVertexAI()) {
4824
+ throw new Error('This method is only supported by the Gemini Developer API.');
4825
+ }
4826
+ else {
4827
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params);
4828
+ path = formatMap('{model}:asyncBatchEmbedContent', body['_url']);
4451
4829
  queryParams = body['_query'];
4452
4830
  delete body['config'];
4453
4831
  delete body['_url'];
@@ -4458,8 +4836,8 @@ class Batches extends BaseModule {
4458
4836
  queryParams: queryParams,
4459
4837
  body: JSON.stringify(body),
4460
4838
  httpMethod: 'POST',
4461
- httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4462
- abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4839
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4840
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4463
4841
  })
4464
4842
  .then((httpResponse) => {
4465
4843
  return httpResponse.json();
@@ -4783,6 +5161,22 @@ function fileDataToMldev$3(fromObject) {
4783
5161
  }
4784
5162
  return toObject;
4785
5163
  }
5164
+ function functionCallToMldev$3(fromObject) {
5165
+ const toObject = {};
5166
+ const fromId = getValueByPath(fromObject, ['id']);
5167
+ if (fromId != null) {
5168
+ setValueByPath(toObject, ['id'], fromId);
5169
+ }
5170
+ const fromArgs = getValueByPath(fromObject, ['args']);
5171
+ if (fromArgs != null) {
5172
+ setValueByPath(toObject, ['args'], fromArgs);
5173
+ }
5174
+ const fromName = getValueByPath(fromObject, ['name']);
5175
+ if (fromName != null) {
5176
+ setValueByPath(toObject, ['name'], fromName);
5177
+ }
5178
+ return toObject;
5179
+ }
4786
5180
  function partToMldev$3(fromObject) {
4787
5181
  const toObject = {};
4788
5182
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -4809,6 +5203,10 @@ function partToMldev$3(fromObject) {
4809
5203
  if (fromThoughtSignature != null) {
4810
5204
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
4811
5205
  }
5206
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5207
+ if (fromFunctionCall != null) {
5208
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5209
+ }
4812
5210
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4813
5211
  'codeExecutionResult',
4814
5212
  ]);
@@ -4821,10 +5219,6 @@ function partToMldev$3(fromObject) {
4821
5219
  if (fromExecutableCode != null) {
4822
5220
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
4823
5221
  }
4824
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4825
- if (fromFunctionCall != null) {
4826
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4827
- }
4828
5222
  const fromFunctionResponse = getValueByPath(fromObject, [
4829
5223
  'functionResponse',
4830
5224
  ]);
@@ -5232,6 +5626,21 @@ function fileDataToVertex$2(fromObject) {
5232
5626
  }
5233
5627
  return toObject;
5234
5628
  }
5629
+ function functionCallToVertex$2(fromObject) {
5630
+ const toObject = {};
5631
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
5632
+ throw new Error('id parameter is not supported in Vertex AI.');
5633
+ }
5634
+ const fromArgs = getValueByPath(fromObject, ['args']);
5635
+ if (fromArgs != null) {
5636
+ setValueByPath(toObject, ['args'], fromArgs);
5637
+ }
5638
+ const fromName = getValueByPath(fromObject, ['name']);
5639
+ if (fromName != null) {
5640
+ setValueByPath(toObject, ['name'], fromName);
5641
+ }
5642
+ return toObject;
5643
+ }
5235
5644
  function partToVertex$2(fromObject) {
5236
5645
  const toObject = {};
5237
5646
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -5258,6 +5667,10 @@ function partToVertex$2(fromObject) {
5258
5667
  if (fromThoughtSignature != null) {
5259
5668
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
5260
5669
  }
5670
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5671
+ if (fromFunctionCall != null) {
5672
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$2(fromFunctionCall));
5673
+ }
5261
5674
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5262
5675
  'codeExecutionResult',
5263
5676
  ]);
@@ -5270,10 +5683,6 @@ function partToVertex$2(fromObject) {
5270
5683
  if (fromExecutableCode != null) {
5271
5684
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
5272
5685
  }
5273
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5274
- if (fromFunctionCall != null) {
5275
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5276
- }
5277
5686
  const fromFunctionResponse = getValueByPath(fromObject, [
5278
5687
  'functionResponse',
5279
5688
  ]);
@@ -7303,6 +7712,22 @@ function fileDataToMldev$2(fromObject) {
7303
7712
  }
7304
7713
  return toObject;
7305
7714
  }
7715
+ function functionCallToMldev$2(fromObject) {
7716
+ const toObject = {};
7717
+ const fromId = getValueByPath(fromObject, ['id']);
7718
+ if (fromId != null) {
7719
+ setValueByPath(toObject, ['id'], fromId);
7720
+ }
7721
+ const fromArgs = getValueByPath(fromObject, ['args']);
7722
+ if (fromArgs != null) {
7723
+ setValueByPath(toObject, ['args'], fromArgs);
7724
+ }
7725
+ const fromName = getValueByPath(fromObject, ['name']);
7726
+ if (fromName != null) {
7727
+ setValueByPath(toObject, ['name'], fromName);
7728
+ }
7729
+ return toObject;
7730
+ }
7306
7731
  function partToMldev$2(fromObject) {
7307
7732
  const toObject = {};
7308
7733
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -7329,6 +7754,10 @@ function partToMldev$2(fromObject) {
7329
7754
  if (fromThoughtSignature != null) {
7330
7755
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
7331
7756
  }
7757
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7758
+ if (fromFunctionCall != null) {
7759
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
7760
+ }
7332
7761
  const fromCodeExecutionResult = getValueByPath(fromObject, [
7333
7762
  'codeExecutionResult',
7334
7763
  ]);
@@ -7341,10 +7770,6 @@ function partToMldev$2(fromObject) {
7341
7770
  if (fromExecutableCode != null) {
7342
7771
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
7343
7772
  }
7344
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
7345
- if (fromFunctionCall != null) {
7346
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
7347
- }
7348
7773
  const fromFunctionResponse = getValueByPath(fromObject, [
7349
7774
  'functionResponse',
7350
7775
  ]);
@@ -8007,6 +8432,21 @@ function fileDataToVertex$1(fromObject) {
8007
8432
  }
8008
8433
  return toObject;
8009
8434
  }
8435
+ function functionCallToVertex$1(fromObject) {
8436
+ const toObject = {};
8437
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
8438
+ throw new Error('id parameter is not supported in Vertex AI.');
8439
+ }
8440
+ const fromArgs = getValueByPath(fromObject, ['args']);
8441
+ if (fromArgs != null) {
8442
+ setValueByPath(toObject, ['args'], fromArgs);
8443
+ }
8444
+ const fromName = getValueByPath(fromObject, ['name']);
8445
+ if (fromName != null) {
8446
+ setValueByPath(toObject, ['name'], fromName);
8447
+ }
8448
+ return toObject;
8449
+ }
8010
8450
  function partToVertex$1(fromObject) {
8011
8451
  const toObject = {};
8012
8452
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8033,6 +8473,10 @@ function partToVertex$1(fromObject) {
8033
8473
  if (fromThoughtSignature != null) {
8034
8474
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8035
8475
  }
8476
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8477
+ if (fromFunctionCall != null) {
8478
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$1(fromFunctionCall));
8479
+ }
8036
8480
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8037
8481
  'codeExecutionResult',
8038
8482
  ]);
@@ -8045,10 +8489,6 @@ function partToVertex$1(fromObject) {
8045
8489
  if (fromExecutableCode != null) {
8046
8490
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8047
8491
  }
8048
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8049
- if (fromFunctionCall != null) {
8050
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8051
- }
8052
8492
  const fromFunctionResponse = getValueByPath(fromObject, [
8053
8493
  'functionResponse',
8054
8494
  ]);
@@ -8596,6 +9036,22 @@ function fileDataFromMldev$1(fromObject) {
8596
9036
  }
8597
9037
  return toObject;
8598
9038
  }
9039
+ function functionCallFromMldev$1(fromObject) {
9040
+ const toObject = {};
9041
+ const fromId = getValueByPath(fromObject, ['id']);
9042
+ if (fromId != null) {
9043
+ setValueByPath(toObject, ['id'], fromId);
9044
+ }
9045
+ const fromArgs = getValueByPath(fromObject, ['args']);
9046
+ if (fromArgs != null) {
9047
+ setValueByPath(toObject, ['args'], fromArgs);
9048
+ }
9049
+ const fromName = getValueByPath(fromObject, ['name']);
9050
+ if (fromName != null) {
9051
+ setValueByPath(toObject, ['name'], fromName);
9052
+ }
9053
+ return toObject;
9054
+ }
8599
9055
  function partFromMldev$1(fromObject) {
8600
9056
  const toObject = {};
8601
9057
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8622,6 +9078,10 @@ function partFromMldev$1(fromObject) {
8622
9078
  if (fromThoughtSignature != null) {
8623
9079
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8624
9080
  }
9081
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9082
+ if (fromFunctionCall != null) {
9083
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$1(fromFunctionCall));
9084
+ }
8625
9085
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8626
9086
  'codeExecutionResult',
8627
9087
  ]);
@@ -8634,10 +9094,6 @@ function partFromMldev$1(fromObject) {
8634
9094
  if (fromExecutableCode != null) {
8635
9095
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8636
9096
  }
8637
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8638
- if (fromFunctionCall != null) {
8639
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8640
- }
8641
9097
  const fromFunctionResponse = getValueByPath(fromObject, [
8642
9098
  'functionResponse',
8643
9099
  ]);
@@ -8754,22 +9210,6 @@ function liveServerContentFromMldev(fromObject) {
8754
9210
  }
8755
9211
  return toObject;
8756
9212
  }
8757
- function functionCallFromMldev(fromObject) {
8758
- const toObject = {};
8759
- const fromId = getValueByPath(fromObject, ['id']);
8760
- if (fromId != null) {
8761
- setValueByPath(toObject, ['id'], fromId);
8762
- }
8763
- const fromArgs = getValueByPath(fromObject, ['args']);
8764
- if (fromArgs != null) {
8765
- setValueByPath(toObject, ['args'], fromArgs);
8766
- }
8767
- const fromName = getValueByPath(fromObject, ['name']);
8768
- if (fromName != null) {
8769
- setValueByPath(toObject, ['name'], fromName);
8770
- }
8771
- return toObject;
8772
- }
8773
9213
  function liveServerToolCallFromMldev(fromObject) {
8774
9214
  const toObject = {};
8775
9215
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -8779,7 +9219,7 @@ function liveServerToolCallFromMldev(fromObject) {
8779
9219
  let transformedList = fromFunctionCalls;
8780
9220
  if (Array.isArray(transformedList)) {
8781
9221
  transformedList = transformedList.map((item) => {
8782
- return functionCallFromMldev(item);
9222
+ return functionCallFromMldev$1(item);
8783
9223
  });
8784
9224
  }
8785
9225
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9190,6 +9630,18 @@ function fileDataFromVertex$1(fromObject) {
9190
9630
  }
9191
9631
  return toObject;
9192
9632
  }
9633
+ function functionCallFromVertex$1(fromObject) {
9634
+ const toObject = {};
9635
+ const fromArgs = getValueByPath(fromObject, ['args']);
9636
+ if (fromArgs != null) {
9637
+ setValueByPath(toObject, ['args'], fromArgs);
9638
+ }
9639
+ const fromName = getValueByPath(fromObject, ['name']);
9640
+ if (fromName != null) {
9641
+ setValueByPath(toObject, ['name'], fromName);
9642
+ }
9643
+ return toObject;
9644
+ }
9193
9645
  function partFromVertex$1(fromObject) {
9194
9646
  const toObject = {};
9195
9647
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9216,6 +9668,10 @@ function partFromVertex$1(fromObject) {
9216
9668
  if (fromThoughtSignature != null) {
9217
9669
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9218
9670
  }
9671
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9672
+ if (fromFunctionCall != null) {
9673
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex$1(fromFunctionCall));
9674
+ }
9219
9675
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9220
9676
  'codeExecutionResult',
9221
9677
  ]);
@@ -9228,10 +9684,6 @@ function partFromVertex$1(fromObject) {
9228
9684
  if (fromExecutableCode != null) {
9229
9685
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9230
9686
  }
9231
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9232
- if (fromFunctionCall != null) {
9233
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9234
- }
9235
9687
  const fromFunctionResponse = getValueByPath(fromObject, [
9236
9688
  'functionResponse',
9237
9689
  ]);
@@ -9314,18 +9766,6 @@ function liveServerContentFromVertex(fromObject) {
9314
9766
  }
9315
9767
  return toObject;
9316
9768
  }
9317
- function functionCallFromVertex(fromObject) {
9318
- const toObject = {};
9319
- const fromArgs = getValueByPath(fromObject, ['args']);
9320
- if (fromArgs != null) {
9321
- setValueByPath(toObject, ['args'], fromArgs);
9322
- }
9323
- const fromName = getValueByPath(fromObject, ['name']);
9324
- if (fromName != null) {
9325
- setValueByPath(toObject, ['name'], fromName);
9326
- }
9327
- return toObject;
9328
- }
9329
9769
  function liveServerToolCallFromVertex(fromObject) {
9330
9770
  const toObject = {};
9331
9771
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -9335,7 +9775,7 @@ function liveServerToolCallFromVertex(fromObject) {
9335
9775
  let transformedList = fromFunctionCalls;
9336
9776
  if (Array.isArray(transformedList)) {
9337
9777
  transformedList = transformedList.map((item) => {
9338
- return functionCallFromVertex(item);
9778
+ return functionCallFromVertex$1(item);
9339
9779
  });
9340
9780
  }
9341
9781
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9574,6 +10014,22 @@ function fileDataToMldev$1(fromObject) {
9574
10014
  }
9575
10015
  return toObject;
9576
10016
  }
10017
+ function functionCallToMldev$1(fromObject) {
10018
+ const toObject = {};
10019
+ const fromId = getValueByPath(fromObject, ['id']);
10020
+ if (fromId != null) {
10021
+ setValueByPath(toObject, ['id'], fromId);
10022
+ }
10023
+ const fromArgs = getValueByPath(fromObject, ['args']);
10024
+ if (fromArgs != null) {
10025
+ setValueByPath(toObject, ['args'], fromArgs);
10026
+ }
10027
+ const fromName = getValueByPath(fromObject, ['name']);
10028
+ if (fromName != null) {
10029
+ setValueByPath(toObject, ['name'], fromName);
10030
+ }
10031
+ return toObject;
10032
+ }
9577
10033
  function partToMldev$1(fromObject) {
9578
10034
  const toObject = {};
9579
10035
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9600,6 +10056,10 @@ function partToMldev$1(fromObject) {
9600
10056
  if (fromThoughtSignature != null) {
9601
10057
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9602
10058
  }
10059
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10060
+ if (fromFunctionCall != null) {
10061
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
10062
+ }
9603
10063
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9604
10064
  'codeExecutionResult',
9605
10065
  ]);
@@ -9612,10 +10072,6 @@ function partToMldev$1(fromObject) {
9612
10072
  if (fromExecutableCode != null) {
9613
10073
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9614
10074
  }
9615
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9616
- if (fromFunctionCall != null) {
9617
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9618
- }
9619
10075
  const fromFunctionResponse = getValueByPath(fromObject, [
9620
10076
  'functionResponse',
9621
10077
  ]);
@@ -10638,6 +11094,21 @@ function fileDataToVertex(fromObject) {
10638
11094
  }
10639
11095
  return toObject;
10640
11096
  }
11097
+ function functionCallToVertex(fromObject) {
11098
+ const toObject = {};
11099
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
11100
+ throw new Error('id parameter is not supported in Vertex AI.');
11101
+ }
11102
+ const fromArgs = getValueByPath(fromObject, ['args']);
11103
+ if (fromArgs != null) {
11104
+ setValueByPath(toObject, ['args'], fromArgs);
11105
+ }
11106
+ const fromName = getValueByPath(fromObject, ['name']);
11107
+ if (fromName != null) {
11108
+ setValueByPath(toObject, ['name'], fromName);
11109
+ }
11110
+ return toObject;
11111
+ }
10641
11112
  function partToVertex(fromObject) {
10642
11113
  const toObject = {};
10643
11114
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -10664,6 +11135,10 @@ function partToVertex(fromObject) {
10664
11135
  if (fromThoughtSignature != null) {
10665
11136
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
10666
11137
  }
11138
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11139
+ if (fromFunctionCall != null) {
11140
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex(fromFunctionCall));
11141
+ }
10667
11142
  const fromCodeExecutionResult = getValueByPath(fromObject, [
10668
11143
  'codeExecutionResult',
10669
11144
  ]);
@@ -10676,10 +11151,6 @@ function partToVertex(fromObject) {
10676
11151
  if (fromExecutableCode != null) {
10677
11152
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
10678
11153
  }
10679
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10680
- if (fromFunctionCall != null) {
10681
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
10682
- }
10683
11154
  const fromFunctionResponse = getValueByPath(fromObject, [
10684
11155
  'functionResponse',
10685
11156
  ]);
@@ -12304,6 +12775,22 @@ function fileDataFromMldev(fromObject) {
12304
12775
  }
12305
12776
  return toObject;
12306
12777
  }
12778
+ function functionCallFromMldev(fromObject) {
12779
+ const toObject = {};
12780
+ const fromId = getValueByPath(fromObject, ['id']);
12781
+ if (fromId != null) {
12782
+ setValueByPath(toObject, ['id'], fromId);
12783
+ }
12784
+ const fromArgs = getValueByPath(fromObject, ['args']);
12785
+ if (fromArgs != null) {
12786
+ setValueByPath(toObject, ['args'], fromArgs);
12787
+ }
12788
+ const fromName = getValueByPath(fromObject, ['name']);
12789
+ if (fromName != null) {
12790
+ setValueByPath(toObject, ['name'], fromName);
12791
+ }
12792
+ return toObject;
12793
+ }
12307
12794
  function partFromMldev(fromObject) {
12308
12795
  const toObject = {};
12309
12796
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12330,6 +12817,10 @@ function partFromMldev(fromObject) {
12330
12817
  if (fromThoughtSignature != null) {
12331
12818
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
12332
12819
  }
12820
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12821
+ if (fromFunctionCall != null) {
12822
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev(fromFunctionCall));
12823
+ }
12333
12824
  const fromCodeExecutionResult = getValueByPath(fromObject, [
12334
12825
  'codeExecutionResult',
12335
12826
  ]);
@@ -12342,10 +12833,6 @@ function partFromMldev(fromObject) {
12342
12833
  if (fromExecutableCode != null) {
12343
12834
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
12344
12835
  }
12345
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12346
- if (fromFunctionCall != null) {
12347
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
12348
- }
12349
12836
  const fromFunctionResponse = getValueByPath(fromObject, [
12350
12837
  'functionResponse',
12351
12838
  ]);
@@ -12868,6 +13355,18 @@ function fileDataFromVertex(fromObject) {
12868
13355
  }
12869
13356
  return toObject;
12870
13357
  }
13358
+ function functionCallFromVertex(fromObject) {
13359
+ const toObject = {};
13360
+ const fromArgs = getValueByPath(fromObject, ['args']);
13361
+ if (fromArgs != null) {
13362
+ setValueByPath(toObject, ['args'], fromArgs);
13363
+ }
13364
+ const fromName = getValueByPath(fromObject, ['name']);
13365
+ if (fromName != null) {
13366
+ setValueByPath(toObject, ['name'], fromName);
13367
+ }
13368
+ return toObject;
13369
+ }
12871
13370
  function partFromVertex(fromObject) {
12872
13371
  const toObject = {};
12873
13372
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12894,6 +13393,10 @@ function partFromVertex(fromObject) {
12894
13393
  if (fromThoughtSignature != null) {
12895
13394
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
12896
13395
  }
13396
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
13397
+ if (fromFunctionCall != null) {
13398
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex(fromFunctionCall));
13399
+ }
12897
13400
  const fromCodeExecutionResult = getValueByPath(fromObject, [
12898
13401
  'codeExecutionResult',
12899
13402
  ]);
@@ -12906,10 +13409,6 @@ function partFromVertex(fromObject) {
12906
13409
  if (fromExecutableCode != null) {
12907
13410
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
12908
13411
  }
12909
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
12910
- if (fromFunctionCall != null) {
12911
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
12912
- }
12913
13412
  const fromFunctionResponse = getValueByPath(fromObject, [
12914
13413
  'functionResponse',
12915
13414
  ]);
@@ -13584,7 +14083,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13584
14083
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13585
14084
  const USER_AGENT_HEADER = 'User-Agent';
13586
14085
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13587
- const SDK_VERSION = '1.17.0'; // x-release-please-version
14086
+ const SDK_VERSION = '1.18.0'; // x-release-please-version
13588
14087
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13589
14088
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13590
14089
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -16905,6 +17404,22 @@ function fileDataToMldev(fromObject) {
16905
17404
  }
16906
17405
  return toObject;
16907
17406
  }
17407
+ function functionCallToMldev(fromObject) {
17408
+ const toObject = {};
17409
+ const fromId = getValueByPath(fromObject, ['id']);
17410
+ if (fromId != null) {
17411
+ setValueByPath(toObject, ['id'], fromId);
17412
+ }
17413
+ const fromArgs = getValueByPath(fromObject, ['args']);
17414
+ if (fromArgs != null) {
17415
+ setValueByPath(toObject, ['args'], fromArgs);
17416
+ }
17417
+ const fromName = getValueByPath(fromObject, ['name']);
17418
+ if (fromName != null) {
17419
+ setValueByPath(toObject, ['name'], fromName);
17420
+ }
17421
+ return toObject;
17422
+ }
16908
17423
  function partToMldev(fromObject) {
16909
17424
  const toObject = {};
16910
17425
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -16931,6 +17446,10 @@ function partToMldev(fromObject) {
16931
17446
  if (fromThoughtSignature != null) {
16932
17447
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
16933
17448
  }
17449
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
17450
+ if (fromFunctionCall != null) {
17451
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
17452
+ }
16934
17453
  const fromCodeExecutionResult = getValueByPath(fromObject, [
16935
17454
  'codeExecutionResult',
16936
17455
  ]);
@@ -16943,10 +17462,6 @@ function partToMldev(fromObject) {
16943
17462
  if (fromExecutableCode != null) {
16944
17463
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
16945
17464
  }
16946
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
16947
- if (fromFunctionCall != null) {
16948
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
16949
- }
16950
17465
  const fromFunctionResponse = getValueByPath(fromObject, [
16951
17466
  'functionResponse',
16952
17467
  ]);
@@ -18890,5 +19405,5 @@ class GoogleGenAI {
18890
19405
  }
18891
19406
  }
18892
19407
 
18893
- 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 };
19408
+ 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 };
18894
19409
  //# sourceMappingURL=index.mjs.map