@google/genai 1.6.0 → 1.7.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.mjs CHANGED
@@ -530,7 +530,7 @@ var MediaResolution;
530
530
  */
531
531
  MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
532
532
  })(MediaResolution || (MediaResolution = {}));
533
- /** Output only. The detailed state of the job. */
533
+ /** Job state. */
534
534
  var JobState;
535
535
  (function (JobState) {
536
536
  /**
@@ -574,7 +574,7 @@ var JobState;
574
574
  */
575
575
  JobState["JOB_STATE_EXPIRED"] = "JOB_STATE_EXPIRED";
576
576
  /**
577
- * The job is being updated. Only jobs in the `RUNNING` state can be updated. After updating, the job goes back to the `RUNNING` state.
577
+ * The job is being updated. Only jobs in the `JOB_STATE_RUNNING` state can be updated. After updating, the job goes back to the `JOB_STATE_RUNNING` state.
578
578
  */
579
579
  JobState["JOB_STATE_UPDATING"] = "JOB_STATE_UPDATING";
580
580
  /**
@@ -697,8 +697,17 @@ var SafetyFilterLevel;
697
697
  /** Enum that controls the generation of people. */
698
698
  var PersonGeneration;
699
699
  (function (PersonGeneration) {
700
+ /**
701
+ * Block generation of images of people.
702
+ */
700
703
  PersonGeneration["DONT_ALLOW"] = "DONT_ALLOW";
704
+ /**
705
+ * Generate images of adults, but not children.
706
+ */
701
707
  PersonGeneration["ALLOW_ADULT"] = "ALLOW_ADULT";
708
+ /**
709
+ * Generate images that include adults and children.
710
+ */
702
711
  PersonGeneration["ALLOW_ALL"] = "ALLOW_ALL";
703
712
  })(PersonGeneration || (PersonGeneration = {}));
704
713
  /** Enum that specifies the language of the text in the prompt. */
@@ -747,6 +756,20 @@ var EditMode;
747
756
  EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
748
757
  EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
749
758
  })(EditMode || (EditMode = {}));
759
+ /** Enum that controls the compression quality of the generated videos. */
760
+ var VideoCompressionQuality;
761
+ (function (VideoCompressionQuality) {
762
+ /**
763
+ * Optimized video compression quality. This will produce videos
764
+ with a compressed, smaller file size.
765
+ */
766
+ VideoCompressionQuality["OPTIMIZED"] = "OPTIMIZED";
767
+ /**
768
+ * Lossless video compression quality. This will produce videos
769
+ with a larger file size.
770
+ */
771
+ VideoCompressionQuality["LOSSLESS"] = "LOSSLESS";
772
+ })(VideoCompressionQuality || (VideoCompressionQuality = {}));
750
773
  /** State for the lifecycle of a File. */
751
774
  var FileState;
