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