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