752
775
  (function (FileState) {
@@ -1383,6 +1406,12 @@ class CreateFileResponse {
1383
1406
  /** Response for the delete file method. */
1384
1407
  class DeleteFileResponse {
1385
1408
  }
1409
+ /** Config for `inlined_responses` parameter. */
1410
+ class InlinedResponse {
1411
+ }
1412
+ /** Config for batches.list return value. */
1413
+ class ListBatchJobsResponse {
1414
+ }
1386
1415
  /** Represents a single response in a replay. */
1387
1416
  class ReplayResponse {
1388
1417
  }
@@ -2373,17 +2402,1966 @@ function filterToJsonSchema(schema) {
2373
2402
  else if (dictSchemaFieldNames.has(fieldName)) {
2374
2403
  filteredSchema[fieldName] = filterDictSchemaField(fieldValue);
2375
2404
  }
2376
- else if (fieldName === 'type') {
2377
- const typeValue = fieldValue.toUpperCase();
2378
- filteredSchema[fieldName] = Object.values(Type).includes(typeValue)
2379
- ? typeValue
2380
- : Type.TYPE_UNSPECIFIED;
2405
+ else if (fieldName === 'type') {
2406
+ const typeValue = fieldValue.toUpperCase();
2407
+ filteredSchema[fieldName] = Object.values(Type).includes(typeValue)
2408
+ ? typeValue
2409
+ : Type.TYPE_UNSPECIFIED;
2410
+ }
2411
+ else if (supportedJsonSchemaFields.has(fieldName)) {
2412
+ filteredSchema[fieldName] = fieldValue;
2413
+ }
2414
+ }
2415
+ return filteredSchema;
2416
+ }
2417
+ // Transforms a source input into a BatchJobSource object with validation.
2418
+ function tBatchJobSource(apiClient, src) {
2419
+ if (typeof src !== 'string' && !Array.isArray(src)) {
2420
+ if (apiClient && apiClient.isVertexAI()) {
2421
+ if (src.gcsUri && src.bigqueryUri) {
2422
+ throw new Error('Only one of `gcsUri` or `bigqueryUri` can be set.');
2423
+ }
2424
+ else if (!src.gcsUri && !src.bigqueryUri) {
2425
+ throw new Error('One of `gcsUri` or `bigqueryUri` must be set.');
2426
+ }
2427
+ }
2428
+ else {
2429
+ // Logic for non-Vertex AI client (inlined_requests, file_name)
2430
+ if (src.inlinedRequests && src.fileName) {
2431
+ throw new Error('Only one of `inlinedRequests` or `fileName` can be set.');
2432
+ }
2433
+ else if (!src.inlinedRequests && !src.fileName) {
2434
+ throw new Error('One of `inlinedRequests` or `fileName` must be set.');
2435
+ }
2436
+ }
2437
+ return src;
2438
+ }
2439
+ // If src is an array (list in Python)
2440
+ else if (Array.isArray(src)) {
2441
+ return { inlinedRequests: src };
2442
+ }
2443
+ else if (typeof src === 'string') {
2444
+ if (src.startsWith('gs://')) {
2445
+ return {
2446
+ format: 'jsonl',
2447
+ gcsUri: [src], // GCS URI is expected as an array
2448
+ };
2449
+ }
2450
+ else if (src.startsWith('bq://')) {
2451
+ return {
2452
+ format: 'bigquery',
2453
+ bigqueryUri: src,
2454
+ };
2455
+ }
2456
+ else if (src.startsWith('files/')) {
2457
+ return {
2458
+ fileName: src,
2459
+ };
2460
+ }
2461
+ }
2462
+ throw new Error(`Unsupported source: ${src}`);
2463
+ }
2464
+ function tBatchJobDestination(dest) {
2465
+ const destString = dest;
2466
+ if (destString.startsWith('gs://')) {
2467
+ return {
2468
+ format: 'jsonl',
2469
+ gcsUri: destString,
2470
+ };
2471
+ }
2472
+ else if (destString.startsWith('bq://')) {
2473
+ return {
2474
+ format: 'bigquery',
2475
+ bigqueryUri: destString,
2476
+ };
2477
+ }
2478
+ else {
2479
+ throw new Error(`Unsupported destination: ${destString}`);
2480
+ }
2481
+ }
2482
+ function tBatchJobName(apiClient, name) {
2483
+ const nameString = name;
2484
+ if (!apiClient.isVertexAI()) {
2485
+ const mldevPattern = /batches\/[^/]+$/;
2486
+ if (mldevPattern.test(nameString)) {
2487
+ return nameString.split('/').pop();
2488
+ }
2489
+ else {
2490
+ throw new Error(`Invalid batch job name: ${nameString}.`);
2491
+ }
2492
+ }
2493
+ const vertexPattern = /^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/;
2494
+ if (vertexPattern.test(nameString)) {
2495
+ return nameString.split('/').pop();
2496
+ }
2497
+ else if (/^\d+$/.test(nameString)) {
2498
+ return nameString;
2499
+ }
2500
+ else {
2501
+ throw new Error(`Invalid batch job name: ${nameString}.`);
2502
+ }
2503
+ }
2504
+ function tJobState(state) {
2505
+ const stateString = state;
2506
+ if (stateString === 'BATCH_STATE_UNSPECIFIED') {
2507
+ return 'JOB_STATE_UNSPECIFIED';
2508
+ }
2509
+ else if (stateString === 'BATCH_STATE_PENDING') {
2510
+ return 'JOB_STATE_PENDING';
2511
+ }
2512
+ else if (stateString === 'BATCH_STATE_SUCCEEDED') {
2513
+ return 'JOB_STATE_SUCCEEDED';
2514
+ }
2515
+ else if (stateString === 'BATCH_STATE_FAILED') {
2516
+ return 'JOB_STATE_FAILED';
2517
+ }
2518
+ else if (stateString === 'BATCH_STATE_CANCELLED') {
2519
+ return 'JOB_STATE_CANCELLED';
2520
+ }
2521
+ else {
2522
+ return stateString;
2523
+ }
2524
+ }
2525
+
2526
+ /**
2527
+ * @license
2528
+ * Copyright 2025 Google LLC
2529
+ * SPDX-License-Identifier: Apache-2.0
2530
+ */
2531
+ function videoMetadataToMldev$4(fromObject) {
2532
+ const toObject = {};
2533
+ const fromFps = getValueByPath(fromObject, ['fps']);
2534
+ if (fromFps != null) {
2535
+ setValueByPath(toObject, ['fps'], fromFps);
2536
+ }
2537
+ const fromEndOffset = getValueByPath(fromObject, ['endOffset']);
2538
+ if (fromEndOffset != null) {
2539
+ setValueByPath(toObject, ['endOffset'], fromEndOffset);
2540
+ }
2541
+ const fromStartOffset = getValueByPath(fromObject, ['startOffset']);
2542
+ if (fromStartOffset != null) {
2543
+ setValueByPath(toObject, ['startOffset'], fromStartOffset);
2544
+ }
2545
+ return toObject;
2546
+ }
2547
+ function blobToMldev$4(fromObject) {
2548
+ const toObject = {};
2549
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
2550
+ throw new Error('displayName parameter is not supported in Gemini API.');
2551
+ }
2552
+ const fromData = getValueByPath(fromObject, ['data']);
2553
+ if (fromData != null) {
2554
+ setValueByPath(toObject, ['data'], fromData);
2555
+ }
2556
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
2557
+ if (fromMimeType != null) {
2558
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
2559
+ }
2560
+ return toObject;
2561
+ }
2562
+ function fileDataToMldev$4(fromObject) {
2563
+ const toObject = {};
2564
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
2565
+ throw new Error('displayName parameter is not supported in Gemini API.');
2566
+ }
2567
+ const fromFileUri = getValueByPath(fromObject, ['fileUri']);
2568
+ if (fromFileUri != null) {
2569
+ setValueByPath(toObject, ['fileUri'], fromFileUri);
2570
+ }
2571
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
2572
+ if (fromMimeType != null) {
2573
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
2574
+ }
2575
+ return toObject;
2576
+ }
2577
+ function partToMldev$4(fromObject) {
2578
+ const toObject = {};
2579
+ const fromVideoMetadata = getValueByPath(fromObject, [
2580
+ 'videoMetadata',
2581
+ ]);
2582
+ if (fromVideoMetadata != null) {
2583
+ setValueByPath(toObject, ['videoMetadata'], videoMetadataToMldev$4(fromVideoMetadata));
2584
+ }
2585
+ const fromThought = getValueByPath(fromObject, ['thought']);
2586
+ if (fromThought != null) {
2587
+ setValueByPath(toObject, ['thought'], fromThought);
2588
+ }
2589
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
2590
+ if (fromInlineData != null) {
2591
+ setValueByPath(toObject, ['inlineData'], blobToMldev$4(fromInlineData));
2592
+ }
2593
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
2594
+ if (fromFileData != null) {
2595
+ setValueByPath(toObject, ['fileData'], fileDataToMldev$4(fromFileData));
2596
+ }
2597
+ const fromThoughtSignature = getValueByPath(fromObject, [
2598
+ 'thoughtSignature',
2599
+ ]);
2600
+ if (fromThoughtSignature != null) {
2601
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
2602
+ }
2603
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
2604
+ 'codeExecutionResult',
2605
+ ]);
2606
+ if (fromCodeExecutionResult != null) {
2607
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
2608
+ }
2609
+ const fromExecutableCode = getValueByPath(fromObject, [
2610
+ 'executableCode',
2611
+ ]);
2612
+ if (fromExecutableCode != null) {
2613
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
2614
+ }
2615
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2616
+ if (fromFunctionCall != null) {
2617
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
2618
+ }
2619
+ const fromFunctionResponse = getValueByPath(fromObject, [
2620
+ 'functionResponse',
2621
+ ]);
2622
+ if (fromFunctionResponse != null) {
2623
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
2624
+ }
2625
+ const fromText = getValueByPath(fromObject, ['text']);
2626
+ if (fromText != null) {
2627
+ setValueByPath(toObject, ['text'], fromText);
2628
+ }
2629
+ return toObject;
2630
+ }
2631
+ function contentToMldev$4(fromObject) {
2632
+ const toObject = {};
2633
+ const fromParts = getValueByPath(fromObject, ['parts']);
2634
+ if (fromParts != null) {
2635
+ let transformedList = fromParts;
2636
+ if (Array.isArray(transformedList)) {
2637
+ transformedList = transformedList.map((item) => {
2638
+ return partToMldev$4(item);
2639
+ });
2640
+ }
2641
+ setValueByPath(toObject, ['parts'], transformedList);
2642
+ }
2643
+ const fromRole = getValueByPath(fromObject, ['role']);
2644
+ if (fromRole != null) {
2645
+ setValueByPath(toObject, ['role'], fromRole);
2646
+ }
2647
+ return toObject;
2648
+ }
2649
+ function schemaToMldev$1(fromObject) {
2650
+ const toObject = {};
2651
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
2652
+ if (fromAnyOf != null) {
2653
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
2654
+ }
2655
+ const fromDefault = getValueByPath(fromObject, ['default']);
2656
+ if (fromDefault != null) {
2657
+ setValueByPath(toObject, ['default'], fromDefault);
2658
+ }
2659
+ const fromDescription = getValueByPath(fromObject, ['description']);
2660
+ if (fromDescription != null) {
2661
+ setValueByPath(toObject, ['description'], fromDescription);
2662
+ }
2663
+ const fromEnum = getValueByPath(fromObject, ['enum']);
2664
+ if (fromEnum != null) {
2665
+ setValueByPath(toObject, ['enum'], fromEnum);
2666
+ }
2667
+ const fromExample = getValueByPath(fromObject, ['example']);
2668
+ if (fromExample != null) {
2669
+ setValueByPath(toObject, ['example'], fromExample);
2670
+ }
2671
+ const fromFormat = getValueByPath(fromObject, ['format']);
2672
+ if (fromFormat != null) {
2673
+ setValueByPath(toObject, ['format'], fromFormat);
2674
+ }
2675
+ const fromItems = getValueByPath(fromObject, ['items']);
2676
+ if (fromItems != null) {
2677
+ setValueByPath(toObject, ['items'], fromItems);
2678
+ }
2679
+ const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
2680
+ if (fromMaxItems != null) {
2681
+ setValueByPath(toObject, ['maxItems'], fromMaxItems);
2682
+ }
2683
+ const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
2684
+ if (fromMaxLength != null) {
2685
+ setValueByPath(toObject, ['maxLength'], fromMaxLength);
2686
+ }
2687
+ const fromMaxProperties = getValueByPath(fromObject, [
2688
+ 'maxProperties',
2689
+ ]);
2690
+ if (fromMaxProperties != null) {
2691
+ setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
2692
+ }
2693
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
2694
+ if (fromMaximum != null) {
2695
+ setValueByPath(toObject, ['maximum'], fromMaximum);
2696
+ }
2697
+ const fromMinItems = getValueByPath(fromObject, ['minItems']);
2698
+ if (fromMinItems != null) {
2699
+ setValueByPath(toObject, ['minItems'], fromMinItems);
2700
+ }
2701
+ const fromMinLength = getValueByPath(fromObject, ['minLength']);
2702
+ if (fromMinLength != null) {
2703
+ setValueByPath(toObject, ['minLength'], fromMinLength);
2704
+ }
2705
+ const fromMinProperties = getValueByPath(fromObject, [
2706
+ 'minProperties',
2707
+ ]);
2708
+ if (fromMinProperties != null) {
2709
+ setValueByPath(toObject, ['minProperties'], fromMinProperties);
2710
+ }
2711
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
2712
+ if (fromMinimum != null) {
2713
+ setValueByPath(toObject, ['minimum'], fromMinimum);
2714
+ }
2715
+ const fromNullable = getValueByPath(fromObject, ['nullable']);
2716
+ if (fromNullable != null) {
2717
+ setValueByPath(toObject, ['nullable'], fromNullable);
2718
+ }
2719
+ const fromPattern = getValueByPath(fromObject, ['pattern']);
2720
+ if (fromPattern != null) {
2721
+ setValueByPath(toObject, ['pattern'], fromPattern);
2722
+ }
2723
+ const fromProperties = getValueByPath(fromObject, ['properties']);
2724
+ if (fromProperties != null) {
2725
+ setValueByPath(toObject, ['properties'], fromProperties);
2726
+ }
2727
+ const fromPropertyOrdering = getValueByPath(fromObject, [
2728
+ 'propertyOrdering',
2729
+ ]);
2730
+ if (fromPropertyOrdering != null) {
2731
+ setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
2732
+ }
2733
+ const fromRequired = getValueByPath(fromObject, ['required']);
2734
+ if (fromRequired != null) {
2735
+ setValueByPath(toObject, ['required'], fromRequired);
2736
+ }
2737
+ const fromTitle = getValueByPath(fromObject, ['title']);
2738
+ if (fromTitle != null) {
2739
+ setValueByPath(toObject, ['title'], fromTitle);
2740
+ }
2741
+ const fromType = getValueByPath(fromObject, ['type']);
2742
+ if (fromType != null) {
2743
+ setValueByPath(toObject, ['type'], fromType);
2744
+ }
2745
+ return toObject;
2746
+ }
2747
+ function safetySettingToMldev$1(fromObject) {
2748
+ const toObject = {};
2749
+ if (getValueByPath(fromObject, ['method']) !== undefined) {
2750
+ throw new Error('method parameter is not supported in Gemini API.');
2751
+ }
2752
+ const fromCategory = getValueByPath(fromObject, ['category']);
2753
+ if (fromCategory != null) {
2754
+ setValueByPath(toObject, ['category'], fromCategory);
2755
+ }
2756
+ const fromThreshold = getValueByPath(fromObject, ['threshold']);
2757
+ if (fromThreshold != null) {
2758
+ setValueByPath(toObject, ['threshold'], fromThreshold);
2759
+ }
2760
+ return toObject;
2761
+ }
2762
+ function functionDeclarationToMldev$4(fromObject) {
2763
+ const toObject = {};
2764
+ const fromBehavior = getValueByPath(fromObject, ['behavior']);
2765
+ if (fromBehavior != null) {
2766
+ setValueByPath(toObject, ['behavior'], fromBehavior);
2767
+ }
2768
+ const fromDescription = getValueByPath(fromObject, ['description']);
2769
+ if (fromDescription != null) {
2770
+ setValueByPath(toObject, ['description'], fromDescription);
2771
+ }
2772
+ const fromName = getValueByPath(fromObject, ['name']);
2773
+ if (fromName != null) {
2774
+ setValueByPath(toObject, ['name'], fromName);
2775
+ }
2776
+ const fromParameters = getValueByPath(fromObject, ['parameters']);
2777
+ if (fromParameters != null) {
2778
+ setValueByPath(toObject, ['parameters'], fromParameters);
2779
+ }
2780
+ const fromParametersJsonSchema = getValueByPath(fromObject, [
2781
+ 'parametersJsonSchema',
2782
+ ]);
2783
+ if (fromParametersJsonSchema != null) {
2784
+ setValueByPath(toObject, ['parametersJsonSchema'], fromParametersJsonSchema);
2785
+ }
2786
+ const fromResponse = getValueByPath(fromObject, ['response']);
2787
+ if (fromResponse != null) {
2788
+ setValueByPath(toObject, ['response'], fromResponse);
2789
+ }
2790
+ const fromResponseJsonSchema = getValueByPath(fromObject, [
2791
+ 'responseJsonSchema',
2792
+ ]);
2793
+ if (fromResponseJsonSchema != null) {
2794
+ setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
2795
+ }
2796
+ return toObject;
2797
+ }
2798
+ function intervalToMldev$4(fromObject) {
2799
+ const toObject = {};
2800
+ const fromStartTime = getValueByPath(fromObject, ['startTime']);
2801
+ if (fromStartTime != null) {
2802
+ setValueByPath(toObject, ['startTime'], fromStartTime);
2803
+ }
2804
+ const fromEndTime = getValueByPath(fromObject, ['endTime']);
2805
+ if (fromEndTime != null) {
2806
+ setValueByPath(toObject, ['endTime'], fromEndTime);
2807
+ }
2808
+ return toObject;
2809
+ }
2810
+ function googleSearchToMldev$4(fromObject) {
2811
+ const toObject = {};
2812
+ const fromTimeRangeFilter = getValueByPath(fromObject, [
2813
+ 'timeRangeFilter',
2814
+ ]);
2815
+ if (fromTimeRangeFilter != null) {
2816
+ setValueByPath(toObject, ['timeRangeFilter'], intervalToMldev$4(fromTimeRangeFilter));
2817
+ }
2818
+ return toObject;
2819
+ }
2820
+ function dynamicRetrievalConfigToMldev$4(fromObject) {
2821
+ const toObject = {};
2822
+ const fromMode = getValueByPath(fromObject, ['mode']);
2823
+ if (fromMode != null) {
2824
+ setValueByPath(toObject, ['mode'], fromMode);
2825
+ }
2826
+ const fromDynamicThreshold = getValueByPath(fromObject, [
2827
+ 'dynamicThreshold',
2828
+ ]);
2829
+ if (fromDynamicThreshold != null) {
2830
+ setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
2831
+ }
2832
+ return toObject;
2833
+ }
2834
+ function googleSearchRetrievalToMldev$4(fromObject) {
2835
+ const toObject = {};
2836
+ const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
2837
+ 'dynamicRetrievalConfig',
2838
+ ]);
2839
+ if (fromDynamicRetrievalConfig != null) {
2840
+ setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev$4(fromDynamicRetrievalConfig));
2841
+ }
2842
+ return toObject;
2843
+ }
2844
+ function urlContextToMldev$4() {
2845
+ const toObject = {};
2846
+ return toObject;
2847
+ }
2848
+ function toolToMldev$4(fromObject) {
2849
+ const toObject = {};
2850
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
2851
+ 'functionDeclarations',
2852
+ ]);
2853
+ if (fromFunctionDeclarations != null) {
2854
+ let transformedList = fromFunctionDeclarations;
2855
+ if (Array.isArray(transformedList)) {
2856
+ transformedList = transformedList.map((item) => {
2857
+ return functionDeclarationToMldev$4(item);
2858
+ });
2859
+ }
2860
+ setValueByPath(toObject, ['functionDeclarations'], transformedList);
2861
+ }
2862
+ if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
2863
+ throw new Error('retrieval parameter is not supported in Gemini API.');
2864
+ }
2865
+ const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
2866
+ if (fromGoogleSearch != null) {
2867
+ setValueByPath(toObject, ['googleSearch'], googleSearchToMldev$4(fromGoogleSearch));
2868
+ }
2869
+ const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
2870
+ 'googleSearchRetrieval',
2871
+ ]);
2872
+ if (fromGoogleSearchRetrieval != null) {
2873
+ setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$4(fromGoogleSearchRetrieval));
2874
+ }
2875
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
2876
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
2877
+ }
2878
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
2879
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
2880
+ }
2881
+ const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
2882
+ if (fromUrlContext != null) {
2883
+ setValueByPath(toObject, ['urlContext'], urlContextToMldev$4());
2884
+ }
2885
+ const fromCodeExecution = getValueByPath(fromObject, [
2886
+ 'codeExecution',
2887
+ ]);
2888
+ if (fromCodeExecution != null) {
2889
+ setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
2890
+ }
2891
+ return toObject;
2892
+ }
2893
+ function functionCallingConfigToMldev$2(fromObject) {
2894
+ const toObject = {};
2895
+ const fromMode = getValueByPath(fromObject, ['mode']);
2896
+ if (fromMode != null) {
2897
+ setValueByPath(toObject, ['mode'], fromMode);
2898
+ }
2899
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
2900
+ 'allowedFunctionNames',
2901
+ ]);
2902
+ if (fromAllowedFunctionNames != null) {
2903
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
2904
+ }
2905
+ return toObject;
2906
+ }
2907
+ function latLngToMldev$2(fromObject) {
2908
+ const toObject = {};
2909
+ const fromLatitude = getValueByPath(fromObject, ['latitude']);
2910
+ if (fromLatitude != null) {
2911
+ setValueByPath(toObject, ['latitude'], fromLatitude);
2912
+ }
2913
+ const fromLongitude = getValueByPath(fromObject, ['longitude']);
2914
+ if (fromLongitude != null) {
2915
+ setValueByPath(toObject, ['longitude'], fromLongitude);
2916
+ }
2917
+ return toObject;
2918
+ }
2919
+ function retrievalConfigToMldev$2(fromObject) {
2920
+ const toObject = {};
2921
+ const fromLatLng = getValueByPath(fromObject, ['latLng']);
2922
+ if (fromLatLng != null) {
2923
+ setValueByPath(toObject, ['latLng'], latLngToMldev$2(fromLatLng));
2924
+ }
2925
+ const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
2926
+ if (fromLanguageCode != null) {
2927
+ setValueByPath(toObject, ['languageCode'], fromLanguageCode);
2928
+ }
2929
+ return toObject;
2930
+ }
2931
+ function toolConfigToMldev$2(fromObject) {
2932
+ const toObject = {};
2933
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
2934
+ 'functionCallingConfig',
2935
+ ]);
2936
+ if (fromFunctionCallingConfig != null) {
2937
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
2938
+ }
2939
+ const fromRetrievalConfig = getValueByPath(fromObject, [
2940
+ 'retrievalConfig',
2941
+ ]);
2942
+ if (fromRetrievalConfig != null) {
2943
+ setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToMldev$2(fromRetrievalConfig));
2944
+ }
2945
+ return toObject;
2946
+ }
2947
+ function prebuiltVoiceConfigToMldev$3(fromObject) {
2948
+ const toObject = {};
2949
+ const fromVoiceName = getValueByPath(fromObject, ['voiceName']);
2950
+ if (fromVoiceName != null) {
2951
+ setValueByPath(toObject, ['voiceName'], fromVoiceName);
2952
+ }
2953
+ return toObject;
2954
+ }
2955
+ function voiceConfigToMldev$3(fromObject) {
2956
+ const toObject = {};
2957
+ const fromPrebuiltVoiceConfig = getValueByPath(fromObject, [
2958
+ 'prebuiltVoiceConfig',
2959
+ ]);
2960
+ if (fromPrebuiltVoiceConfig != null) {
2961
+ setValueByPath(toObject, ['prebuiltVoiceConfig'], prebuiltVoiceConfigToMldev$3(fromPrebuiltVoiceConfig));
2962
+ }
2963
+ return toObject;
2964
+ }
2965
+ function speakerVoiceConfigToMldev$3(fromObject) {
2966
+ const toObject = {};
2967
+ const fromSpeaker = getValueByPath(fromObject, ['speaker']);
2968
+ if (fromSpeaker != null) {
2969
+ setValueByPath(toObject, ['speaker'], fromSpeaker);
2970
+ }
2971
+ const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
2972
+ if (fromVoiceConfig != null) {
2973
+ setValueByPath(toObject, ['voiceConfig'], voiceConfigToMldev$3(fromVoiceConfig));
2974
+ }
2975
+ return toObject;
2976
+ }
2977
+ function multiSpeakerVoiceConfigToMldev$3(fromObject) {
2978
+ const toObject = {};
2979
+ const fromSpeakerVoiceConfigs = getValueByPath(fromObject, [
2980
+ 'speakerVoiceConfigs',
2981
+ ]);
2982
+ if (fromSpeakerVoiceConfigs != null) {
2983
+ let transformedList = fromSpeakerVoiceConfigs;
2984
+ if (Array.isArray(transformedList)) {
2985
+ transformedList = transformedList.map((item) => {
2986
+ return speakerVoiceConfigToMldev$3(item);
2987
+ });
2988
+ }
2989
+ setValueByPath(toObject, ['speakerVoiceConfigs'], transformedList);
2990
+ }
2991
+ return toObject;
2992
+ }
2993
+ function speechConfigToMldev$3(fromObject) {
2994
+ const toObject = {};
2995
+ const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
2996
+ if (fromVoiceConfig != null) {
2997
+ setValueByPath(toObject, ['voiceConfig'], voiceConfigToMldev$3(fromVoiceConfig));
2998
+ }
2999
+ const fromMultiSpeakerVoiceConfig = getValueByPath(fromObject, [
3000
+ 'multiSpeakerVoiceConfig',
3001
+ ]);
3002
+ if (fromMultiSpeakerVoiceConfig != null) {
3003
+ setValueByPath(toObject, ['multiSpeakerVoiceConfig'], multiSpeakerVoiceConfigToMldev$3(fromMultiSpeakerVoiceConfig));
3004
+ }
3005
+ const fromLanguageCode = getValueByPath(fromObject, ['languageCode']);
3006
+ if (fromLanguageCode != null) {
3007
+ setValueByPath(toObject, ['languageCode'], fromLanguageCode);
3008
+ }
3009
+ return toObject;
3010
+ }
3011
+ function thinkingConfigToMldev$1(fromObject) {
3012
+ const toObject = {};
3013
+ const fromIncludeThoughts = getValueByPath(fromObject, [
3014
+ 'includeThoughts',
3015
+ ]);
3016
+ if (fromIncludeThoughts != null) {
3017
+ setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
3018
+ }
3019
+ const fromThinkingBudget = getValueByPath(fromObject, [
3020
+ 'thinkingBudget',
3021
+ ]);
3022
+ if (fromThinkingBudget != null) {
3023
+ setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
3024
+ }
3025
+ return toObject;
3026
+ }
3027
+ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
3028
+ const toObject = {};
3029
+ const fromSystemInstruction = getValueByPath(fromObject, [
3030
+ 'systemInstruction',
3031
+ ]);
3032
+ if (parentObject !== undefined && fromSystemInstruction != null) {
3033
+ setValueByPath(parentObject, ['systemInstruction'], contentToMldev$4(tContent(fromSystemInstruction)));
3034
+ }
3035
+ const fromTemperature = getValueByPath(fromObject, ['temperature']);
3036
+ if (fromTemperature != null) {
3037
+ setValueByPath(toObject, ['temperature'], fromTemperature);
3038
+ }
3039
+ const fromTopP = getValueByPath(fromObject, ['topP']);
3040
+ if (fromTopP != null) {
3041
+ setValueByPath(toObject, ['topP'], fromTopP);
3042
+ }
3043
+ const fromTopK = getValueByPath(fromObject, ['topK']);
3044
+ if (fromTopK != null) {
3045
+ setValueByPath(toObject, ['topK'], fromTopK);
3046
+ }
3047
+ const fromCandidateCount = getValueByPath(fromObject, [
3048
+ 'candidateCount',
3049
+ ]);
3050
+ if (fromCandidateCount != null) {
3051
+ setValueByPath(toObject, ['candidateCount'], fromCandidateCount);
3052
+ }
3053
+ const fromMaxOutputTokens = getValueByPath(fromObject, [
3054
+ 'maxOutputTokens',
3055
+ ]);
3056
+ if (fromMaxOutputTokens != null) {
3057
+ setValueByPath(toObject, ['maxOutputTokens'], fromMaxOutputTokens);
3058
+ }
3059
+ const fromStopSequences = getValueByPath(fromObject, [
3060
+ 'stopSequences',
3061
+ ]);
3062
+ if (fromStopSequences != null) {
3063
+ setValueByPath(toObject, ['stopSequences'], fromStopSequences);
3064
+ }
3065
+ const fromResponseLogprobs = getValueByPath(fromObject, [
3066
+ 'responseLogprobs',
3067
+ ]);
3068
+ if (fromResponseLogprobs != null) {
3069
+ setValueByPath(toObject, ['responseLogprobs'], fromResponseLogprobs);
3070
+ }
3071
+ const fromLogprobs = getValueByPath(fromObject, ['logprobs']);
3072
+ if (fromLogprobs != null) {
3073
+ setValueByPath(toObject, ['logprobs'], fromLogprobs);
3074
+ }
3075
+ const fromPresencePenalty = getValueByPath(fromObject, [
3076
+ 'presencePenalty',
3077
+ ]);
3078
+ if (fromPresencePenalty != null) {
3079
+ setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
3080
+ }
3081
+ const fromFrequencyPenalty = getValueByPath(fromObject, [
3082
+ 'frequencyPenalty',
3083
+ ]);
3084
+ if (fromFrequencyPenalty != null) {
3085
+ setValueByPath(toObject, ['frequencyPenalty'], fromFrequencyPenalty);
3086
+ }
3087
+ const fromSeed = getValueByPath(fromObject, ['seed']);
3088
+ if (fromSeed != null) {
3089
+ setValueByPath(toObject, ['seed'], fromSeed);
3090
+ }
3091
+ const fromResponseMimeType = getValueByPath(fromObject, [
3092
+ 'responseMimeType',
3093
+ ]);
3094
+ if (fromResponseMimeType != null) {
3095
+ setValueByPath(toObject, ['responseMimeType'], fromResponseMimeType);
3096
+ }
3097
+ const fromResponseSchema = getValueByPath(fromObject, [
3098
+ 'responseSchema',
3099
+ ]);
3100
+ if (fromResponseSchema != null) {
3101
+ setValueByPath(toObject, ['responseSchema'], schemaToMldev$1(tSchema(fromResponseSchema)));
3102
+ }
3103
+ const fromResponseJsonSchema = getValueByPath(fromObject, [
3104
+ 'responseJsonSchema',
3105
+ ]);
3106
+ if (fromResponseJsonSchema != null) {
3107
+ setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
3108
+ }
3109
+ if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
3110
+ throw new Error('routingConfig parameter is not supported in Gemini API.');
3111
+ }
3112
+ if (getValueByPath(fromObject, ['modelSelectionConfig']) !== undefined) {
3113
+ throw new Error('modelSelectionConfig parameter is not supported in Gemini API.');
3114
+ }
3115
+ const fromSafetySettings = getValueByPath(fromObject, [
3116
+ 'safetySettings',
3117
+ ]);
3118
+ if (parentObject !== undefined && fromSafetySettings != null) {
3119
+ let transformedList = fromSafetySettings;
3120
+ if (Array.isArray(transformedList)) {
3121
+ transformedList = transformedList.map((item) => {
3122
+ return safetySettingToMldev$1(item);
3123
+ });
3124
+ }
3125
+ setValueByPath(parentObject, ['safetySettings'], transformedList);
3126
+ }
3127
+ const fromTools = getValueByPath(fromObject, ['tools']);
3128
+ if (parentObject !== undefined && fromTools != null) {
3129
+ let transformedList = tTools(fromTools);
3130
+ if (Array.isArray(transformedList)) {
3131
+ transformedList = transformedList.map((item) => {
3132
+ return toolToMldev$4(tTool(item));
3133
+ });
3134
+ }
3135
+ setValueByPath(parentObject, ['tools'], transformedList);
3136
+ }
3137
+ const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
3138
+ if (parentObject !== undefined && fromToolConfig != null) {
3139
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev$2(fromToolConfig));
3140
+ }
3141
+ if (getValueByPath(fromObject, ['labels']) !== undefined) {
3142
+ throw new Error('labels parameter is not supported in Gemini API.');
3143
+ }
3144
+ const fromCachedContent = getValueByPath(fromObject, [
3145
+ 'cachedContent',
3146
+ ]);
3147
+ if (parentObject !== undefined && fromCachedContent != null) {
3148
+ setValueByPath(parentObject, ['cachedContent'], tCachedContentName(apiClient, fromCachedContent));
3149
+ }
3150
+ const fromResponseModalities = getValueByPath(fromObject, [
3151
+ 'responseModalities',
3152
+ ]);
3153
+ if (fromResponseModalities != null) {
3154
+ setValueByPath(toObject, ['responseModalities'], fromResponseModalities);
3155
+ }
3156
+ const fromMediaResolution = getValueByPath(fromObject, [
3157
+ 'mediaResolution',
3158
+ ]);
3159
+ if (fromMediaResolution != null) {
3160
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
3161
+ }
3162
+ const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
3163
+ if (fromSpeechConfig != null) {
3164
+ setValueByPath(toObject, ['speechConfig'], speechConfigToMldev$3(tSpeechConfig(fromSpeechConfig)));
3165
+ }
3166
+ if (getValueByPath(fromObject, ['audioTimestamp']) !== undefined) {
3167
+ throw new Error('audioTimestamp parameter is not supported in Gemini API.');
3168
+ }
3169
+ const fromThinkingConfig = getValueByPath(fromObject, [
3170
+ 'thinkingConfig',
3171
+ ]);
3172
+ if (fromThinkingConfig != null) {
3173
+ setValueByPath(toObject, ['thinkingConfig'], thinkingConfigToMldev$1(fromThinkingConfig));
3174
+ }
3175
+ return toObject;
3176
+ }
3177
+ function inlinedRequestToMldev(apiClient, fromObject) {
3178
+ const toObject = {};
3179
+ const fromModel = getValueByPath(fromObject, ['model']);
3180
+ if (fromModel != null) {
3181
+ setValueByPath(toObject, ['request', 'model'], tModel(apiClient, fromModel));
3182
+ }
3183
+ const fromContents = getValueByPath(fromObject, ['contents']);
3184
+ if (fromContents != null) {
3185
+ let transformedList = tContents(fromContents);
3186
+ if (Array.isArray(transformedList)) {
3187
+ transformedList = transformedList.map((item) => {
3188
+ return contentToMldev$4(item);
3189
+ });
3190
+ }
3191
+ setValueByPath(toObject, ['request', 'contents'], transformedList);
3192
+ }
3193
+ const fromConfig = getValueByPath(fromObject, ['config']);
3194
+ if (fromConfig != null) {
3195
+ setValueByPath(toObject, ['request', 'generationConfig'], generateContentConfigToMldev$1(apiClient, fromConfig, toObject));
3196
+ }
3197
+ return toObject;
3198
+ }
3199
+ function batchJobSourceToMldev(apiClient, fromObject) {
3200
+ const toObject = {};
3201
+ if (getValueByPath(fromObject, ['format']) !== undefined) {
3202
+ throw new Error('format parameter is not supported in Gemini API.');
3203
+ }
3204
+ if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
3205
+ throw new Error('gcsUri parameter is not supported in Gemini API.');
3206
+ }
3207
+ if (getValueByPath(fromObject, ['bigqueryUri']) !== undefined) {
3208
+ throw new Error('bigqueryUri parameter is not supported in Gemini API.');
3209
+ }
3210
+ const fromFileName = getValueByPath(fromObject, ['fileName']);
3211
+ if (fromFileName != null) {
3212
+ setValueByPath(toObject, ['fileName'], fromFileName);
3213
+ }
3214
+ const fromInlinedRequests = getValueByPath(fromObject, [
3215
+ 'inlinedRequests',
3216
+ ]);
3217
+ if (fromInlinedRequests != null) {
3218
+ let transformedList = fromInlinedRequests;
3219
+ if (Array.isArray(transformedList)) {
3220
+ transformedList = transformedList.map((item) => {
3221
+ return inlinedRequestToMldev(apiClient, item);
3222
+ });
3223
+ }
3224
+ setValueByPath(toObject, ['requests', 'requests'], transformedList);
3225
+ }
3226
+ return toObject;
3227
+ }
3228
+ function createBatchJobConfigToMldev(fromObject, parentObject) {
3229
+ const toObject = {};
3230
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3231
+ if (parentObject !== undefined && fromDisplayName != null) {
3232
+ setValueByPath(parentObject, ['batch', 'displayName'], fromDisplayName);
3233
+ }
3234
+ if (getValueByPath(fromObject, ['dest']) !== undefined) {
3235
+ throw new Error('dest parameter is not supported in Gemini API.');
3236
+ }
3237
+ return toObject;
3238
+ }
3239
+ function createBatchJobParametersToMldev(apiClient, fromObject) {
3240
+ const toObject = {};
3241
+ const fromModel = getValueByPath(fromObject, ['model']);
3242
+ if (fromModel != null) {
3243
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3244
+ }
3245
+ const fromSrc = getValueByPath(fromObject, ['src']);
3246
+ if (fromSrc != null) {
3247
+ setValueByPath(toObject, ['batch', 'inputConfig'], batchJobSourceToMldev(apiClient, tBatchJobSource(apiClient, fromSrc)));
3248
+ }
3249
+ const fromConfig = getValueByPath(fromObject, ['config']);
3250
+ if (fromConfig != null) {
3251
+ setValueByPath(toObject, ['config'], createBatchJobConfigToMldev(fromConfig, toObject));
3252
+ }
3253
+ return toObject;
3254
+ }
3255
+ function getBatchJobParametersToMldev(apiClient, fromObject) {
3256
+ const toObject = {};
3257
+ const fromName = getValueByPath(fromObject, ['name']);
3258
+ if (fromName != null) {
3259
+ setValueByPath(toObject, ['_url', 'name'], tBatchJobName(apiClient, fromName));
3260
+ }
3261
+ const fromConfig = getValueByPath(fromObject, ['config']);
3262
+ if (fromConfig != null) {
3263
+ setValueByPath(toObject, ['config'], fromConfig);
3264
+ }
3265
+ return toObject;
3266
+ }
3267
+ function cancelBatchJobParametersToMldev(apiClient, fromObject) {
3268
+ const toObject = {};
3269
+ const fromName = getValueByPath(fromObject, ['name']);
3270
+ if (fromName != null) {
3271
+ setValueByPath(toObject, ['_url', 'name'], tBatchJobName(apiClient, fromName));
3272
+ }
3273
+ const fromConfig = getValueByPath(fromObject, ['config']);
3274
+ if (fromConfig != null) {
3275
+ setValueByPath(toObject, ['config'], fromConfig);
3276
+ }
3277
+ return toObject;
3278
+ }
3279
+ function listBatchJobsConfigToMldev(fromObject, parentObject) {
3280
+ const toObject = {};
3281
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
3282
+ if (parentObject !== undefined && fromPageSize != null) {
3283
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
3284
+ }
3285
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
3286
+ if (parentObject !== undefined && fromPageToken != null) {
3287
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
3288
+ }
3289
+ if (getValueByPath(fromObject, ['filter']) !== undefined) {
3290
+ throw new Error('filter parameter is not supported in Gemini API.');
3291
+ }
3292
+ return toObject;
3293
+ }
3294
+ function listBatchJobsParametersToMldev(fromObject) {
3295
+ const toObject = {};
3296
+ const fromConfig = getValueByPath(fromObject, ['config']);
3297
+ if (fromConfig != null) {
3298
+ setValueByPath(toObject, ['config'], listBatchJobsConfigToMldev(fromConfig, toObject));
3299
+ }
3300
+ return toObject;
3301
+ }
3302
+ function batchJobSourceToVertex(fromObject) {
3303
+ const toObject = {};
3304
+ const fromFormat = getValueByPath(fromObject, ['format']);
3305
+ if (fromFormat != null) {
3306
+ setValueByPath(toObject, ['instancesFormat'], fromFormat);
3307
+ }
3308
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
3309
+ if (fromGcsUri != null) {
3310
+ setValueByPath(toObject, ['gcsSource', 'uris'], fromGcsUri);
3311
+ }
3312
+ const fromBigqueryUri = getValueByPath(fromObject, ['bigqueryUri']);
3313
+ if (fromBigqueryUri != null) {
3314
+ setValueByPath(toObject, ['bigquerySource', 'inputUri'], fromBigqueryUri);
3315
+ }
3316
+ if (getValueByPath(fromObject, ['fileName']) !== undefined) {
3317
+ throw new Error('fileName parameter is not supported in Vertex AI.');
3318
+ }
3319
+ if (getValueByPath(fromObject, ['inlinedRequests']) !== undefined) {
3320
+ throw new Error('inlinedRequests parameter is not supported in Vertex AI.');
3321
+ }
3322
+ return toObject;
3323
+ }
3324
+ function batchJobDestinationToVertex(fromObject) {
3325
+ const toObject = {};
3326
+ const fromFormat = getValueByPath(fromObject, ['format']);
3327
+ if (fromFormat != null) {
3328
+ setValueByPath(toObject, ['predictionsFormat'], fromFormat);
3329
+ }
3330
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
3331
+ if (fromGcsUri != null) {
3332
+ setValueByPath(toObject, ['gcsDestination', 'outputUriPrefix'], fromGcsUri);
3333
+ }
3334
+ const fromBigqueryUri = getValueByPath(fromObject, ['bigqueryUri']);
3335
+ if (fromBigqueryUri != null) {
3336
+ setValueByPath(toObject, ['bigqueryDestination', 'outputUri'], fromBigqueryUri);
3337
+ }
3338
+ if (getValueByPath(fromObject, ['fileName']) !== undefined) {
3339
+ throw new Error('fileName parameter is not supported in Vertex AI.');
3340
+ }
3341
+ if (getValueByPath(fromObject, ['inlinedResponses']) !== undefined) {
3342
+ throw new Error('inlinedResponses parameter is not supported in Vertex AI.');
3343
+ }
3344
+ return toObject;
3345
+ }
3346
+ function createBatchJobConfigToVertex(fromObject, parentObject) {
3347
+ const toObject = {};
3348
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3349
+ if (parentObject !== undefined && fromDisplayName != null) {
3350
+ setValueByPath(parentObject, ['displayName'], fromDisplayName);
3351
+ }
3352
+ const fromDest = getValueByPath(fromObject, ['dest']);
3353
+ if (parentObject !== undefined && fromDest != null) {
3354
+ setValueByPath(parentObject, ['outputConfig'], batchJobDestinationToVertex(tBatchJobDestination(fromDest)));
3355
+ }
3356
+ return toObject;
3357
+ }
3358
+ function createBatchJobParametersToVertex(apiClient, fromObject) {
3359
+ const toObject = {};
3360
+ const fromModel = getValueByPath(fromObject, ['model']);
3361
+ if (fromModel != null) {
3362
+ setValueByPath(toObject, ['model'], tModel(apiClient, fromModel));
3363
+ }
3364
+ const fromSrc = getValueByPath(fromObject, ['src']);
3365
+ if (fromSrc != null) {
3366
+ setValueByPath(toObject, ['inputConfig'], batchJobSourceToVertex(tBatchJobSource(apiClient, fromSrc)));
3367
+ }
3368
+ const fromConfig = getValueByPath(fromObject, ['config']);
3369
+ if (fromConfig != null) {
3370
+ setValueByPath(toObject, ['config'], createBatchJobConfigToVertex(fromConfig, toObject));
3371
+ }
3372
+ return toObject;
3373
+ }
3374
+ function getBatchJobParametersToVertex(apiClient, fromObject) {
3375
+ const toObject = {};
3376
+ const fromName = getValueByPath(fromObject, ['name']);
3377
+ if (fromName != null) {
3378
+ setValueByPath(toObject, ['_url', 'name'], tBatchJobName(apiClient, fromName));
3379
+ }
3380
+ const fromConfig = getValueByPath(fromObject, ['config']);
3381
+ if (fromConfig != null) {
3382
+ setValueByPath(toObject, ['config'], fromConfig);
3383
+ }
3384
+ return toObject;
3385
+ }
3386
+ function cancelBatchJobParametersToVertex(apiClient, fromObject) {
3387
+ const toObject = {};
3388
+ const fromName = getValueByPath(fromObject, ['name']);
3389
+ if (fromName != null) {
3390
+ setValueByPath(toObject, ['_url', 'name'], tBatchJobName(apiClient, fromName));
3391
+ }
3392
+ const fromConfig = getValueByPath(fromObject, ['config']);
3393
+ if (fromConfig != null) {
3394
+ setValueByPath(toObject, ['config'], fromConfig);
3395
+ }
3396
+ return toObject;
3397
+ }
3398
+ function listBatchJobsConfigToVertex(fromObject, parentObject) {
3399
+ const toObject = {};
3400
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
3401
+ if (parentObject !== undefined && fromPageSize != null) {
3402
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
3403
+ }
3404
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
3405
+ if (parentObject !== undefined && fromPageToken != null) {
3406
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
3407
+ }
3408
+ const fromFilter = getValueByPath(fromObject, ['filter']);
3409
+ if (parentObject !== undefined && fromFilter != null) {
3410
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
3411
+ }
3412
+ return toObject;
3413
+ }
3414
+ function listBatchJobsParametersToVertex(fromObject) {
3415
+ const toObject = {};
3416
+ const fromConfig = getValueByPath(fromObject, ['config']);
3417
+ if (fromConfig != null) {
3418
+ setValueByPath(toObject, ['config'], listBatchJobsConfigToVertex(fromConfig, toObject));
3419
+ }
3420
+ return toObject;
3421
+ }
3422
+ function jobErrorFromMldev() {
3423
+ const toObject = {};
3424
+ return toObject;
3425
+ }
3426
+ function videoMetadataFromMldev$2(fromObject) {
3427
+ const toObject = {};
3428
+ const fromFps = getValueByPath(fromObject, ['fps']);
3429
+ if (fromFps != null) {
3430
+ setValueByPath(toObject, ['fps'], fromFps);
3431
+ }
3432
+ const fromEndOffset = getValueByPath(fromObject, ['endOffset']);
3433
+ if (fromEndOffset != null) {
3434
+ setValueByPath(toObject, ['endOffset'], fromEndOffset);
3435
+ }
3436
+ const fromStartOffset = getValueByPath(fromObject, ['startOffset']);
3437
+ if (fromStartOffset != null) {
3438
+ setValueByPath(toObject, ['startOffset'], fromStartOffset);
3439
+ }
3440
+ return toObject;
3441
+ }
3442
+ function blobFromMldev$2(fromObject) {
3443
+ const toObject = {};
3444
+ const fromData = getValueByPath(fromObject, ['data']);
3445
+ if (fromData != null) {
3446
+ setValueByPath(toObject, ['data'], fromData);
3447
+ }
3448
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3449
+ if (fromMimeType != null) {
3450
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3451
+ }
3452
+ return toObject;
3453
+ }
3454
+ function fileDataFromMldev$2(fromObject) {
3455
+ const toObject = {};
3456
+ const fromFileUri = getValueByPath(fromObject, ['fileUri']);
3457
+ if (fromFileUri != null) {
3458
+ setValueByPath(toObject, ['fileUri'], fromFileUri);
3459
+ }
3460
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3461
+ if (fromMimeType != null) {
3462
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3463
+ }
3464
+ return toObject;
3465
+ }
3466
+ function partFromMldev$2(fromObject) {
3467
+ const toObject = {};
3468
+ const fromVideoMetadata = getValueByPath(fromObject, [
3469
+ 'videoMetadata',
3470
+ ]);
3471
+ if (fromVideoMetadata != null) {
3472
+ setValueByPath(toObject, ['videoMetadata'], videoMetadataFromMldev$2(fromVideoMetadata));
3473
+ }
3474
+ const fromThought = getValueByPath(fromObject, ['thought']);
3475
+ if (fromThought != null) {
3476
+ setValueByPath(toObject, ['thought'], fromThought);
3477
+ }
3478
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3479
+ if (fromInlineData != null) {
3480
+ setValueByPath(toObject, ['inlineData'], blobFromMldev$2(fromInlineData));
3481
+ }
3482
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
3483
+ if (fromFileData != null) {
3484
+ setValueByPath(toObject, ['fileData'], fileDataFromMldev$2(fromFileData));
3485
+ }
3486
+ const fromThoughtSignature = getValueByPath(fromObject, [
3487
+ 'thoughtSignature',
3488
+ ]);
3489
+ if (fromThoughtSignature != null) {
3490
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
3491
+ }
3492
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
3493
+ 'codeExecutionResult',
3494
+ ]);
3495
+ if (fromCodeExecutionResult != null) {
3496
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
3497
+ }
3498
+ const fromExecutableCode = getValueByPath(fromObject, [
3499
+ 'executableCode',
3500
+ ]);
3501
+ if (fromExecutableCode != null) {
3502
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
3503
+ }
3504
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3505
+ if (fromFunctionCall != null) {
3506
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
3507
+ }
3508
+ const fromFunctionResponse = getValueByPath(fromObject, [
3509
+ 'functionResponse',
3510
+ ]);
3511
+ if (fromFunctionResponse != null) {
3512
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
3513
+ }
3514
+ const fromText = getValueByPath(fromObject, ['text']);
3515
+ if (fromText != null) {
3516
+ setValueByPath(toObject, ['text'], fromText);
3517
+ }
3518
+ return toObject;
3519
+ }
3520
+ function contentFromMldev$2(fromObject) {
3521
+ const toObject = {};
3522
+ const fromParts = getValueByPath(fromObject, ['parts']);
3523
+ if (fromParts != null) {
3524
+ let transformedList = fromParts;
3525
+ if (Array.isArray(transformedList)) {
3526
+ transformedList = transformedList.map((item) => {
3527
+ return partFromMldev$2(item);
3528
+ });
3529
+ }
3530
+ setValueByPath(toObject, ['parts'], transformedList);
3531
+ }
3532
+ const fromRole = getValueByPath(fromObject, ['role']);
3533
+ if (fromRole != null) {
3534
+ setValueByPath(toObject, ['role'], fromRole);
3535
+ }
3536
+ return toObject;
3537
+ }
3538
+ function citationMetadataFromMldev$1(fromObject) {
3539
+ const toObject = {};
3540
+ const fromCitations = getValueByPath(fromObject, ['citationSources']);
3541
+ if (fromCitations != null) {
3542
+ setValueByPath(toObject, ['citations'], fromCitations);
3543
+ }
3544
+ return toObject;
3545
+ }
3546
+ function urlMetadataFromMldev$2(fromObject) {
3547
+ const toObject = {};
3548
+ const fromRetrievedUrl = getValueByPath(fromObject, ['retrievedUrl']);
3549
+ if (fromRetrievedUrl != null) {
3550
+ setValueByPath(toObject, ['retrievedUrl'], fromRetrievedUrl);
3551
+ }
3552
+ const fromUrlRetrievalStatus = getValueByPath(fromObject, [
3553
+ 'urlRetrievalStatus',
3554
+ ]);
3555
+ if (fromUrlRetrievalStatus != null) {
3556
+ setValueByPath(toObject, ['urlRetrievalStatus'], fromUrlRetrievalStatus);
3557
+ }
3558
+ return toObject;
3559
+ }
3560
+ function urlContextMetadataFromMldev$2(fromObject) {
3561
+ const toObject = {};
3562
+ const fromUrlMetadata = getValueByPath(fromObject, ['urlMetadata']);
3563
+ if (fromUrlMetadata != null) {
3564
+ let transformedList = fromUrlMetadata;
3565
+ if (Array.isArray(transformedList)) {
3566
+ transformedList = transformedList.map((item) => {
3567
+ return urlMetadataFromMldev$2(item);
3568
+ });
3569
+ }
3570
+ setValueByPath(toObject, ['urlMetadata'], transformedList);
3571
+ }
3572
+ return toObject;
3573
+ }
3574
+ function candidateFromMldev$1(fromObject) {
3575
+ const toObject = {};
3576
+ const fromContent = getValueByPath(fromObject, ['content']);
3577
+ if (fromContent != null) {
3578
+ setValueByPath(toObject, ['content'], contentFromMldev$2(fromContent));
3579
+ }
3580
+ const fromCitationMetadata = getValueByPath(fromObject, [
3581
+ 'citationMetadata',
3582
+ ]);
3583
+ if (fromCitationMetadata != null) {
3584
+ setValueByPath(toObject, ['citationMetadata'], citationMetadataFromMldev$1(fromCitationMetadata));
3585
+ }
3586
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
3587
+ if (fromTokenCount != null) {
3588
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
3589
+ }
3590
+ const fromFinishReason = getValueByPath(fromObject, ['finishReason']);
3591
+ if (fromFinishReason != null) {
3592
+ setValueByPath(toObject, ['finishReason'], fromFinishReason);
3593
+ }
3594
+ const fromUrlContextMetadata = getValueByPath(fromObject, [
3595
+ 'urlContextMetadata',
3596
+ ]);
3597
+ if (fromUrlContextMetadata != null) {
3598
+ setValueByPath(toObject, ['urlContextMetadata'], urlContextMetadataFromMldev$2(fromUrlContextMetadata));
3599
+ }
3600
+ const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
3601
+ if (fromAvgLogprobs != null) {
3602
+ setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
3603
+ }
3604
+ const fromGroundingMetadata = getValueByPath(fromObject, [
3605
+ 'groundingMetadata',
3606
+ ]);
3607
+ if (fromGroundingMetadata != null) {
3608
+ setValueByPath(toObject, ['groundingMetadata'], fromGroundingMetadata);
3609
+ }
3610
+ const fromIndex = getValueByPath(fromObject, ['index']);
3611
+ if (fromIndex != null) {
3612
+ setValueByPath(toObject, ['index'], fromIndex);
3613
+ }
3614
+ const fromLogprobsResult = getValueByPath(fromObject, [
3615
+ 'logprobsResult',
3616
+ ]);
3617
+ if (fromLogprobsResult != null) {
3618
+ setValueByPath(toObject, ['logprobsResult'], fromLogprobsResult);
3619
+ }
3620
+ const fromSafetyRatings = getValueByPath(fromObject, [
3621
+ 'safetyRatings',
3622
+ ]);
3623
+ if (fromSafetyRatings != null) {
3624
+ setValueByPath(toObject, ['safetyRatings'], fromSafetyRatings);
3625
+ }
3626
+ return toObject;
3627
+ }
3628
+ function generateContentResponseFromMldev$1(fromObject) {
3629
+ const toObject = {};
3630
+ const fromCandidates = getValueByPath(fromObject, ['candidates']);
3631
+ if (fromCandidates != null) {
3632
+ let transformedList = fromCandidates;
3633
+ if (Array.isArray(transformedList)) {
3634
+ transformedList = transformedList.map((item) => {
3635
+ return candidateFromMldev$1(item);
3636
+ });
3637
+ }
3638
+ setValueByPath(toObject, ['candidates'], transformedList);
3639
+ }
3640
+ const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
3641
+ if (fromModelVersion != null) {
3642
+ setValueByPath(toObject, ['modelVersion'], fromModelVersion);
3643
+ }
3644
+ const fromPromptFeedback = getValueByPath(fromObject, [
3645
+ 'promptFeedback',
3646
+ ]);
3647
+ if (fromPromptFeedback != null) {
3648
+ setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
3649
+ }
3650
+ const fromUsageMetadata = getValueByPath(fromObject, [
3651
+ 'usageMetadata',
3652
+ ]);
3653
+ if (fromUsageMetadata != null) {
3654
+ setValueByPath(toObject, ['usageMetadata'], fromUsageMetadata);
3655
+ }
3656
+ return toObject;
3657
+ }
3658
+ function inlinedResponseFromMldev(fromObject) {
3659
+ const toObject = {};
3660
+ const fromResponse = getValueByPath(fromObject, ['response']);
3661
+ if (fromResponse != null) {
3662
+ setValueByPath(toObject, ['response'], generateContentResponseFromMldev$1(fromResponse));
3663
+ }
3664
+ const fromError = getValueByPath(fromObject, ['error']);
3665
+ if (fromError != null) {
3666
+ setValueByPath(toObject, ['error'], jobErrorFromMldev());
3667
+ }
3668
+ return toObject;
3669
+ }
3670
+ function batchJobDestinationFromMldev(fromObject) {
3671
+ const toObject = {};
3672
+ const fromFileName = getValueByPath(fromObject, ['responsesFile']);
3673
+ if (fromFileName != null) {
3674
+ setValueByPath(toObject, ['fileName'], fromFileName);
3675
+ }
3676
+ const fromInlinedResponses = getValueByPath(fromObject, [
3677
+ 'inlinedResponses',
3678
+ 'inlinedResponses',
3679
+ ]);
3680
+ if (fromInlinedResponses != null) {
3681
+ let transformedList = fromInlinedResponses;
3682
+ if (Array.isArray(transformedList)) {
3683
+ transformedList = transformedList.map((item) => {
3684
+ return inlinedResponseFromMldev(item);
3685
+ });
3686
+ }
3687
+ setValueByPath(toObject, ['inlinedResponses'], transformedList);
3688
+ }
3689
+ return toObject;
3690
+ }
3691
+ function batchJobFromMldev(fromObject) {
3692
+ const toObject = {};
3693
+ const fromName = getValueByPath(fromObject, ['name']);
3694
+ if (fromName != null) {
3695
+ setValueByPath(toObject, ['name'], fromName);
3696
+ }
3697
+ const fromDisplayName = getValueByPath(fromObject, [
3698
+ 'metadata',
3699
+ 'displayName',
3700
+ ]);
3701
+ if (fromDisplayName != null) {
3702
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
3703
+ }
3704
+ const fromState = getValueByPath(fromObject, ['metadata', 'state']);
3705
+ if (fromState != null) {
3706
+ setValueByPath(toObject, ['state'], tJobState(fromState));
3707
+ }
3708
+ const fromCreateTime = getValueByPath(fromObject, [
3709
+ 'metadata',
3710
+ 'createTime',
3711
+ ]);
3712
+ if (fromCreateTime != null) {
3713
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
3714
+ }
3715
+ const fromEndTime = getValueByPath(fromObject, [
3716
+ 'metadata',
3717
+ 'endTime',
3718
+ ]);
3719
+ if (fromEndTime != null) {
3720
+ setValueByPath(toObject, ['endTime'], fromEndTime);
3721
+ }
3722
+ const fromUpdateTime = getValueByPath(fromObject, [
3723
+ 'metadata',
3724
+ 'updateTime',
3725
+ ]);
3726
+ if (fromUpdateTime != null) {
3727
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
3728
+ }
3729
+ const fromModel = getValueByPath(fromObject, ['metadata', 'model']);
3730
+ if (fromModel != null) {
3731
+ setValueByPath(toObject, ['model'], fromModel);
3732
+ }
3733
+ const fromDest = getValueByPath(fromObject, ['metadata', 'output']);
3734
+ if (fromDest != null) {
3735
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromMldev(fromDest));
3736
+ }
3737
+ return toObject;
3738
+ }
3739
+ function listBatchJobsResponseFromMldev(fromObject) {
3740
+ const toObject = {};
3741
+ const fromNextPageToken = getValueByPath(fromObject, [
3742
+ 'nextPageToken',
3743
+ ]);
3744
+ if (fromNextPageToken != null) {
3745
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
3746
+ }
3747
+ const fromBatchJobs = getValueByPath(fromObject, ['operations']);
3748
+ if (fromBatchJobs != null) {
3749
+ let transformedList = fromBatchJobs;
3750
+ if (Array.isArray(transformedList)) {
3751
+ transformedList = transformedList.map((item) => {
3752
+ return batchJobFromMldev(item);
3753
+ });
3754
+ }
3755
+ setValueByPath(toObject, ['batchJobs'], transformedList);
3756
+ }
3757
+ return toObject;
3758
+ }
3759
+ function jobErrorFromVertex(fromObject) {
3760
+ const toObject = {};
3761
+ const fromDetails = getValueByPath(fromObject, ['details']);
3762
+ if (fromDetails != null) {
3763
+ setValueByPath(toObject, ['details'], fromDetails);
3764
+ }
3765
+ const fromCode = getValueByPath(fromObject, ['code']);
3766
+ if (fromCode != null) {
3767
+ setValueByPath(toObject, ['code'], fromCode);
3768
+ }
3769
+ const fromMessage = getValueByPath(fromObject, ['message']);
3770
+ if (fromMessage != null) {
3771
+ setValueByPath(toObject, ['message'], fromMessage);
3772
+ }
3773
+ return toObject;
3774
+ }
3775
+ function batchJobSourceFromVertex(fromObject) {
3776
+ const toObject = {};
3777
+ const fromFormat = getValueByPath(fromObject, ['instancesFormat']);
3778
+ if (fromFormat != null) {
3779
+ setValueByPath(toObject, ['format'], fromFormat);
3780
+ }
3781
+ const fromGcsUri = getValueByPath(fromObject, ['gcsSource', 'uris']);
3782
+ if (fromGcsUri != null) {
3783
+ setValueByPath(toObject, ['gcsUri'], fromGcsUri);
3784
+ }
3785
+ const fromBigqueryUri = getValueByPath(fromObject, [
3786
+ 'bigquerySource',
3787
+ 'inputUri',
3788
+ ]);
3789
+ if (fromBigqueryUri != null) {
3790
+ setValueByPath(toObject, ['bigqueryUri'], fromBigqueryUri);
3791
+ }
3792
+ return toObject;
3793
+ }
3794
+ function batchJobDestinationFromVertex(fromObject) {
3795
+ const toObject = {};
3796
+ const fromFormat = getValueByPath(fromObject, ['predictionsFormat']);
3797
+ if (fromFormat != null) {
3798
+ setValueByPath(toObject, ['format'], fromFormat);
3799
+ }
3800
+ const fromGcsUri = getValueByPath(fromObject, [
3801
+ 'gcsDestination',
3802
+ 'outputUriPrefix',
3803
+ ]);
3804
+ if (fromGcsUri != null) {
3805
+ setValueByPath(toObject, ['gcsUri'], fromGcsUri);
3806
+ }
3807
+ const fromBigqueryUri = getValueByPath(fromObject, [
3808
+ 'bigqueryDestination',
3809
+ 'outputUri',
3810
+ ]);
3811
+ if (fromBigqueryUri != null) {
3812
+ setValueByPath(toObject, ['bigqueryUri'], fromBigqueryUri);
3813
+ }
3814
+ return toObject;
3815
+ }
3816
+ function batchJobFromVertex(fromObject) {
3817
+ const toObject = {};
3818
+ const fromName = getValueByPath(fromObject, ['name']);
3819
+ if (fromName != null) {
3820
+ setValueByPath(toObject, ['name'], fromName);
3821
+ }
3822
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3823
+ if (fromDisplayName != null) {
3824
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
3825
+ }
3826
+ const fromState = getValueByPath(fromObject, ['state']);
3827
+ if (fromState != null) {
3828
+ setValueByPath(toObject, ['state'], tJobState(fromState));
3829
+ }
3830
+ const fromError = getValueByPath(fromObject, ['error']);
3831
+ if (fromError != null) {
3832
+ setValueByPath(toObject, ['error'], jobErrorFromVertex(fromError));
3833
+ }
3834
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
3835
+ if (fromCreateTime != null) {
3836
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
3837
+ }
3838
+ const fromStartTime = getValueByPath(fromObject, ['startTime']);
3839
+ if (fromStartTime != null) {
3840
+ setValueByPath(toObject, ['startTime'], fromStartTime);
3841
+ }
3842
+ const fromEndTime = getValueByPath(fromObject, ['endTime']);
3843
+ if (fromEndTime != null) {
3844
+ setValueByPath(toObject, ['endTime'], fromEndTime);
3845
+ }
3846
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
3847
+ if (fromUpdateTime != null) {
3848
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
3849
+ }
3850
+ const fromModel = getValueByPath(fromObject, ['model']);
3851
+ if (fromModel != null) {
3852
+ setValueByPath(toObject, ['model'], fromModel);
3853
+ }
3854
+ const fromSrc = getValueByPath(fromObject, ['inputConfig']);
3855
+ if (fromSrc != null) {
3856
+ setValueByPath(toObject, ['src'], batchJobSourceFromVertex(fromSrc));
3857
+ }
3858
+ const fromDest = getValueByPath(fromObject, ['outputConfig']);
3859
+ if (fromDest != null) {
3860
+ setValueByPath(toObject, ['dest'], batchJobDestinationFromVertex(fromDest));
3861
+ }
3862
+ return toObject;
3863
+ }
3864
+ function listBatchJobsResponseFromVertex(fromObject) {
3865
+ const toObject = {};
3866
+ const fromNextPageToken = getValueByPath(fromObject, [
3867
+ 'nextPageToken',
3868
+ ]);
3869
+ if (fromNextPageToken != null) {
3870
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
3871
+ }
3872
+ const fromBatchJobs = getValueByPath(fromObject, [
3873
+ 'batchPredictionJobs',
3874
+ ]);
3875
+ if (fromBatchJobs != null) {
3876
+ let transformedList = fromBatchJobs;
3877
+ if (Array.isArray(transformedList)) {
3878
+ transformedList = transformedList.map((item) => {
3879
+ return batchJobFromVertex(item);
3880
+ });
3881
+ }
3882
+ setValueByPath(toObject, ['batchJobs'], transformedList);
3883
+ }
3884
+ return toObject;
3885
+ }
3886
+
3887
+ /**
3888
+ * @license
3889
+ * Copyright 2025 Google LLC
3890
+ * SPDX-License-Identifier: Apache-2.0
3891
+ */
3892
+ /**
3893
+ * Pagers for the GenAI List APIs.
3894
+ */
3895
+ var PagedItem;
3896
+ (function (PagedItem) {
3897
+ PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
3898
+ PagedItem["PAGED_ITEM_MODELS"] = "models";
3899
+ PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
3900
+ PagedItem["PAGED_ITEM_FILES"] = "files";
3901
+ PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
3902
+ })(PagedItem || (PagedItem = {}));
3903
+ /**
3904
+ * Pager class for iterating through paginated results.
3905
+ */
3906
+ class Pager {
3907
+ constructor(name, request, response, params) {
3908
+ this.pageInternal = [];
3909
+ this.paramsInternal = {};
3910
+ this.requestInternal = request;
3911
+ this.init(name, response, params);
3912
+ }
3913
+ init(name, response, params) {
3914
+ var _a, _b;
3915
+ this.nameInternal = name;
3916
+ this.pageInternal = response[this.nameInternal] || [];
3917
+ this.idxInternal = 0;
3918
+ let requestParams = { config: {} };
3919
+ if (!params) {
3920
+ requestParams = { config: {} };
3921
+ }
3922
+ else if (typeof params === 'object') {
3923
+ requestParams = Object.assign({}, params);
3924
+ }
3925
+ else {
3926
+ requestParams = params;
3927
+ }
3928
+ if (requestParams['config']) {
3929
+ requestParams['config']['pageToken'] = response['nextPageToken'];
3930
+ }
3931
+ this.paramsInternal = requestParams;
3932
+ this.pageInternalSize =
3933
+ (_b = (_a = requestParams['config']) === null || _a === void 0 ? void 0 : _a['pageSize']) !== null && _b !== void 0 ? _b : this.pageInternal.length;
3934
+ }
3935
+ initNextPage(response) {
3936
+ this.init(this.nameInternal, response, this.paramsInternal);
3937
+ }
3938
+ /**
3939
+ * Returns the current page, which is a list of items.
3940
+ *
3941
+ * @remarks
3942
+ * The first page is retrieved when the pager is created. The returned list of
3943
+ * items could be a subset of the entire list.
3944
+ */
3945
+ get page() {
3946
+ return this.pageInternal;
3947
+ }
3948
+ /**
3949
+ * Returns the type of paged item (for example, ``batch_jobs``).
3950
+ */
3951
+ get name() {
3952
+ return this.nameInternal;
3953
+ }
3954
+ /**
3955
+ * Returns the length of the page fetched each time by this pager.
3956
+ *
3957
+ * @remarks
3958
+ * The number of items in the page is less than or equal to the page length.
3959
+ */
3960
+ get pageSize() {
3961
+ return this.pageInternalSize;
3962
+ }
3963
+ /**
3964
+ * Returns the parameters when making the API request for the next page.
3965
+ *
3966
+ * @remarks
3967
+ * Parameters contain a set of optional configs that can be
3968
+ * used to customize the API request. For example, the `pageToken` parameter
3969
+ * contains the token to request the next page.
3970
+ */
3971
+ get params() {
3972
+ return this.paramsInternal;
3973
+ }
3974
+ /**
3975
+ * Returns the total number of items in the current page.
3976
+ */
3977
+ get pageLength() {
3978
+ return this.pageInternal.length;
3979
+ }
3980
+ /**
3981
+ * Returns the item at the given index.
3982
+ */
3983
+ getItem(index) {
3984
+ return this.pageInternal[index];
3985
+ }
3986
+ /**
3987
+ * Returns an async iterator that support iterating through all items
3988
+ * retrieved from the API.
3989
+ *
3990
+ * @remarks
3991
+ * The iterator will automatically fetch the next page if there are more items
3992
+ * to fetch from the API.
3993
+ *
3994
+ * @example
3995
+ *
3996
+ * ```ts
3997
+ * const pager = await ai.files.list({config: {pageSize: 10}});
3998
+ * for await (const file of pager) {
3999
+ * console.log(file.name);
4000
+ * }
4001
+ * ```
4002
+ */
4003
+ [Symbol.asyncIterator]() {
4004
+ return {
4005
+ next: async () => {
4006
+ if (this.idxInternal >= this.pageLength) {
4007
+ if (this.hasNextPage()) {
4008
+ await this.nextPage();
4009
+ }
4010
+ else {
4011
+ return { value: undefined, done: true };
4012
+ }
4013
+ }
4014
+ const item = this.getItem(this.idxInternal);
4015
+ this.idxInternal += 1;
4016
+ return { value: item, done: false };
4017
+ },
4018
+ return: async () => {
4019
+ return { value: undefined, done: true };
4020
+ },
4021
+ };
4022
+ }
4023
+ /**
4024
+ * Fetches the next page of items. This makes a new API request.
4025
+ *
4026
+ * @throws {Error} If there are no more pages to fetch.
4027
+ *
4028
+ * @example
4029
+ *
4030
+ * ```ts
4031
+ * const pager = await ai.files.list({config: {pageSize: 10}});
4032
+ * let page = pager.page;
4033
+ * while (true) {
4034
+ * for (const file of page) {
4035
+ * console.log(file.name);
4036
+ * }
4037
+ * if (!pager.hasNextPage()) {
4038
+ * break;
4039
+ * }
4040
+ * page = await pager.nextPage();
4041
+ * }
4042
+ * ```
4043
+ */
4044
+ async nextPage() {
4045
+ if (!this.hasNextPage()) {
4046
+ throw new Error('No more pages to fetch.');
4047
+ }
4048
+ const response = await this.requestInternal(this.params);
4049
+ this.initNextPage(response);
4050
+ return this.page;
4051
+ }
4052
+ /**
4053
+ * Returns true if there are more pages to fetch from the API.
4054
+ */
4055
+ hasNextPage() {
4056
+ var _a;
4057
+ if (((_a = this.params['config']) === null || _a === void 0 ? void 0 : _a['pageToken']) !== undefined) {
4058
+ return true;
4059
+ }
4060
+ return false;
4061
+ }
4062
+ }
4063
+
4064
+ /**
4065
+ * @license
4066
+ * Copyright 2025 Google LLC
4067
+ * SPDX-License-Identifier: Apache-2.0
4068
+ */
4069
+ class Batches extends BaseModule {
4070
+ constructor(apiClient) {
4071
+ super();
4072
+ this.apiClient = apiClient;
4073
+ /**
4074
+ * Create batch job.
4075
+ *
4076
+ * @param params - The parameters for create batch job request.
4077
+ * @return The created batch job.
4078
+ *
4079
+ * @example
4080
+ * ```ts
4081
+ * const response = await ai.batches.create({
4082
+ * model: 'gemini-2.0-flash',
4083
+ * src: {gcsUri: 'gs://bucket/path/to/file.jsonl', format: 'jsonl'},
4084
+ * config: {
4085
+ * dest: {gcsUri: 'gs://bucket/path/output/directory', format: 'jsonl'},
4086
+ * }
4087
+ * });
4088
+ * console.log(response);
4089
+ * ```
4090
+ */
4091
+ this.create = async (params) => {
4092
+ if (this.apiClient.isVertexAI()) {
4093
+ if (Array.isArray(params.src)) {
4094
+ throw new Error('InlinedRequest[] is not supported in Vertex AI. Please use ' +
4095
+ 'Google Cloud Storage URI or BigQuery URI instead.');
4096
+ }
4097
+ params.config = params.config || {};
4098
+ if (params.config.displayName === undefined) {
4099
+ params.config.displayName = 'genaiBatchJob_';
4100
+ }
4101
+ if (params.config.dest === undefined && typeof params.src === 'string') {
4102
+ if (params.src.startsWith('gs://') && params.src.endsWith('.jsonl')) {
4103
+ params.config.dest = `${params.src.slice(0, -6)}/dest`;
4104
+ }
4105
+ else if (params.src.startsWith('bq://')) {
4106
+ params.config.dest = `${params.src}_dest_`;
4107
+ }
4108
+ else {
4109
+ throw new Error('Unsupported source:' + params.src);
4110
+ }
4111
+ }
4112
+ }
4113
+ return await this.createInternal(params);
4114
+ };
4115
+ /**
4116
+ * Lists batch job configurations.
4117
+ *
4118
+ * @param params - The parameters for the list request.
4119
+ * @return The paginated results of the list of batch jobs.
4120
+ *
4121
+ * @example
4122
+ * ```ts
4123
+ * const batchJobs = await ai.batches.list({config: {'pageSize': 2}});
4124
+ * for await (const batchJob of batchJobs) {
4125
+ * console.log(batchJob);
4126
+ * }
4127
+ * ```
4128
+ */
4129
+ this.list = async (params = {}) => {
4130
+ return new Pager(PagedItem.PAGED_ITEM_BATCH_JOBS, (x) => this.listInternal(x), await this.listInternal(params), params);
4131
+ };
4132
+ }
4133
+ /**
4134
+ * Internal method to create batch job.
4135
+ *
4136
+ * @param params - The parameters for create batch job request.
4137
+ * @return The created batch job.
4138
+ *
4139
+ */
4140
+ async createInternal(params) {
4141
+ var _a, _b, _c, _d;
4142
+ let response;
4143
+ let path = '';
4144
+ let queryParams = {};
4145
+ if (this.apiClient.isVertexAI()) {
4146
+ const body = createBatchJobParametersToVertex(this.apiClient, params);
4147
+ path = formatMap('batchPredictionJobs', body['_url']);
4148
+ queryParams = body['_query'];
4149
+ delete body['config'];
4150
+ delete body['_url'];
4151
+ delete body['_query'];
4152
+ response = this.apiClient
4153
+ .request({
4154
+ path: path,
4155
+ queryParams: queryParams,
4156
+ body: JSON.stringify(body),
4157
+ httpMethod: 'POST',
4158
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4159
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4160
+ })
4161
+ .then((httpResponse) => {
4162
+ return httpResponse.json();
4163
+ });
4164
+ return response.then((apiResponse) => {
4165
+ const resp = batchJobFromVertex(apiResponse);
4166
+ return resp;
4167
+ });
4168
+ }
4169
+ else {
4170
+ const body = createBatchJobParametersToMldev(this.apiClient, params);
4171
+ path = formatMap('{model}:batchGenerateContent', body['_url']);
4172
+ queryParams = body['_query'];
4173
+ delete body['config'];
4174
+ delete body['_url'];
4175
+ delete body['_query'];
4176
+ response = this.apiClient
4177
+ .request({
4178
+ path: path,
4179
+ queryParams: queryParams,
4180
+ body: JSON.stringify(body),
4181
+ httpMethod: 'POST',
4182
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4183
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4184
+ })
4185
+ .then((httpResponse) => {
4186
+ return httpResponse.json();
4187
+ });
4188
+ return response.then((apiResponse) => {
4189
+ const resp = batchJobFromMldev(apiResponse);
4190
+ return resp;
4191
+ });
4192
+ }
4193
+ }
4194
+ /**
4195
+ * Gets batch job configurations.
4196
+ *
4197
+ * @param params - The parameters for the get request.
4198
+ * @return The batch job.
4199
+ *
4200
+ * @example
4201
+ * ```ts
4202
+ * await ai.batches.get({name: '...'}); // The server-generated resource name.
4203
+ * ```
4204
+ */
4205
+ async get(params) {
4206
+ var _a, _b, _c, _d;
4207
+ let response;
4208
+ let path = '';
4209
+ let queryParams = {};
4210
+ if (this.apiClient.isVertexAI()) {
4211
+ const body = getBatchJobParametersToVertex(this.apiClient, params);
4212
+ path = formatMap('batchPredictionJobs/{name}', body['_url']);
4213
+ queryParams = body['_query'];
4214
+ delete body['config'];
4215
+ delete body['_url'];
4216
+ delete body['_query'];
4217
+ response = this.apiClient
4218
+ .request({
4219
+ path: path,
4220
+ queryParams: queryParams,
4221
+ body: JSON.stringify(body),
4222
+ httpMethod: 'GET',
4223
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4224
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4225
+ })
4226
+ .then((httpResponse) => {
4227
+ return httpResponse.json();
4228
+ });
4229
+ return response.then((apiResponse) => {
4230
+ const resp = batchJobFromVertex(apiResponse);
4231
+ return resp;
4232
+ });
4233
+ }
4234
+ else {
4235
+ const body = getBatchJobParametersToMldev(this.apiClient, params);
4236
+ path = formatMap('batches/{name}', body['_url']);
4237
+ queryParams = body['_query'];
4238
+ delete body['config'];
4239
+ delete body['_url'];
4240
+ delete body['_query'];
4241
+ response = this.apiClient
4242
+ .request({
4243
+ path: path,
4244
+ queryParams: queryParams,
4245
+ body: JSON.stringify(body),
4246
+ httpMethod: 'GET',
4247
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4248
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4249
+ })
4250
+ .then((httpResponse) => {
4251
+ return httpResponse.json();
4252
+ });
4253
+ return response.then((apiResponse) => {
4254
+ const resp = batchJobFromMldev(apiResponse);
4255
+ return resp;
4256
+ });
4257
+ }
4258
+ }
4259
+ /**
4260
+ * Cancels a batch job.
4261
+ *
4262
+ * @param params - The parameters for the cancel request.
4263
+ * @return The empty response returned by the API.
4264
+ *
4265
+ * @example
4266
+ * ```ts
4267
+ * await ai.batches.cancel({name: '...'}); // The server-generated resource name.
4268
+ * ```
4269
+ */
4270
+ async cancel(params) {
4271
+ var _a, _b, _c, _d;
4272
+ let path = '';
4273
+ let queryParams = {};
4274
+ if (this.apiClient.isVertexAI()) {
4275
+ const body = cancelBatchJobParametersToVertex(this.apiClient, params);
4276
+ path = formatMap('batchPredictionJobs/{name}:cancel', body['_url']);
4277
+ queryParams = body['_query'];
4278
+ delete body['config'];
4279
+ delete body['_url'];
4280
+ delete body['_query'];
4281
+ await this.apiClient.request({
4282
+ path: path,
4283
+ queryParams: queryParams,
4284
+ body: JSON.stringify(body),
4285
+ httpMethod: 'POST',
4286
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4287
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4288
+ });
4289
+ }
4290
+ else {
4291
+ const body = cancelBatchJobParametersToMldev(this.apiClient, params);
4292
+ path = formatMap('batches/{name}:cancel', body['_url']);
4293
+ queryParams = body['_query'];
4294
+ delete body['config'];
4295
+ delete body['_url'];
4296
+ delete body['_query'];
4297
+ await this.apiClient.request({
4298
+ path: path,
4299
+ queryParams: queryParams,
4300
+ body: JSON.stringify(body),
4301
+ httpMethod: 'POST',
4302
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4303
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4304
+ });
4305
+ }
4306
+ }
4307
+ async listInternal(params) {
4308
+ var _a, _b, _c, _d;
4309
+ let response;
4310
+ let path = '';
4311
+ let queryParams = {};
4312
+ if (this.apiClient.isVertexAI()) {
4313
+ const body = listBatchJobsParametersToVertex(params);
4314
+ path = formatMap('batchPredictionJobs', body['_url']);
4315
+ queryParams = body['_query'];
4316
+ delete body['config'];
4317
+ delete body['_url'];
4318
+ delete body['_query'];
4319
+ response = this.apiClient
4320
+ .request({
4321
+ path: path,
4322
+ queryParams: queryParams,
4323
+ body: JSON.stringify(body),
4324
+ httpMethod: 'GET',
4325
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
4326
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4327
+ })
4328
+ .then((httpResponse) => {
4329
+ return httpResponse.json();
4330
+ });
4331
+ return response.then((apiResponse) => {
4332
+ const resp = listBatchJobsResponseFromVertex(apiResponse);
4333
+ const typedResp = new ListBatchJobsResponse();
4334
+ Object.assign(typedResp, resp);
4335
+ return typedResp;
4336
+ });
2381
4337
  }
2382
- else if (supportedJsonSchemaFields.has(fieldName)) {
2383
- filteredSchema[fieldName] = fieldValue;
4338
+ else {
4339
+ const body = listBatchJobsParametersToMldev(params);
4340
+ path = formatMap('batches', body['_url']);
4341
+ queryParams = body['_query'];
4342
+ delete body['config'];
4343
+ delete body['_url'];
4344
+ delete body['_query'];
4345
+ response = this.apiClient
4346
+ .request({
4347
+ path: path,
4348
+ queryParams: queryParams,
4349
+ body: JSON.stringify(body),
4350
+ httpMethod: 'GET',
4351
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
4352
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4353
+ })
4354
+ .then((httpResponse) => {
4355
+ return httpResponse.json();
4356
+ });
4357
+ return response.then((apiResponse) => {
4358
+ const resp = listBatchJobsResponseFromMldev(apiResponse);
4359
+ const typedResp = new ListBatchJobsResponse();
4360
+ Object.assign(typedResp, resp);
4361
+ return typedResp;
4362
+ });
2384
4363
  }
2385
4364
  }
2386
- return filteredSchema;
2387
4365
  }
2388
4366
 
2389
4367
  /**
@@ -3435,183 +5413,6 @@ function listCachedContentsResponseFromVertex(fromObject) {
3435
5413
  return toObject;
3436
5414
  }
3437
5415
 
3438
- /**
3439
- * @license
3440
- * Copyright 2025 Google LLC
3441
- * SPDX-License-Identifier: Apache-2.0
3442
- */
3443
- /**
3444
- * Pagers for the GenAI List APIs.
3445
- */
3446
- var PagedItem;
3447
- (function (PagedItem) {
3448
- PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
3449
- PagedItem["PAGED_ITEM_MODELS"] = "models";
3450
- PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
3451
- PagedItem["PAGED_ITEM_FILES"] = "files";
3452
- PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
3453
- })(PagedItem || (PagedItem = {}));
3454
- /**
3455
- * Pager class for iterating through paginated results.
3456
- */
3457
- class Pager {
3458
- constructor(name, request, response, params) {
3459
- this.pageInternal = [];
3460
- this.paramsInternal = {};
3461
- this.requestInternal = request;
3462
- this.init(name, response, params);
3463
- }
3464
- init(name, response, params) {
3465
- var _a, _b;
3466
- this.nameInternal = name;
3467
- this.pageInternal = response[this.nameInternal] || [];
3468
- this.idxInternal = 0;
3469
- let requestParams = { config: {} };
3470
- if (!params) {
3471
- requestParams = { config: {} };
3472
- }
3473
- else if (typeof params === 'object') {
3474
- requestParams = Object.assign({}, params);
3475
- }
3476
- else {
3477
- requestParams = params;
3478
- }
3479
- if (requestParams['config']) {
3480
- requestParams['config']['pageToken'] = response['nextPageToken'];
3481
- }
3482
- this.paramsInternal = requestParams;
3483
- this.pageInternalSize =
3484
- (_b = (_a = requestParams['config']) === null || _a === void 0 ? void 0 : _a['pageSize']) !== null && _b !== void 0 ? _b : this.pageInternal.length;
3485
- }
3486
- initNextPage(response) {
3487
- this.init(this.nameInternal, response, this.paramsInternal);
3488
- }
3489
- /**
3490
- * Returns the current page, which is a list of items.
3491
- *
3492
- * @remarks
3493
- * The first page is retrieved when the pager is created. The returned list of
3494
- * items could be a subset of the entire list.
3495
- */
3496
- get page() {
3497
- return this.pageInternal;
3498
- }
3499
- /**
3500
- * Returns the type of paged item (for example, ``batch_jobs``).
3501
- */
3502
- get name() {
3503
- return this.nameInternal;
3504
- }
3505
- /**
3506
- * Returns the length of the page fetched each time by this pager.
3507
- *
3508
- * @remarks
3509
- * The number of items in the page is less than or equal to the page length.
3510
- */
3511
- get pageSize() {
3512
- return this.pageInternalSize;
3513
- }
3514
- /**
3515
- * Returns the parameters when making the API request for the next page.
3516
- *
3517
- * @remarks
3518
- * Parameters contain a set of optional configs that can be
3519
- * used to customize the API request. For example, the `pageToken` parameter
3520
- * contains the token to request the next page.
3521
- */
3522
- get params() {
3523
- return this.paramsInternal;
3524
- }
3525
- /**
3526
- * Returns the total number of items in the current page.
3527
- */
3528
- get pageLength() {
3529
- return this.pageInternal.length;
3530
- }
3531
- /**
3532
- * Returns the item at the given index.
3533
- */
3534
- getItem(index) {
3535
- return this.pageInternal[index];
3536
- }
3537
- /**
3538
- * Returns an async iterator that support iterating through all items
3539
- * retrieved from the API.
3540
- *
3541
- * @remarks
3542
- * The iterator will automatically fetch the next page if there are more items
3543
- * to fetch from the API.
3544
- *
3545
- * @example
3546
- *
3547
- * ```ts
3548
- * const pager = await ai.files.list({config: {pageSize: 10}});
3549
- * for await (const file of pager) {
3550
- * console.log(file.name);
3551
- * }
3552
- * ```
3553
- */
3554
- [Symbol.asyncIterator]() {
3555
- return {
3556
- next: async () => {
3557
- if (this.idxInternal >= this.pageLength) {
3558
- if (this.hasNextPage()) {
3559
- await this.nextPage();
3560
- }
3561
- else {
3562
- return { value: undefined, done: true };
3563
- }
3564
- }
3565
- const item = this.getItem(this.idxInternal);
3566
- this.idxInternal += 1;
3567
- return { value: item, done: false };
3568
- },
3569
- return: async () => {
3570
- return { value: undefined, done: true };
3571
- },
3572
- };
3573
- }
3574
- /**
3575
- * Fetches the next page of items. This makes a new API request.
3576
- *
3577
- * @throws {Error} If there are no more pages to fetch.
3578
- *
3579
- * @example
3580
- *
3581
- * ```ts
3582
- * const pager = await ai.files.list({config: {pageSize: 10}});
3583
- * let page = pager.page;
3584
- * while (true) {
3585
- * for (const file of page) {
3586
- * console.log(file.name);
3587
- * }
3588
- * if (!pager.hasNextPage()) {
3589
- * break;
3590
- * }
3591
- * page = await pager.nextPage();
3592
- * }
3593
- * ```
3594
- */
3595
- async nextPage() {
3596
- if (!this.hasNextPage()) {
3597
- throw new Error('No more pages to fetch.');
3598
- }
3599
- const response = await this.requestInternal(this.params);
3600
- this.initNextPage(response);
3601
- return this.page;
3602
- }
3603
- /**
3604
- * Returns true if there are more pages to fetch from the API.
3605
- */
3606
- hasNextPage() {
3607
- var _a;
3608
- if (((_a = this.params['config']) === null || _a === void 0 ? void 0 : _a['pageToken']) !== undefined) {
3609
- return true;
3610
- }
3611
- return false;
3612
- }
3613
- }
3614
-
3615
5416
  /**
3616
5417
  * @license
3617
5418
  * Copyright 2025 Google LLC
@@ -4392,7 +6193,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
4392
6193
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
4393
6194
  const USER_AGENT_HEADER = 'User-Agent';
4394
6195
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
4395
- const SDK_VERSION = '1.6.0'; // x-release-please-version
6196
+ const SDK_VERSION = '1.7.0'; // x-release-please-version
4396
6197
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
4397
6198
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
4398
6199
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8449,6 +10250,12 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
8449
10250
  if (fromResponseSchema != null) {
8450
10251
  setValueByPath(toObject, ['responseSchema'], schemaToMldev(tSchema(fromResponseSchema)));
8451
10252
  }
10253
+ const fromResponseJsonSchema = getValueByPath(fromObject, [
10254
+ 'responseJsonSchema',
10255
+ ]);
10256
+ if (fromResponseJsonSchema != null) {
10257
+ setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
10258
+ }
8452
10259
  if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
8453
10260
  throw new Error('routingConfig parameter is not supported in Gemini API.');
8454
10261
  }
@@ -8863,6 +10670,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
8863
10670
  if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
8864
10671
  throw new Error('lastFrame parameter is not supported in Gemini API.');
8865
10672
  }
10673
+ if (getValueByPath(fromObject, ['compressionQuality']) !== undefined) {
10674
+ throw new Error('compressionQuality parameter is not supported in Gemini API.');
10675
+ }
8866
10676
  return toObject;
8867
10677
  }
8868
10678
  function generateVideosParametersToMldev(apiClient, fromObject) {
@@ -9498,6 +11308,12 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
9498
11308
  if (fromResponseSchema != null) {
9499
11309
  setValueByPath(toObject, ['responseSchema'], schemaToVertex(tSchema(fromResponseSchema)));
9500
11310
  }
11311
+ const fromResponseJsonSchema = getValueByPath(fromObject, [
11312
+ 'responseJsonSchema',
11313
+ ]);
11314
+ if (fromResponseJsonSchema != null) {
11315
+ setValueByPath(toObject, ['responseJsonSchema'], fromResponseJsonSchema);
11316
+ }
9501
11317
  const fromRoutingConfig = getValueByPath(fromObject, [
9502
11318
  'routingConfig',
9503
11319
  ]);
@@ -9986,6 +11802,18 @@ function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
9986
11802
  if (parentObject !== undefined && fromOutputCompressionQuality != null) {
9987
11803
  setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
9988
11804
  }
11805
+ const fromEnhanceInputImage = getValueByPath(fromObject, [
11806
+ 'enhanceInputImage',
11807
+ ]);
11808
+ if (parentObject !== undefined && fromEnhanceInputImage != null) {
11809
+ setValueByPath(parentObject, ['parameters', 'upscaleConfig', 'enhanceInputImage'], fromEnhanceInputImage);
11810
+ }
11811
+ const fromImagePreservationFactor = getValueByPath(fromObject, [
11812
+ 'imagePreservationFactor',
11813
+ ]);
11814
+ if (parentObject !== undefined && fromImagePreservationFactor != null) {
11815
+ setValueByPath(parentObject, ['parameters', 'upscaleConfig', 'imagePreservationFactor'], fromImagePreservationFactor);
11816
+ }
9989
11817
  const fromNumberOfImages = getValueByPath(fromObject, [
9990
11818
  'numberOfImages',
9991
11819
  ]);
@@ -10254,6 +12082,12 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
10254
12082
  if (parentObject !== undefined && fromLastFrame != null) {
10255
12083
  setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(fromLastFrame));
10256
12084
  }
12085
+ const fromCompressionQuality = getValueByPath(fromObject, [
12086
+ 'compressionQuality',
12087
+ ]);
12088
+ if (parentObject !== undefined && fromCompressionQuality != null) {
12089
+ setValueByPath(parentObject, ['parameters', 'compressionQuality'], fromCompressionQuality);
12090
+ }
10257
12091
  return toObject;
10258
12092
  }
10259
12093
  function generateVideosParametersToVertex(apiClient, fromObject) {
@@ -11878,13 +13712,17 @@ const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id
11878
13712
  */
11879
13713
  async function handleWebSocketMessage(apiClient, onmessage, event) {
11880
13714
  const serverMessage = new LiveServerMessage();
11881
- let data;
13715
+ let jsonData;
11882
13716
  if (event.data instanceof Blob) {
11883
- data = JSON.parse(await event.data.text());
13717
+ jsonData = await event.data.text();
13718
+ }
13719
+ else if (event.data instanceof ArrayBuffer) {
13720
+ jsonData = new TextDecoder().decode(event.data);
11884
13721
  }
11885
13722
  else {
11886
- data = JSON.parse(event.data);
13723
+ jsonData = event.data;
11887
13724
  }
13725
+ const data = JSON.parse(jsonData);
11888
13726
  if (apiClient.isVertexAI()) {
11889
13727
  const resp = liveServerMessageFromVertex(data);
11890
13728
  Object.assign(serverMessage, resp);
@@ -15645,6 +17483,7 @@ class GoogleGenAI {
15645
17483
  this.models = new Models(this.apiClient);
15646
17484
  this.live = new Live(this.apiClient, auth, new CrossWebSocketFactory());
15647
17485
  this.chats = new Chats(this.models, this.apiClient);
17486
+ this.batches = new Batches(this.apiClient);
15648
17487
  this.caches = new Caches(this.apiClient);
15649
17488
  this.files = new Files(this.apiClient);
15650
17489
  this.operations = new Operations(this.apiClient);
@@ -15653,5 +17492,5 @@ class GoogleGenAI {
15653
17492
  }
15654
17493
  }
15655
17494
 
15656
- export { ActivityHandling, AdapterSize, ApiError, AuthType, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
17495
+ export { ActivityHandling, AdapterSize, ApiError, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, 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, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
15657
17496
  //# sourceMappingURL=index.mjs.map