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