@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.
package/dist/index.cjs CHANGED
@@ -117,7 +117,16 @@ function setValueByPath(data, keys, value) {
117
117
  }
118
118
  }
119
119
  else {
120
- data[keyToSet] = value;
120
+ if (keyToSet === '_self' &&
121
+ typeof value === 'object' &&
122
+ value !== null &&
123
+ !Array.isArray(value)) {
124
+ const valueAsRecord = value;
125
+ Object.assign(data, valueAsRecord);
126
+ }
127
+ else {
128
+ data[keyToSet] = value;
129
+ }
121
130
  }
122
131
  }
123
132
  function getValueByPath(data, keys) {
@@ -1638,6 +1647,12 @@ class DeleteFileResponse {
1638
1647
  /** Config for `inlined_responses` parameter. */
1639
1648
  class InlinedResponse {
1640
1649
  }
1650
+ /** Config for `response` parameter. */
1651
+ class SingleEmbedContentResponse {
1652
+ }
1653
+ /** Config for `inlined_embedding_responses` parameter. */
1654
+ class InlinedEmbedContentResponse {
1655
+ }
1641
1656
  /** Config for batches.list return value. */
1642
1657
  class ListBatchJobsResponse {
1643
1658
  }
@@ -2489,51 +2504,59 @@ function mcpToolsToGeminiTool(mcpTools, config = {}) {
2489
2504
  return { functionDeclarations: functionDeclarations };
2490
2505
  }
2491
2506
  // Transforms a source input into a BatchJobSource object with validation.
2492
- function tBatchJobSource(apiClient, src) {
2493
- if (typeof src !== 'string' && !Array.isArray(src)) {
2494
- if (apiClient && apiClient.isVertexAI()) {
2495
- if (src.gcsUri && src.bigqueryUri) {
2496
- throw new Error('Only one of `gcsUri` or `bigqueryUri` can be set.');
2507
+ function tBatchJobSource(client, src) {
2508
+ let sourceObj;
2509
+ if (typeof src === 'string') {
2510
+ if (client.isVertexAI()) {
2511
+ if (src.startsWith('gs://')) {
2512
+ sourceObj = { format: 'jsonl', gcsUri: [src] };
2513
+ }
2514
+ else if (src.startsWith('bq://')) {
2515
+ sourceObj = { format: 'bigquery', bigqueryUri: src };
2497
2516
  }
2498
- else if (!src.gcsUri && !src.bigqueryUri) {
2499
- throw new Error('One of `gcsUri` or `bigqueryUri` must be set.');
2517
+ else {
2518
+ throw new Error(`Unsupported string source for Vertex AI: ${src}`);
2500
2519
  }
2501
2520
  }
2502
2521
  else {
2503
- // Logic for non-Vertex AI client (inlined_requests, file_name)
2504
- if (src.inlinedRequests && src.fileName) {
2505
- throw new Error('Only one of `inlinedRequests` or `fileName` can be set.');
2522
+ // MLDEV
2523
+ if (src.startsWith('files/')) {
2524
+ sourceObj = { fileName: src }; // Default to fileName for string input
2506
2525
  }
2507
- else if (!src.inlinedRequests && !src.fileName) {
2508
- throw new Error('One of `inlinedRequests` or `fileName` must be set.');
2526
+ else {
2527
+ throw new Error(`Unsupported string source for Gemini API: ${src}`);
2509
2528
  }
2510
2529
  }
2511
- return src;
2512
2530
  }
2513
- // If src is an array (list in Python)
2514
2531
  else if (Array.isArray(src)) {
2515
- return { inlinedRequests: src };
2516
- }
2517
- else if (typeof src === 'string') {
2518
- if (src.startsWith('gs://')) {
2519
- return {
2520
- format: 'jsonl',
2521
- gcsUri: [src], // GCS URI is expected as an array
2522
- };
2532
+ if (client.isVertexAI()) {
2533
+ throw new Error('InlinedRequest[] is not supported in Vertex AI.');
2523
2534
  }
2524
- else if (src.startsWith('bq://')) {
2525
- return {
2526
- format: 'bigquery',
2527
- bigqueryUri: src,
2528
- };
2535
+ sourceObj = { inlinedRequests: src };
2536
+ }
2537
+ else {
2538
+ // It's already a BatchJobSource object
2539
+ sourceObj = src;
2540
+ }
2541
+ // Validation logic
2542
+ const vertexSourcesCount = [sourceObj.gcsUri, sourceObj.bigqueryUri].filter(Boolean).length;
2543
+ const mldevSourcesCount = [
2544
+ sourceObj.inlinedRequests,
2545
+ sourceObj.fileName,
2546
+ ].filter(Boolean).length;
2547
+ if (client.isVertexAI()) {
2548
+ if (mldevSourcesCount > 0 || vertexSourcesCount !== 1) {
2549
+ throw new Error('Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.');
2529
2550
  }
2530
- else if (src.startsWith('files/')) {
2531
- return {
2532
- fileName: src,
2533
- };
2551
+ }
2552
+ else {
2553
+ // MLDEV
2554
+ if (vertexSourcesCount > 0 || mldevSourcesCount !== 1) {
2555
+ throw new Error('Exactly one of `inlinedRequests`, `fileName`, ' +
2556
+ 'must be set for Gemini API.');
2534
2557
  }
2535
2558
  }
2536
- throw new Error(`Unsupported source: ${src}`);
2559
+ return sourceObj;
2537
2560
  }
2538
2561
  function tBatchJobDestination(dest) {
2539
2562
  if (typeof dest !== 'string') {
@@ -2556,6 +2579,52 @@ function tBatchJobDestination(dest) {
2556
2579
  throw new Error(`Unsupported destination: ${destString}`);
2557
2580
  }
2558
2581
  }
2582
+ function tRecvBatchJobDestination(dest) {
2583
+ // Ensure dest is a non-null object before proceeding.
2584
+ if (typeof dest !== 'object' || dest === null) {
2585
+ // If the input is not an object, it cannot be a valid BatchJobDestination
2586
+ // based on the operations performed. Return it cast, or handle as an error.
2587
+ // Casting an empty object might be a safe default.
2588
+ return {};
2589
+ }
2590
+ // Cast to Record<string, unknown> to allow string property access.
2591
+ const obj = dest;
2592
+ // Safely access nested properties.
2593
+ const inlineResponsesVal = obj['inlinedResponses'];
2594
+ if (typeof inlineResponsesVal !== 'object' || inlineResponsesVal === null) {
2595
+ return dest;
2596
+ }
2597
+ const inlineResponsesObj = inlineResponsesVal;
2598
+ const responsesArray = inlineResponsesObj['inlinedResponses'];
2599
+ if (!Array.isArray(responsesArray) || responsesArray.length === 0) {
2600
+ return dest;
2601
+ }
2602
+ // Check if any response has the 'embedding' property.
2603
+ let hasEmbedding = false;
2604
+ for (const responseItem of responsesArray) {
2605
+ if (typeof responseItem !== 'object' || responseItem === null) {
2606
+ continue;
2607
+ }
2608
+ const responseItemObj = responseItem;
2609
+ const responseVal = responseItemObj['response'];
2610
+ if (typeof responseVal !== 'object' || responseVal === null) {
2611
+ continue;
2612
+ }
2613
+ const responseObj = responseVal;
2614
+ // Check for the existence of the 'embedding' key.
2615
+ if (responseObj['embedding'] !== undefined) {
2616
+ hasEmbedding = true;
2617
+ break;
2618
+ }
2619
+ }
2620
+ // Perform the transformation if an embedding was found.
2621
+ if (hasEmbedding) {
2622
+ obj['inlinedEmbedContentResponses'] = obj['inlinedResponses'];
2623
+ delete obj['inlinedResponses'];
2624
+ }
2625
+ // Cast the (potentially) modified object to the target type.
2626
+ return dest;
2627
+ }
2559
2628
  function tBatchJobName(apiClient, name) {
2560
2629
  const nameString = name;
2561
2630
  if (!apiClient.isVertexAI()) {
@@ -2651,6 +2720,22 @@ function fileDataToMldev$4(fromObject) {
2651
2720
  }
2652
2721
  return toObject;
2653
2722
  }
2723
+ function functionCallToMldev$4(fromObject) {
2724
+ const toObject = {};
2725
+ const fromId = getValueByPath(fromObject, ['id']);
2726
+ if (fromId != null) {
2727
+ setValueByPath(toObject, ['id'], fromId);
2728
+ }
2729
+ const fromArgs = getValueByPath(fromObject, ['args']);
2730
+ if (fromArgs != null) {
2731
+ setValueByPath(toObject, ['args'], fromArgs);
2732
+ }
2733
+ const fromName = getValueByPath(fromObject, ['name']);
2734
+ if (fromName != null) {
2735
+ setValueByPath(toObject, ['name'], fromName);
2736
+ }
2737
+ return toObject;
2738
+ }
2654
2739
  function partToMldev$4(fromObject) {
2655
2740
  const toObject = {};
2656
2741
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -2677,6 +2762,10 @@ function partToMldev$4(fromObject) {
2677
2762
  if (fromThoughtSignature != null) {
2678
2763
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
2679
2764
  }
2765
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2766
+ if (fromFunctionCall != null) {
2767
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$4(fromFunctionCall));
2768
+ }
2680
2769
  const fromCodeExecutionResult = getValueByPath(fromObject, [
2681
2770
  'codeExecutionResult',
2682
2771
  ]);
@@ -2689,10 +2778,6 @@ function partToMldev$4(fromObject) {
2689
2778
  if (fromExecutableCode != null) {
2690
2779
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
2691
2780
  }
2692
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2693
- if (fromFunctionCall != null) {
2694
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
2695
- }
2696
2781
  const fromFunctionResponse = getValueByPath(fromObject, [
2697
2782
  'functionResponse',
2698
2783
  ]);
@@ -3344,6 +3429,80 @@ function createBatchJobParametersToMldev(apiClient, fromObject) {
3344
3429
  }
3345
3430
  return toObject;
3346
3431
  }
3432
+ function embedContentConfigToMldev$1(fromObject, parentObject) {
3433
+ const toObject = {};
3434
+ const fromTaskType = getValueByPath(fromObject, ['taskType']);
3435
+ if (parentObject !== undefined && fromTaskType != null) {
3436
+ setValueByPath(parentObject, ['requests[]', 'taskType'], fromTaskType);
3437
+ }
3438
+ const fromTitle = getValueByPath(fromObject, ['title']);
3439
+ if (parentObject !== undefined && fromTitle != null) {
3440
+ setValueByPath(parentObject, ['requests[]', 'title'], fromTitle);
3441
+ }
3442
+ const fromOutputDimensionality = getValueByPath(fromObject, [
3443
+ 'outputDimensionality',
3444
+ ]);
3445
+ if (parentObject !== undefined && fromOutputDimensionality != null) {
3446
+ setValueByPath(parentObject, ['requests[]', 'outputDimensionality'], fromOutputDimensionality);
3447
+ }
3448
+ if (getValueByPath(fromObject, ['mimeType']) !== undefined) {
3449
+ throw new Error('mimeType parameter is not supported in Gemini API.');
3450
+ }
3451
+ if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
3452
+ throw new Error('autoTruncate parameter is not supported in Gemini API.');
3453
+ }
3454
+ return toObject;
3455
+ }
3456
+ function embedContentBatchToMldev(apiClient, fromObject) {
3457
+ const toObject = {};
3458
+ const fromContents = getValueByPath(fromObject, ['contents']);
3459
+ if (fromContents != null) {
3460
+ setValueByPath(toObject, ['requests[]', 'request', 'content'], tContentsForEmbed(apiClient, fromContents));
3461
+ }
3462
+ const fromConfig = getValueByPath(fromObject, ['config']);
3463
+ if (fromConfig != null) {
3464
+ setValueByPath(toObject, ['config'], embedContentConfigToMldev$1(fromConfig, toObject));
3465
+ }
3466
+ return toObject;
3467
+ }
3468
+ function embeddingsBatchJobSourceToMldev(apiClient, fromObject) {
3469
+ const toObject = {};
3470
+ const fromFileName = getValueByPath(fromObject, ['fileName']);
3471
+ if (fromFileName != null) {
3472
+ setValueByPath(toObject, ['file_name'], fromFileName);
3473
+ }
3474
+ const fromInlinedRequests = getValueByPath(fromObject, [
3475
+ 'inlinedRequests',
3476
+ ]);
3477
+ if (fromInlinedRequests != null) {
3478
+ setValueByPath(toObject, ['requests'], embedContentBatchToMldev(apiClient, fromInlinedRequests));
3479
+ }
3480
+ return toObject;
3481
+ }
3482
+ function createEmbeddingsBatchJobConfigToMldev(fromObject, parentObject) {
3483
+ const toObject = {};
3484
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3485
+ if (parentObject !== undefined && fromDisplayName != null) {
3486
+ setValueByPath(parentObject, ['batch', 'displayName'], fromDisplayName);
3487
+ }
3488
+ return toObject;
3489
+ }
3490
+ function createEmbeddingsBatchJobParametersToMldev(apiClient, fromObject) {
3491
+ const toObject = {};
3492
+ const fromModel = getValueByPath(fromObject, ['model']);
3493
+ if (fromModel != null) {
3494
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3495
+ }
3496
+ const fromSrc = getValueByPath(fromObject, ['src']);
3497
+ if (fromSrc != null) {
3498
+ setValueByPath(toObject, ['batch', 'inputConfig'], embeddingsBatchJobSourceToMldev(apiClient, fromSrc));
3499
+ }
3500
+ const fromConfig = getValueByPath(fromObject, ['config']);
3501
+ if (fromConfig != null) {
3502
+ setValueByPath(toObject, ['config'], createEmbeddingsBatchJobConfigToMldev(fromConfig, toObject));
3503
+ }
3504
+ return toObject;
3505
+ }
3347
3506
  function getBatchJobParametersToMldev(apiClient, fromObject) {
3348
3507
  const toObject = {};
3349
3508
  const fromName = getValueByPath(fromObject, ['name']);
@@ -3445,6 +3604,10 @@ function batchJobDestinationToVertex(fromObject) {
3445
3604
  if (getValueByPath(fromObject, ['inlinedResponses']) !== undefined) {
3446
3605
  throw new Error('inlinedResponses parameter is not supported in Vertex AI.');
3447
3606
  }
3607
+ if (getValueByPath(fromObject, ['inlinedEmbedContentResponses']) !==
3608
+ undefined) {
3609
+ throw new Error('inlinedEmbedContentResponses parameter is not supported in Vertex AI.');
3610
+ }
3448
3611
  return toObject;
3449
3612
  }
3450
3613
  function createBatchJobConfigToVertex(fromObject, parentObject) {
@@ -3575,6 +3738,22 @@ function fileDataFromMldev$2(fromObject) {
3575
3738
  }
3576
3739
  return toObject;
3577
3740
  }
3741
+ function functionCallFromMldev$2(fromObject) {
3742
+ const toObject = {};
3743
+ const fromId = getValueByPath(fromObject, ['id']);
3744
+ if (fromId != null) {
3745
+ setValueByPath(toObject, ['id'], fromId);
3746
+ }
3747
+ const fromArgs = getValueByPath(fromObject, ['args']);
3748
+ if (fromArgs != null) {
3749
+ setValueByPath(toObject, ['args'], fromArgs);
3750
+ }
3751
+ const fromName = getValueByPath(fromObject, ['name']);
3752
+ if (fromName != null) {
3753
+ setValueByPath(toObject, ['name'], fromName);
3754
+ }
3755
+ return toObject;
3756
+ }
3578
3757
  function partFromMldev$2(fromObject) {
3579
3758
  const toObject = {};
3580
3759
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -3601,6 +3780,10 @@ function partFromMldev$2(fromObject) {
3601
3780
  if (fromThoughtSignature != null) {
3602
3781
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
3603
3782
  }
3783
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3784
+ if (fromFunctionCall != null) {
3785
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$2(fromFunctionCall));
3786
+ }
3604
3787
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3605
3788
  'codeExecutionResult',
3606
3789
  ]);
@@ -3613,10 +3796,6 @@ function partFromMldev$2(fromObject) {
3613
3796
  if (fromExecutableCode != null) {
3614
3797
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
3615
3798
  }
3616
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3617
- if (fromFunctionCall != null) {
3618
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
3619
- }
3620
3799
  const fromFunctionResponse = getValueByPath(fromObject, [
3621
3800
  'functionResponse',
3622
3801
  ]);
@@ -3805,6 +3984,38 @@ function inlinedResponseFromMldev(fromObject) {
3805
3984
  }
3806
3985
  return toObject;
3807
3986
  }
3987
+ function contentEmbeddingFromMldev$1(fromObject) {
3988
+ const toObject = {};
3989
+ const fromValues = getValueByPath(fromObject, ['values']);
3990
+ if (fromValues != null) {
3991
+ setValueByPath(toObject, ['values'], fromValues);
3992
+ }
3993
+ return toObject;
3994
+ }
3995
+ function singleEmbedContentResponseFromMldev(fromObject) {
3996
+ const toObject = {};
3997
+ const fromEmbedding = getValueByPath(fromObject, ['embedding']);
3998
+ if (fromEmbedding != null) {
3999
+ setValueByPath(toObject, ['embedding'], contentEmbeddingFromMldev$1(fromEmbedding));
4000
+ }
4001
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
4002
+ if (fromTokenCount != null) {
4003
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
4004
+ }
4005
+ return toObject;
4006
+ }
4007
+ function inlinedEmbedContentResponseFromMldev(fromObject) {
4008
+ const toObject = {};
4009
+ const fromResponse = getValueByPath(fromObject, ['response']);
4010
+ if (fromResponse != null) {
4011
+ setValueByPath(toObject, ['response'], singleEmbedContentResponseFromMldev(fromResponse));
4012
+ }
4013
+ const fromError = getValueByPath(fromObject, ['error']);
4014
+ if (fromError != null) {
4015
+ setValueByPath(toObject, ['error'], jobErrorFromMldev(fromError));
4016
+ }
4017
+ return toObject;
4018
+ }
3808
4019
  function batchJobDestinationFromMldev(fromObject) {
3809
4020
  const toObject = {};
3810
4021
  const fromFileName = getValueByPath(fromObject, ['responsesFile']);
@@ -3824,6 +4035,19 @@ function batchJobDestinationFromMldev(fromObject) {
3824
4035
  }
3825
4036
  setValueByPath(toObject, ['inlinedResponses'], transformedList);
3826
4037
  }
4038
+ const fromInlinedEmbedContentResponses = getValueByPath(fromObject, [
4039
+ 'inlinedEmbedContentResponses',
4040
+ 'inlinedResponses',
4041
+ ]);
4042
+ if (fromInlinedEmbedContentResponses != null) {
4043
+ let transformedList = fromInlinedEmbedContentResponses;
4044
+ if (Array.isArray(transformedList)) {
4045
+ transformedList = transformedList.map((item) => {
4046
+ return inlinedEmbedContentResponseFromMldev(item);
4047
+ });
4048
+ }
4049
+ setValueByPath(toObject, ['inlinedEmbedContentResponses'], transformedList);
4050
+ }
3827
4051
  return toObject;
3828
4052
  }
3829
4053
  function batchJobFromMldev(fromObject) {
@@ -3870,7 +4094,7 @@ function batchJobFromMldev(fromObject) {
3870
4094
  }
3871
4095
  const fromDest = getValueByPath(fromObject, ['metadata', 'output']);
3872
4096
  if (fromDest != null) {
3873
- setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(fromDest));
4097
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(tRecvBatchJobDestination(fromDest)));
3874
4098
  }
3875
4099
  return toObject;
3876
4100
  }
@@ -4023,7 +4247,7 @@ function batchJobFromVertex(fromObject) {
4023
4247
  }
4024
4248
  const fromDest = getValueByPath(fromObject, ['outputConfig']);
4025
4249
  if (fromDest != null) {
4026
- setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(fromDest));
4250
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(tRecvBatchJobDestination(fromDest)));
4027
4251
  }
4028
4252
  return toObject;
4029
4253
  }
@@ -4289,79 +4513,87 @@ class Batches extends BaseModule {
4289
4513
  this.create = async (params) => {
4290
4514
  var _a, _b;
4291
4515
  if (this.apiClient.isVertexAI()) {
4292
- const timestamp = Date.now();
4293
- const timestampStr = timestamp.toString();
4294
- if (Array.isArray(params.src)) {
4295
- throw new Error('InlinedRequest[] is not supported in Vertex AI. Please use ' +
4296
- 'Google Cloud Storage URI or BigQuery URI instead.');
4297
- }
4298
- params.config = params.config || {};
4299
- if (params.config.displayName === undefined) {
4300
- params.config.displayName = 'genaiBatchJob_${timestampStr}';
4301
- }
4302
- if (params.config.dest === undefined && typeof params.src === 'string') {
4303
- if (params.src.startsWith('gs://') && params.src.endsWith('.jsonl')) {
4304
- params.config.dest = `${params.src.slice(0, -6)}/dest`;
4305
- }
4306
- else if (params.src.startsWith('bq://')) {
4307
- params.config.dest =
4308
- `${params.src}_dest_${timestampStr}`;
4309
- }
4310
- else {
4311
- throw new Error('Unsupported source:' + params.src);
4312
- }
4313
- }
4516
+ // Format destination if not provided
4517
+ // Cast params.src as Vertex AI path does not handle InlinedRequest[]
4518
+ params.config = this.formatDestination(params.src, params.config);
4519
+ return this.createInternal(params);
4314
4520
  }
4315
- else {
4316
- if (Array.isArray(params.src) ||
4317
- (typeof params.src !== 'string' && params.src.inlinedRequests)) {
4318
- // Move system instruction to httpOptions extraBody.
4319
- let path = '';
4320
- let queryParams = {};
4321
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4322
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4323
- queryParams = body['_query'];
4324
- // Move system instruction to 'request':
4325
- // {'systemInstruction': system_instruction}
4326
- const batch = body['batch'];
4327
- const inputConfig = batch['inputConfig'];
4328
- const requestsWrapper = inputConfig['requests'];
4329
- const requests = requestsWrapper['requests'];
4330
- const newRequests = [];
4331
- for (const request of requests) {
4332
- const requestDict = request;
4333
- if (requestDict['systemInstruction']) {
4334
- const systemInstructionValue = requestDict['systemInstruction'];
4335
- delete requestDict['systemInstruction'];
4336
- const requestContent = requestDict['request'];
4337
- requestContent['systemInstruction'] = systemInstructionValue;
4338
- requestDict['request'] = requestContent;
4339
- }
4340
- newRequests.push(requestDict);
4341
- }
4342
- requestsWrapper['requests'] = newRequests;
4343
- delete body['config'];
4344
- delete body['_url'];
4345
- delete body['_query'];
4346
- const response = this.apiClient
4347
- .request({
4348
- path: path,
4349
- queryParams: queryParams,
4350
- body: JSON.stringify(body),
4351
- httpMethod: 'POST',
4352
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4353
- abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4354
- })
4355
- .then((httpResponse) => {
4356
- return httpResponse.json();
4357
- });
4358
- return response.then((apiResponse) => {
4359
- const resp = batchJobFromMldev(apiResponse);
4360
- return resp;
4361
- });
4362
- }
4521
+ // MLDEV
4522
+ const src = params.src;
4523
+ const is_inlined = Array.isArray(params.src) || src.inlinedRequests !== undefined;
4524
+ if (!is_inlined) {
4525
+ return this.createInternal(params);
4363
4526
  }
4364
- return await this.createInternal(params);
4527
+ // Inlined generate content requests handling
4528
+ const result = this.createInlinedGenerateContentRequest(params);
4529
+ const path = result.path;
4530
+ const requestBody = result.body;
4531
+ const queryParams = createBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4532
+ const response = this.apiClient
4533
+ .request({
4534
+ path: path,
4535
+ queryParams: queryParams,
4536
+ body: JSON.stringify(requestBody),
4537
+ httpMethod: 'POST',
4538
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4539
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4540
+ })
4541
+ .then((httpResponse) => {
4542
+ return httpResponse.json();
4543
+ });
4544
+ return response.then((apiResponse) => {
4545
+ const resp = batchJobFromMldev(apiResponse);
4546
+ return resp;
4547
+ });
4548
+ };
4549
+ /**
4550
+ * **Experimental** Creates an embedding batch job.
4551
+ *
4552
+ * @param params - The parameters for create embedding batch job request.
4553
+ * @return The created batch job.
4554
+ *
4555
+ * @example
4556
+ * ```ts
4557
+ * const response = await ai.batches.createEmbeddings({
4558
+ * model: 'text-embedding-004',
4559
+ * src: {fileName: 'files/my_embedding_input'},
4560
+ * });
4561
+ * console.log(response);
4562
+ * ```
4563
+ */
4564
+ this.createEmbeddings = async (params) => {
4565
+ var _a, _b;
4566
+ console.warn('batches.createEmbeddings() is experimental and may change without notice.');
4567
+ if (this.apiClient.isVertexAI()) {
4568
+ throw new Error('Vertex AI does not support batches.createEmbeddings.');
4569
+ }
4570
+ // MLDEV
4571
+ const src = params.src;
4572
+ const is_inlined = src.inlinedRequests !== undefined;
4573
+ if (!is_inlined) {
4574
+ return this.createEmbeddingsInternal(params); // Fixed typo here
4575
+ }
4576
+ // Inlined embed content requests handling
4577
+ const result = this.createInlinedEmbedContentRequest(params);
4578
+ const path = result.path;
4579
+ const requestBody = result.body;
4580
+ const queryParams = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params)['_query'] || {};
4581
+ const response = this.apiClient
4582
+ .request({
4583
+ path: path,
4584
+ queryParams: queryParams,
4585
+ body: JSON.stringify(requestBody),
4586
+ httpMethod: 'POST',
4587
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4588
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4589
+ })
4590
+ .then((httpResponse) => {
4591
+ return httpResponse.json();
4592
+ });
4593
+ return response.then((apiResponse) => {
4594
+ const resp = batchJobFromMldev(apiResponse);
4595
+ return resp;
4596
+ });
4365
4597
  };
4366
4598
  /**
4367
4599
  * Lists batch job configurations.
@@ -4381,6 +4613,112 @@ class Batches extends BaseModule {
4381
4613
  return new Pager(exports.PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4382
4614
  };
4383
4615
  }
4616
+ // Helper function to handle inlined generate content requests
4617
+ createInlinedGenerateContentRequest(params) {
4618
+ const body = createBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4619
+ params);
4620
+ const urlParams = body['_url'];
4621
+ const path = formatMap('{model}:batchGenerateContent', urlParams);
4622
+ const batch = body['batch'];
4623
+ const inputConfig = batch['inputConfig'];
4624
+ const requestsWrapper = inputConfig['requests'];
4625
+ const requests = requestsWrapper['requests'];
4626
+ const newRequests = [];
4627
+ for (const request of requests) {
4628
+ const requestDict = Object.assign({}, request); // Clone
4629
+ if (requestDict['systemInstruction']) {
4630
+ const systemInstructionValue = requestDict['systemInstruction'];
4631
+ delete requestDict['systemInstruction'];
4632
+ const requestContent = requestDict['request'];
4633
+ requestContent['systemInstruction'] = systemInstructionValue;
4634
+ requestDict['request'] = requestContent;
4635
+ }
4636
+ newRequests.push(requestDict);
4637
+ }
4638
+ requestsWrapper['requests'] = newRequests;
4639
+ delete body['config'];
4640
+ delete body['_url'];
4641
+ delete body['_query'];
4642
+ return { path, body };
4643
+ }
4644
+ // Helper function to handle inlined embedding requests
4645
+ createInlinedEmbedContentRequest(params) {
4646
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, // Use instance apiClient
4647
+ params);
4648
+ const urlParams = body['_url'];
4649
+ const path = formatMap('{model}:asyncBatchEmbedContent', 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
+ delete requestsWrapper['config']; // Remove top-level config
4656
+ for (const request of requests) {
4657
+ const requestDict = Object.assign({}, request); // Clone
4658
+ const innerRequest = requestDict['request'];
4659
+ for (const key in requestDict) {
4660
+ if (key !== 'request') {
4661
+ innerRequest[key] = requestDict[key];
4662
+ delete requestDict[key];
4663
+ }
4664
+ }
4665
+ newRequests.push(requestDict);
4666
+ }
4667
+ requestsWrapper['requests'] = newRequests;
4668
+ delete body['config'];
4669
+ delete body['_url'];
4670
+ delete body['_query'];
4671
+ return { path, body };
4672
+ }
4673
+ // Helper function to get the first GCS URI
4674
+ getGcsUri(src) {
4675
+ if (typeof src === 'string') {
4676
+ return src.startsWith('gs://') ? src : undefined;
4677
+ }
4678
+ if (!Array.isArray(src) && src.gcsUri && src.gcsUri.length > 0) {
4679
+ return src.gcsUri[0];
4680
+ }
4681
+ return undefined;
4682
+ }
4683
+ // Helper function to get the BigQuery URI
4684
+ getBigqueryUri(src) {
4685
+ if (typeof src === 'string') {
4686
+ return src.startsWith('bq://') ? src : undefined;
4687
+ }
4688
+ if (!Array.isArray(src)) {
4689
+ return src.bigqueryUri;
4690
+ }
4691
+ return undefined;
4692
+ }
4693
+ // Function to format the destination configuration for Vertex AI
4694
+ formatDestination(src, config) {
4695
+ const newConfig = config ? Object.assign({}, config) : {};
4696
+ const timestampStr = Date.now().toString();
4697
+ if (!newConfig.displayName) {
4698
+ newConfig.displayName = `genaiBatchJob_${timestampStr}`;
4699
+ }
4700
+ if (newConfig.dest === undefined) {
4701
+ const gcsUri = this.getGcsUri(src);
4702
+ const bigqueryUri = this.getBigqueryUri(src);
4703
+ if (gcsUri) {
4704
+ if (gcsUri.endsWith('.jsonl')) {
4705
+ // For .jsonl files, remove suffix and add /dest
4706
+ newConfig.dest = `${gcsUri.slice(0, -6)}/dest`;
4707
+ }
4708
+ else {
4709
+ // Fallback for other GCS URIs
4710
+ newConfig.dest = `${gcsUri}_dest_${timestampStr}`;
4711
+ }
4712
+ }
4713
+ else if (bigqueryUri) {
4714
+ newConfig.dest = `${bigqueryUri}_dest_${timestampStr}`;
4715
+ }
4716
+ else {
4717
+ throw new Error('Unsupported source for Vertex AI: No GCS or BigQuery URI found.');
4718
+ }
4719
+ }
4720
+ return newConfig;
4721
+ }
4384
4722
  /**
4385
4723
  * Internal method to create batch job.
4386
4724
  *
@@ -4418,8 +4756,48 @@ class Batches extends BaseModule {
4418
4756
  });
4419
4757
  }
4420
4758
  else {
4421
- const body = createBatchJobParametersToMldev(this.apiClient, params);
4422
- path = formatMap('{model}:batchGenerateContent', body['_url']);
4759
+ const body = createBatchJobParametersToMldev(this.apiClient, params);
4760
+ path = formatMap('{model}:batchGenerateContent', body['_url']);
4761
+ queryParams = body['_query'];
4762
+ delete body['config'];
4763
+ delete body['_url'];
4764
+ delete body['_query'];
4765
+ response = this.apiClient
4766
+ .request({
4767
+ path: path,
4768
+ queryParams: queryParams,
4769
+ body: JSON.stringify(body),
4770
+ httpMethod: 'POST',
4771
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4772
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4773
+ })
4774
+ .then((httpResponse) => {
4775
+ return httpResponse.json();
4776
+ });
4777
+ return response.then((apiResponse) => {
4778
+ const resp = batchJobFromMldev(apiResponse);
4779
+ return resp;
4780
+ });
4781
+ }
4782
+ }
4783
+ /**
4784
+ * Internal method to create batch job.
4785
+ *
4786
+ * @param params - The parameters for create batch job request.
4787
+ * @return The created batch job.
4788
+ *
4789
+ */
4790
+ async createEmbeddingsInternal(params) {
4791
+ var _a, _b;
4792
+ let response;
4793
+ let path = '';
4794
+ let queryParams = {};
4795
+ if (this.apiClient.isVertexAI()) {
4796
+ throw new Error('This method is only supported by the Gemini Developer API.');
4797
+ }
4798
+ else {
4799
+ const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params);
4800
+ path = formatMap('{model}:asyncBatchEmbedContent', body['_url']);
4423
4801
  queryParams = body['_query'];
4424
4802
  delete body['config'];
4425
4803
  delete body['_url'];
@@ -4430,8 +4808,8 @@ class Batches extends BaseModule {
4430
4808
  queryParams: queryParams,
4431
4809
  body: JSON.stringify(body),
4432
4810
  httpMethod: 'POST',
4433
- httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4434
- abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4811
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4812
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4435
4813
  })
4436
4814
  .then((httpResponse) => {
4437
4815
  return httpResponse.json();
@@ -4755,6 +5133,22 @@ function fileDataToMldev$3(fromObject) {
4755
5133
  }
4756
5134
  return toObject;
4757
5135
  }
5136
+ function functionCallToMldev$3(fromObject) {
5137
+ const toObject = {};
5138
+ const fromId = getValueByPath(fromObject, ['id']);
5139
+ if (fromId != null) {
5140
+ setValueByPath(toObject, ['id'], fromId);
5141
+ }
5142
+ const fromArgs = getValueByPath(fromObject, ['args']);
5143
+ if (fromArgs != null) {
5144
+ setValueByPath(toObject, ['args'], fromArgs);
5145
+ }
5146
+ const fromName = getValueByPath(fromObject, ['name']);
5147
+ if (fromName != null) {
5148
+ setValueByPath(toObject, ['name'], fromName);
5149
+ }
5150
+ return toObject;
5151
+ }
4758
5152
  function partToMldev$3(fromObject) {
4759
5153
  const toObject = {};
4760
5154
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -4781,6 +5175,10 @@ function partToMldev$3(fromObject) {
4781
5175
  if (fromThoughtSignature != null) {
4782
5176
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
4783
5177
  }
5178
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5179
+ if (fromFunctionCall != null) {
5180
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$3(fromFunctionCall));
5181
+ }
4784
5182
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4785
5183
  'codeExecutionResult',
4786
5184
  ]);
@@ -4793,10 +5191,6 @@ function partToMldev$3(fromObject) {
4793
5191
  if (fromExecutableCode != null) {
4794
5192
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
4795
5193
  }
4796
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
4797
- if (fromFunctionCall != null) {
4798
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
4799
- }
4800
5194
  const fromFunctionResponse = getValueByPath(fromObject, [
4801
5195
  'functionResponse',
4802
5196
  ]);
@@ -5204,6 +5598,21 @@ function fileDataToVertex$2(fromObject) {
5204
5598
  }
5205
5599
  return toObject;
5206
5600
  }
5601
+ function functionCallToVertex$2(fromObject) {
5602
+ const toObject = {};
5603
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
5604
+ throw new Error('id parameter is not supported in Vertex AI.');
5605
+ }
5606
+ const fromArgs = getValueByPath(fromObject, ['args']);
5607
+ if (fromArgs != null) {
5608
+ setValueByPath(toObject, ['args'], fromArgs);
5609
+ }
5610
+ const fromName = getValueByPath(fromObject, ['name']);
5611
+ if (fromName != null) {
5612
+ setValueByPath(toObject, ['name'], fromName);
5613
+ }
5614
+ return toObject;
5615
+ }
5207
5616
  function partToVertex$2(fromObject) {
5208
5617
  const toObject = {};
5209
5618
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -5230,6 +5639,10 @@ function partToVertex$2(fromObject) {
5230
5639
  if (fromThoughtSignature != null) {
5231
5640
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
5232
5641
  }
5642
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5643
+ if (fromFunctionCall != null) {
5644
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$2(fromFunctionCall));
5645
+ }
5233
5646
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5234
5647
  'codeExecutionResult',
5235
5648
  ]);
@@ -5242,10 +5655,6 @@ function partToVertex$2(fromObject) {
5242
5655
  if (fromExecutableCode != null) {
5243
5656
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
5244
5657
  }
5245
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5246
- if (fromFunctionCall != null) {
5247
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5248
- }
5249
5658
  const fromFunctionResponse = getValueByPath(fromObject, [
5250
5659
  'functionResponse',
5251
5660
  ]);
@@ -6617,7 +7026,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6617
7026
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6618
7027
  const USER_AGENT_HEADER = 'User-Agent';
6619
7028
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6620
- const SDK_VERSION = '1.17.0'; // x-release-please-version
7029
+ const SDK_VERSION = '1.18.0'; // x-release-please-version
6621
7030
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6622
7031
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6623
7032
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -7972,6 +8381,22 @@ function fileDataToMldev$2(fromObject) {
7972
8381
  }
7973
8382
  return toObject;
7974
8383
  }
8384
+ function functionCallToMldev$2(fromObject) {
8385
+ const toObject = {};
8386
+ const fromId = getValueByPath(fromObject, ['id']);
8387
+ if (fromId != null) {
8388
+ setValueByPath(toObject, ['id'], fromId);
8389
+ }
8390
+ const fromArgs = getValueByPath(fromObject, ['args']);
8391
+ if (fromArgs != null) {
8392
+ setValueByPath(toObject, ['args'], fromArgs);
8393
+ }
8394
+ const fromName = getValueByPath(fromObject, ['name']);
8395
+ if (fromName != null) {
8396
+ setValueByPath(toObject, ['name'], fromName);
8397
+ }
8398
+ return toObject;
8399
+ }
7975
8400
  function partToMldev$2(fromObject) {
7976
8401
  const toObject = {};
7977
8402
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -7998,6 +8423,10 @@ function partToMldev$2(fromObject) {
7998
8423
  if (fromThoughtSignature != null) {
7999
8424
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8000
8425
  }
8426
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8427
+ if (fromFunctionCall != null) {
8428
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$2(fromFunctionCall));
8429
+ }
8001
8430
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8002
8431
  'codeExecutionResult',
8003
8432
  ]);
@@ -8010,10 +8439,6 @@ function partToMldev$2(fromObject) {
8010
8439
  if (fromExecutableCode != null) {
8011
8440
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8012
8441
  }
8013
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8014
- if (fromFunctionCall != null) {
8015
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8016
- }
8017
8442
  const fromFunctionResponse = getValueByPath(fromObject, [
8018
8443
  'functionResponse',
8019
8444
  ]);
@@ -8676,6 +9101,21 @@ function fileDataToVertex$1(fromObject) {
8676
9101
  }
8677
9102
  return toObject;
8678
9103
  }
9104
+ function functionCallToVertex$1(fromObject) {
9105
+ const toObject = {};
9106
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
9107
+ throw new Error('id parameter is not supported in Vertex AI.');
9108
+ }
9109
+ const fromArgs = getValueByPath(fromObject, ['args']);
9110
+ if (fromArgs != null) {
9111
+ setValueByPath(toObject, ['args'], fromArgs);
9112
+ }
9113
+ const fromName = getValueByPath(fromObject, ['name']);
9114
+ if (fromName != null) {
9115
+ setValueByPath(toObject, ['name'], fromName);
9116
+ }
9117
+ return toObject;
9118
+ }
8679
9119
  function partToVertex$1(fromObject) {
8680
9120
  const toObject = {};
8681
9121
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -8702,6 +9142,10 @@ function partToVertex$1(fromObject) {
8702
9142
  if (fromThoughtSignature != null) {
8703
9143
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8704
9144
  }
9145
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9146
+ if (fromFunctionCall != null) {
9147
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex$1(fromFunctionCall));
9148
+ }
8705
9149
  const fromCodeExecutionResult = getValueByPath(fromObject, [
8706
9150
  'codeExecutionResult',
8707
9151
  ]);
@@ -8714,10 +9158,6 @@ function partToVertex$1(fromObject) {
8714
9158
  if (fromExecutableCode != null) {
8715
9159
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8716
9160
  }
8717
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8718
- if (fromFunctionCall != null) {
8719
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8720
- }
8721
9161
  const fromFunctionResponse = getValueByPath(fromObject, [
8722
9162
  'functionResponse',
8723
9163
  ]);
@@ -9265,6 +9705,22 @@ function fileDataFromMldev$1(fromObject) {
9265
9705
  }
9266
9706
  return toObject;
9267
9707
  }
9708
+ function functionCallFromMldev$1(fromObject) {
9709
+ const toObject = {};
9710
+ const fromId = getValueByPath(fromObject, ['id']);
9711
+ if (fromId != null) {
9712
+ setValueByPath(toObject, ['id'], fromId);
9713
+ }
9714
+ const fromArgs = getValueByPath(fromObject, ['args']);
9715
+ if (fromArgs != null) {
9716
+ setValueByPath(toObject, ['args'], fromArgs);
9717
+ }
9718
+ const fromName = getValueByPath(fromObject, ['name']);
9719
+ if (fromName != null) {
9720
+ setValueByPath(toObject, ['name'], fromName);
9721
+ }
9722
+ return toObject;
9723
+ }
9268
9724
  function partFromMldev$1(fromObject) {
9269
9725
  const toObject = {};
9270
9726
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9291,6 +9747,10 @@ function partFromMldev$1(fromObject) {
9291
9747
  if (fromThoughtSignature != null) {
9292
9748
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9293
9749
  }
9750
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9751
+ if (fromFunctionCall != null) {
9752
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev$1(fromFunctionCall));
9753
+ }
9294
9754
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9295
9755
  'codeExecutionResult',
9296
9756
  ]);
@@ -9303,10 +9763,6 @@ function partFromMldev$1(fromObject) {
9303
9763
  if (fromExecutableCode != null) {
9304
9764
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9305
9765
  }
9306
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9307
- if (fromFunctionCall != null) {
9308
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9309
- }
9310
9766
  const fromFunctionResponse = getValueByPath(fromObject, [
9311
9767
  'functionResponse',
9312
9768
  ]);
@@ -9423,22 +9879,6 @@ function liveServerContentFromMldev(fromObject) {
9423
9879
  }
9424
9880
  return toObject;
9425
9881
  }
9426
- function functionCallFromMldev(fromObject) {
9427
- const toObject = {};
9428
- const fromId = getValueByPath(fromObject, ['id']);
9429
- if (fromId != null) {
9430
- setValueByPath(toObject, ['id'], fromId);
9431
- }
9432
- const fromArgs = getValueByPath(fromObject, ['args']);
9433
- if (fromArgs != null) {
9434
- setValueByPath(toObject, ['args'], fromArgs);
9435
- }
9436
- const fromName = getValueByPath(fromObject, ['name']);
9437
- if (fromName != null) {
9438
- setValueByPath(toObject, ['name'], fromName);
9439
- }
9440
- return toObject;
9441
- }
9442
9882
  function liveServerToolCallFromMldev(fromObject) {
9443
9883
  const toObject = {};
9444
9884
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -9448,7 +9888,7 @@ function liveServerToolCallFromMldev(fromObject) {
9448
9888
  let transformedList = fromFunctionCalls;
9449
9889
  if (Array.isArray(transformedList)) {
9450
9890
  transformedList = transformedList.map((item) => {
9451
- return functionCallFromMldev(item);
9891
+ return functionCallFromMldev$1(item);
9452
9892
  });
9453
9893
  }
9454
9894
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -9859,6 +10299,18 @@ function fileDataFromVertex$1(fromObject) {
9859
10299
  }
9860
10300
  return toObject;
9861
10301
  }
10302
+ function functionCallFromVertex$1(fromObject) {
10303
+ const toObject = {};
10304
+ const fromArgs = getValueByPath(fromObject, ['args']);
10305
+ if (fromArgs != null) {
10306
+ setValueByPath(toObject, ['args'], fromArgs);
10307
+ }
10308
+ const fromName = getValueByPath(fromObject, ['name']);
10309
+ if (fromName != null) {
10310
+ setValueByPath(toObject, ['name'], fromName);
10311
+ }
10312
+ return toObject;
10313
+ }
9862
10314
  function partFromVertex$1(fromObject) {
9863
10315
  const toObject = {};
9864
10316
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -9885,6 +10337,10 @@ function partFromVertex$1(fromObject) {
9885
10337
  if (fromThoughtSignature != null) {
9886
10338
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
9887
10339
  }
10340
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10341
+ if (fromFunctionCall != null) {
10342
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex$1(fromFunctionCall));
10343
+ }
9888
10344
  const fromCodeExecutionResult = getValueByPath(fromObject, [
9889
10345
  'codeExecutionResult',
9890
10346
  ]);
@@ -9897,10 +10353,6 @@ function partFromVertex$1(fromObject) {
9897
10353
  if (fromExecutableCode != null) {
9898
10354
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
9899
10355
  }
9900
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
9901
- if (fromFunctionCall != null) {
9902
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
9903
- }
9904
10356
  const fromFunctionResponse = getValueByPath(fromObject, [
9905
10357
  'functionResponse',
9906
10358
  ]);
@@ -9983,18 +10435,6 @@ function liveServerContentFromVertex(fromObject) {
9983
10435
  }
9984
10436
  return toObject;
9985
10437
  }
9986
- function functionCallFromVertex(fromObject) {
9987
- const toObject = {};
9988
- const fromArgs = getValueByPath(fromObject, ['args']);
9989
- if (fromArgs != null) {
9990
- setValueByPath(toObject, ['args'], fromArgs);
9991
- }
9992
- const fromName = getValueByPath(fromObject, ['name']);
9993
- if (fromName != null) {
9994
- setValueByPath(toObject, ['name'], fromName);
9995
- }
9996
- return toObject;
9997
- }
9998
10438
  function liveServerToolCallFromVertex(fromObject) {
9999
10439
  const toObject = {};
10000
10440
  const fromFunctionCalls = getValueByPath(fromObject, [
@@ -10004,7 +10444,7 @@ function liveServerToolCallFromVertex(fromObject) {
10004
10444
  let transformedList = fromFunctionCalls;
10005
10445
  if (Array.isArray(transformedList)) {
10006
10446
  transformedList = transformedList.map((item) => {
10007
- return functionCallFromVertex(item);
10447
+ return functionCallFromVertex$1(item);
10008
10448
  });
10009
10449
  }
10010
10450
  setValueByPath(toObject, ['functionCalls'], transformedList);
@@ -10243,6 +10683,22 @@ function fileDataToMldev$1(fromObject) {
10243
10683
  }
10244
10684
  return toObject;
10245
10685
  }
10686
+ function functionCallToMldev$1(fromObject) {
10687
+ const toObject = {};
10688
+ const fromId = getValueByPath(fromObject, ['id']);
10689
+ if (fromId != null) {
10690
+ setValueByPath(toObject, ['id'], fromId);
10691
+ }
10692
+ const fromArgs = getValueByPath(fromObject, ['args']);
10693
+ if (fromArgs != null) {
10694
+ setValueByPath(toObject, ['args'], fromArgs);
10695
+ }
10696
+ const fromName = getValueByPath(fromObject, ['name']);
10697
+ if (fromName != null) {
10698
+ setValueByPath(toObject, ['name'], fromName);
10699
+ }
10700
+ return toObject;
10701
+ }
10246
10702
  function partToMldev$1(fromObject) {
10247
10703
  const toObject = {};
10248
10704
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -10269,6 +10725,10 @@ function partToMldev$1(fromObject) {
10269
10725
  if (fromThoughtSignature != null) {
10270
10726
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
10271
10727
  }
10728
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10729
+ if (fromFunctionCall != null) {
10730
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev$1(fromFunctionCall));
10731
+ }
10272
10732
  const fromCodeExecutionResult = getValueByPath(fromObject, [
10273
10733
  'codeExecutionResult',
10274
10734
  ]);
@@ -10281,10 +10741,6 @@ function partToMldev$1(fromObject) {
10281
10741
  if (fromExecutableCode != null) {
10282
10742
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
10283
10743
  }
10284
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
10285
- if (fromFunctionCall != null) {
10286
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
10287
- }
10288
10744
  const fromFunctionResponse = getValueByPath(fromObject, [
10289
10745
  'functionResponse',
10290
10746
  ]);
@@ -11307,6 +11763,21 @@ function fileDataToVertex(fromObject) {
11307
11763
  }
11308
11764
  return toObject;
11309
11765
  }
11766
+ function functionCallToVertex(fromObject) {
11767
+ const toObject = {};
11768
+ if (getValueByPath(fromObject, ['id']) !== undefined) {
11769
+ throw new Error('id parameter is not supported in Vertex AI.');
11770
+ }
11771
+ const fromArgs = getValueByPath(fromObject, ['args']);
11772
+ if (fromArgs != null) {
11773
+ setValueByPath(toObject, ['args'], fromArgs);
11774
+ }
11775
+ const fromName = getValueByPath(fromObject, ['name']);
11776
+ if (fromName != null) {
11777
+ setValueByPath(toObject, ['name'], fromName);
11778
+ }
11779
+ return toObject;
11780
+ }
11310
11781
  function partToVertex(fromObject) {
11311
11782
  const toObject = {};
11312
11783
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -11333,6 +11804,10 @@ function partToVertex(fromObject) {
11333
11804
  if (fromThoughtSignature != null) {
11334
11805
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
11335
11806
  }
11807
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11808
+ if (fromFunctionCall != null) {
11809
+ setValueByPath(toObject, ['functionCall'], functionCallToVertex(fromFunctionCall));
11810
+ }
11336
11811
  const fromCodeExecutionResult = getValueByPath(fromObject, [
11337
11812
  'codeExecutionResult',
11338
11813
  ]);
@@ -11345,10 +11820,6 @@ function partToVertex(fromObject) {
11345
11820
  if (fromExecutableCode != null) {
11346
11821
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
11347
11822
  }
11348
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11349
- if (fromFunctionCall != null) {
11350
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
11351
- }
11352
11823
  const fromFunctionResponse = getValueByPath(fromObject, [
11353
11824
  'functionResponse',
11354
11825
  ]);
@@ -12973,6 +13444,22 @@ function fileDataFromMldev(fromObject) {
12973
13444
  }
12974
13445
  return toObject;
12975
13446
  }
13447
+ function functionCallFromMldev(fromObject) {
13448
+ const toObject = {};
13449
+ const fromId = getValueByPath(fromObject, ['id']);
13450
+ if (fromId != null) {
13451
+ setValueByPath(toObject, ['id'], fromId);
13452
+ }
13453
+ const fromArgs = getValueByPath(fromObject, ['args']);
13454
+ if (fromArgs != null) {
13455
+ setValueByPath(toObject, ['args'], fromArgs);
13456
+ }
13457
+ const fromName = getValueByPath(fromObject, ['name']);
13458
+ if (fromName != null) {
13459
+ setValueByPath(toObject, ['name'], fromName);
13460
+ }
13461
+ return toObject;
13462
+ }
12976
13463
  function partFromMldev(fromObject) {
12977
13464
  const toObject = {};
12978
13465
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -12999,6 +13486,10 @@ function partFromMldev(fromObject) {
12999
13486
  if (fromThoughtSignature != null) {
13000
13487
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
13001
13488
  }
13489
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
13490
+ if (fromFunctionCall != null) {
13491
+ setValueByPath(toObject, ['functionCall'], functionCallFromMldev(fromFunctionCall));
13492
+ }
13002
13493
  const fromCodeExecutionResult = getValueByPath(fromObject, [
13003
13494
  'codeExecutionResult',
13004
13495
  ]);
@@ -13011,10 +13502,6 @@ function partFromMldev(fromObject) {
13011
13502
  if (fromExecutableCode != null) {
13012
13503
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
13013
13504
  }
13014
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
13015
- if (fromFunctionCall != null) {
13016
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
13017
- }
13018
13505
  const fromFunctionResponse = getValueByPath(fromObject, [
13019
13506
  'functionResponse',
13020
13507
  ]);
@@ -13537,6 +14024,18 @@ function fileDataFromVertex(fromObject) {
13537
14024
  }
13538
14025
  return toObject;
13539
14026
  }
14027
+ function functionCallFromVertex(fromObject) {
14028
+ const toObject = {};
14029
+ const fromArgs = getValueByPath(fromObject, ['args']);
14030
+ if (fromArgs != null) {
14031
+ setValueByPath(toObject, ['args'], fromArgs);
14032
+ }
14033
+ const fromName = getValueByPath(fromObject, ['name']);
14034
+ if (fromName != null) {
14035
+ setValueByPath(toObject, ['name'], fromName);
14036
+ }
14037
+ return toObject;
14038
+ }
13540
14039
  function partFromVertex(fromObject) {
13541
14040
  const toObject = {};
13542
14041
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -13563,6 +14062,10 @@ function partFromVertex(fromObject) {
13563
14062
  if (fromThoughtSignature != null) {
13564
14063
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
13565
14064
  }
14065
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
14066
+ if (fromFunctionCall != null) {
14067
+ setValueByPath(toObject, ['functionCall'], functionCallFromVertex(fromFunctionCall));
14068
+ }
13566
14069
  const fromCodeExecutionResult = getValueByPath(fromObject, [
13567
14070
  'codeExecutionResult',
13568
14071
  ]);
@@ -13575,10 +14078,6 @@ function partFromVertex(fromObject) {
13575
14078
  if (fromExecutableCode != null) {
13576
14079
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
13577
14080
  }
13578
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
13579
- if (fromFunctionCall != null) {
13580
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
13581
- }
13582
14081
  const fromFunctionResponse = getValueByPath(fromObject, [
13583
14082
  'functionResponse',
13584
14083
  ]);
@@ -17000,6 +17499,22 @@ function fileDataToMldev(fromObject) {
17000
17499
  }
17001
17500
  return toObject;
17002
17501
  }
17502
+ function functionCallToMldev(fromObject) {
17503
+ const toObject = {};
17504
+ const fromId = getValueByPath(fromObject, ['id']);
17505
+ if (fromId != null) {
17506
+ setValueByPath(toObject, ['id'], fromId);
17507
+ }
17508
+ const fromArgs = getValueByPath(fromObject, ['args']);
17509
+ if (fromArgs != null) {
17510
+ setValueByPath(toObject, ['args'], fromArgs);
17511
+ }
17512
+ const fromName = getValueByPath(fromObject, ['name']);
17513
+ if (fromName != null) {
17514
+ setValueByPath(toObject, ['name'], fromName);
17515
+ }
17516
+ return toObject;
17517
+ }
17003
17518
  function partToMldev(fromObject) {
17004
17519
  const toObject = {};
17005
17520
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -17026,6 +17541,10 @@ function partToMldev(fromObject) {
17026
17541
  if (fromThoughtSignature != null) {
17027
17542
  setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
17028
17543
  }
17544
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
17545
+ if (fromFunctionCall != null) {
17546
+ setValueByPath(toObject, ['functionCall'], functionCallToMldev(fromFunctionCall));
17547
+ }
17029
17548
  const fromCodeExecutionResult = getValueByPath(fromObject, [
17030
17549
  'codeExecutionResult',
17031
17550
  ]);
@@ -17038,10 +17557,6 @@ function partToMldev(fromObject) {
17038
17557
  if (fromExecutableCode != null) {
17039
17558
  setValueByPath(toObject, ['executableCode'], fromExecutableCode);
17040
17559
  }
17041
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
17042
- if (fromFunctionCall != null) {
17043
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
17044
- }
17045
17560
  const fromFunctionResponse = getValueByPath(fromObject, [
17046
17561
  'functionResponse',
17047
17562
  ]);
@@ -18856,6 +19371,7 @@ exports.GenerateVideosOperation = GenerateVideosOperation;
18856
19371
  exports.GenerateVideosResponse = GenerateVideosResponse;
18857
19372
  exports.GoogleGenAI = GoogleGenAI;
18858
19373
  exports.HttpResponse = HttpResponse;
19374
+ exports.InlinedEmbedContentResponse = InlinedEmbedContentResponse;
18859
19375
  exports.InlinedResponse = InlinedResponse;
18860
19376
  exports.ListBatchJobsResponse = ListBatchJobsResponse;
18861
19377
  exports.ListCachedContentsResponse = ListCachedContentsResponse;
@@ -18876,6 +19392,7 @@ exports.RecontextImageResponse = RecontextImageResponse;
18876
19392
  exports.ReplayResponse = ReplayResponse;
18877
19393
  exports.SegmentImageResponse = SegmentImageResponse;
18878
19394
  exports.Session = Session;
19395
+ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
18879
19396
  exports.StyleReferenceImage = StyleReferenceImage;
18880
19397
  exports.SubjectReferenceImage = SubjectReferenceImage;
18881
19398
  exports.Tokens = Tokens;