@google/genai 1.6.0 → 1.7.0

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