@google/genai 0.6.1 → 0.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.
@@ -1689,6 +1689,15 @@ var SubjectReferenceType;
1689
1689
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
1690
1690
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
1691
1691
  })(SubjectReferenceType || (SubjectReferenceType = {}));
1692
+ var MediaModality;
1693
+ (function (MediaModality) {
1694
+ MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
1695
+ MediaModality["TEXT"] = "TEXT";
1696
+ MediaModality["IMAGE"] = "IMAGE";
1697
+ MediaModality["VIDEO"] = "VIDEO";
1698
+ MediaModality["AUDIO"] = "AUDIO";
1699
+ MediaModality["DOCUMENT"] = "DOCUMENT";
1700
+ })(MediaModality || (MediaModality = {}));
1692
1701
  /** A function response. */
1693
1702
  class FunctionResponse {
1694
1703
  }
@@ -2035,6 +2044,9 @@ class CountTokensResponse {
2035
2044
  /** Response for computing tokens. */
2036
2045
  class ComputeTokensResponse {
2037
2046
  }
2047
+ /** Response with generated videos. */
2048
+ class GenerateVideosResponse {
2049
+ }
2038
2050
  /** Empty response for caches.delete method. */
2039
2051
  class DeleteCachedContentResponse {
2040
2052
  }
@@ -2118,6 +2130,12 @@ class Caches extends BaseModule {
2118
2130
  /**
2119
2131
  * Creates a cached contents resource.
2120
2132
  *
2133
+ * @remarks
2134
+ * Context caching is only supported for specific models. See [Gemini
2135
+ * Developer API reference] (https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
2136
+ * and [Vertex AI reference] (https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
2137
+ * for more information.
2138
+ *
2121
2139
  * @param params - The parameters for the create request.
2122
2140
  * @return The created cached content.
2123
2141
  *
@@ -2125,7 +2143,7 @@ class Caches extends BaseModule {
2125
2143
  * ```ts
2126
2144
  * const contents = ...; // Initialize the content to cache.
2127
2145
  * const response = await ai.caches.create({
2128
- * model: 'gemini-2.0-flash',
2146
+ * model: 'gemini-1.5-flash',
2129
2147
  * config: {
2130
2148
  * 'contents': contents,
2131
2149
  * 'displayName': 'test cache',
@@ -2804,630 +2822,960 @@ class Chat {
2804
2822
  * Copyright 2025 Google LLC
2805
2823
  * SPDX-License-Identifier: Apache-2.0
2806
2824
  */
2807
- function partToMldev(apiClient, fromObject) {
2825
+ function listFilesConfigToMldev(apiClient, fromObject, parentObject) {
2808
2826
  const toObject = {};
2809
- if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
2810
- throw new Error('videoMetadata parameter is not supported in Gemini API.');
2811
- }
2812
- const fromThought = getValueByPath(fromObject, ['thought']);
2813
- if (fromThought != null) {
2814
- setValueByPath(toObject, ['thought'], fromThought);
2815
- }
2816
- const fromCodeExecutionResult = getValueByPath(fromObject, [
2817
- 'codeExecutionResult',
2818
- ]);
2819
- if (fromCodeExecutionResult != null) {
2820
- setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
2821
- }
2822
- const fromExecutableCode = getValueByPath(fromObject, [
2823
- 'executableCode',
2824
- ]);
2825
- if (fromExecutableCode != null) {
2826
- setValueByPath(toObject, ['executableCode'], fromExecutableCode);
2827
- }
2828
- const fromFileData = getValueByPath(fromObject, ['fileData']);
2829
- if (fromFileData != null) {
2830
- setValueByPath(toObject, ['fileData'], fromFileData);
2831
- }
2832
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
2833
- if (fromFunctionCall != null) {
2834
- setValueByPath(toObject, ['functionCall'], fromFunctionCall);
2835
- }
2836
- const fromFunctionResponse = getValueByPath(fromObject, [
2837
- 'functionResponse',
2838
- ]);
2839
- if (fromFunctionResponse != null) {
2840
- setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
2841
- }
2842
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
2843
- if (fromInlineData != null) {
2844
- setValueByPath(toObject, ['inlineData'], fromInlineData);
2827
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
2828
+ if (parentObject !== undefined && fromPageSize != null) {
2829
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
2845
2830
  }
2846
- const fromText = getValueByPath(fromObject, ['text']);
2847
- if (fromText != null) {
2848
- setValueByPath(toObject, ['text'], fromText);
2831
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
2832
+ if (parentObject !== undefined && fromPageToken != null) {
2833
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
2849
2834
  }
2850
2835
  return toObject;
2851
2836
  }
2852
- function contentToMldev(apiClient, fromObject) {
2837
+ function listFilesParametersToMldev(apiClient, fromObject) {
2853
2838
  const toObject = {};
2854
- const fromParts = getValueByPath(fromObject, ['parts']);
2855
- if (fromParts != null) {
2856
- if (Array.isArray(fromParts)) {
2857
- setValueByPath(toObject, ['parts'], fromParts.map((item) => {
2858
- return partToMldev(apiClient, item);
2859
- }));
2860
- }
2861
- else {
2862
- setValueByPath(toObject, ['parts'], fromParts);
2863
- }
2864
- }
2865
- const fromRole = getValueByPath(fromObject, ['role']);
2866
- if (fromRole != null) {
2867
- setValueByPath(toObject, ['role'], fromRole);
2839
+ const fromConfig = getValueByPath(fromObject, ['config']);
2840
+ if (fromConfig != null) {
2841
+ setValueByPath(toObject, ['config'], listFilesConfigToMldev(apiClient, fromConfig, toObject));
2868
2842
  }
2869
2843
  return toObject;
2870
2844
  }
2871
- function schemaToMldev(apiClient, fromObject) {
2845
+ function fileStatusToMldev(apiClient, fromObject) {
2872
2846
  const toObject = {};
2873
- if (getValueByPath(fromObject, ['example']) !== undefined) {
2874
- throw new Error('example parameter is not supported in Gemini API.');
2875
- }
2876
- if (getValueByPath(fromObject, ['pattern']) !== undefined) {
2877
- throw new Error('pattern parameter is not supported in Gemini API.');
2878
- }
2879
- if (getValueByPath(fromObject, ['default']) !== undefined) {
2880
- throw new Error('default parameter is not supported in Gemini API.');
2881
- }
2882
- if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
2883
- throw new Error('maxLength parameter is not supported in Gemini API.');
2847
+ const fromDetails = getValueByPath(fromObject, ['details']);
2848
+ if (fromDetails != null) {
2849
+ setValueByPath(toObject, ['details'], fromDetails);
2884
2850
  }
2885
- if (getValueByPath(fromObject, ['minLength']) !== undefined) {
2886
- throw new Error('minLength parameter is not supported in Gemini API.');
2851
+ const fromMessage = getValueByPath(fromObject, ['message']);
2852
+ if (fromMessage != null) {
2853
+ setValueByPath(toObject, ['message'], fromMessage);
2887
2854
  }
2888
- if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
2889
- throw new Error('minProperties parameter is not supported in Gemini API.');
2855
+ const fromCode = getValueByPath(fromObject, ['code']);
2856
+ if (fromCode != null) {
2857
+ setValueByPath(toObject, ['code'], fromCode);
2890
2858
  }
2891
- if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
2892
- throw new Error('maxProperties parameter is not supported in Gemini API.');
2859
+ return toObject;
2860
+ }
2861
+ function fileToMldev(apiClient, fromObject) {
2862
+ const toObject = {};
2863
+ const fromName = getValueByPath(fromObject, ['name']);
2864
+ if (fromName != null) {
2865
+ setValueByPath(toObject, ['name'], fromName);
2893
2866
  }
2894
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
2895
- if (fromAnyOf != null) {
2896
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
2867
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
2868
+ if (fromDisplayName != null) {
2869
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
2897
2870
  }
2898
- const fromDescription = getValueByPath(fromObject, ['description']);
2899
- if (fromDescription != null) {
2900
- setValueByPath(toObject, ['description'], fromDescription);
2871
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
2872
+ if (fromMimeType != null) {
2873
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
2901
2874
  }
2902
- const fromEnum = getValueByPath(fromObject, ['enum']);
2903
- if (fromEnum != null) {
2904
- setValueByPath(toObject, ['enum'], fromEnum);
2875
+ const fromSizeBytes = getValueByPath(fromObject, ['sizeBytes']);
2876
+ if (fromSizeBytes != null) {
2877
+ setValueByPath(toObject, ['sizeBytes'], fromSizeBytes);
2905
2878
  }
2906
- const fromFormat = getValueByPath(fromObject, ['format']);
2907
- if (fromFormat != null) {
2908
- setValueByPath(toObject, ['format'], fromFormat);
2879
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
2880
+ if (fromCreateTime != null) {
2881
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
2909
2882
  }
2910
- const fromItems = getValueByPath(fromObject, ['items']);
2911
- if (fromItems != null) {
2912
- setValueByPath(toObject, ['items'], fromItems);
2883
+ const fromExpirationTime = getValueByPath(fromObject, [
2884
+ 'expirationTime',
2885
+ ]);
2886
+ if (fromExpirationTime != null) {
2887
+ setValueByPath(toObject, ['expirationTime'], fromExpirationTime);
2913
2888
  }
2914
- const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
2915
- if (fromMaxItems != null) {
2916
- setValueByPath(toObject, ['maxItems'], fromMaxItems);
2889
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
2890
+ if (fromUpdateTime != null) {
2891
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
2917
2892
  }
2918
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
2919
- if (fromMaximum != null) {
2920
- setValueByPath(toObject, ['maximum'], fromMaximum);
2893
+ const fromSha256Hash = getValueByPath(fromObject, ['sha256Hash']);
2894
+ if (fromSha256Hash != null) {
2895
+ setValueByPath(toObject, ['sha256Hash'], fromSha256Hash);
2921
2896
  }
2922
- const fromMinItems = getValueByPath(fromObject, ['minItems']);
2923
- if (fromMinItems != null) {
2924
- setValueByPath(toObject, ['minItems'], fromMinItems);
2897
+ const fromUri = getValueByPath(fromObject, ['uri']);
2898
+ if (fromUri != null) {
2899
+ setValueByPath(toObject, ['uri'], fromUri);
2925
2900
  }
2926
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
2927
- if (fromMinimum != null) {
2928
- setValueByPath(toObject, ['minimum'], fromMinimum);
2901
+ const fromDownloadUri = getValueByPath(fromObject, ['downloadUri']);
2902
+ if (fromDownloadUri != null) {
2903
+ setValueByPath(toObject, ['downloadUri'], fromDownloadUri);
2929
2904
  }
2930
- const fromNullable = getValueByPath(fromObject, ['nullable']);
2931
- if (fromNullable != null) {
2932
- setValueByPath(toObject, ['nullable'], fromNullable);
2905
+ const fromState = getValueByPath(fromObject, ['state']);
2906
+ if (fromState != null) {
2907
+ setValueByPath(toObject, ['state'], fromState);
2933
2908
  }
2934
- const fromProperties = getValueByPath(fromObject, ['properties']);
2935
- if (fromProperties != null) {
2936
- setValueByPath(toObject, ['properties'], fromProperties);
2909
+ const fromSource = getValueByPath(fromObject, ['source']);
2910
+ if (fromSource != null) {
2911
+ setValueByPath(toObject, ['source'], fromSource);
2937
2912
  }
2938
- const fromPropertyOrdering = getValueByPath(fromObject, [
2939
- 'propertyOrdering',
2913
+ const fromVideoMetadata = getValueByPath(fromObject, [
2914
+ 'videoMetadata',
2940
2915
  ]);
2941
- if (fromPropertyOrdering != null) {
2942
- setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
2943
- }
2944
- const fromRequired = getValueByPath(fromObject, ['required']);
2945
- if (fromRequired != null) {
2946
- setValueByPath(toObject, ['required'], fromRequired);
2947
- }
2948
- const fromTitle = getValueByPath(fromObject, ['title']);
2949
- if (fromTitle != null) {
2950
- setValueByPath(toObject, ['title'], fromTitle);
2916
+ if (fromVideoMetadata != null) {
2917
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
2951
2918
  }
2952
- const fromType = getValueByPath(fromObject, ['type']);
2953
- if (fromType != null) {
2954
- setValueByPath(toObject, ['type'], fromType);
2919
+ const fromError = getValueByPath(fromObject, ['error']);
2920
+ if (fromError != null) {
2921
+ setValueByPath(toObject, ['error'], fileStatusToMldev(apiClient, fromError));
2955
2922
  }
2956
2923
  return toObject;
2957
2924
  }
2958
- function safetySettingToMldev(apiClient, fromObject) {
2925
+ function createFileParametersToMldev(apiClient, fromObject) {
2959
2926
  const toObject = {};
2960
- if (getValueByPath(fromObject, ['method']) !== undefined) {
2961
- throw new Error('method parameter is not supported in Gemini API.');
2962
- }
2963
- const fromCategory = getValueByPath(fromObject, ['category']);
2964
- if (fromCategory != null) {
2965
- setValueByPath(toObject, ['category'], fromCategory);
2927
+ const fromFile = getValueByPath(fromObject, ['file']);
2928
+ if (fromFile != null) {
2929
+ setValueByPath(toObject, ['file'], fileToMldev(apiClient, fromFile));
2966
2930
  }
2967
- const fromThreshold = getValueByPath(fromObject, ['threshold']);
2968
- if (fromThreshold != null) {
2969
- setValueByPath(toObject, ['threshold'], fromThreshold);
2931
+ const fromConfig = getValueByPath(fromObject, ['config']);
2932
+ if (fromConfig != null) {
2933
+ setValueByPath(toObject, ['config'], fromConfig);
2970
2934
  }
2971
2935
  return toObject;
2972
2936
  }
2973
- function functionDeclarationToMldev(apiClient, fromObject) {
2937
+ function getFileParametersToMldev(apiClient, fromObject) {
2974
2938
  const toObject = {};
2975
- if (getValueByPath(fromObject, ['response']) !== undefined) {
2976
- throw new Error('response parameter is not supported in Gemini API.');
2977
- }
2978
- const fromDescription = getValueByPath(fromObject, ['description']);
2979
- if (fromDescription != null) {
2980
- setValueByPath(toObject, ['description'], fromDescription);
2981
- }
2982
2939
  const fromName = getValueByPath(fromObject, ['name']);
2983
2940
  if (fromName != null) {
2984
- setValueByPath(toObject, ['name'], fromName);
2941
+ setValueByPath(toObject, ['_url', 'file'], tFileName(apiClient, fromName));
2985
2942
  }
2986
- const fromParameters = getValueByPath(fromObject, ['parameters']);
2987
- if (fromParameters != null) {
2988
- setValueByPath(toObject, ['parameters'], fromParameters);
2943
+ const fromConfig = getValueByPath(fromObject, ['config']);
2944
+ if (fromConfig != null) {
2945
+ setValueByPath(toObject, ['config'], fromConfig);
2989
2946
  }
2990
2947
  return toObject;
2991
2948
  }
2992
- function googleSearchToMldev() {
2993
- const toObject = {};
2994
- return toObject;
2995
- }
2996
- function dynamicRetrievalConfigToMldev(apiClient, fromObject) {
2949
+ function deleteFileParametersToMldev(apiClient, fromObject) {
2997
2950
  const toObject = {};
2998
- const fromMode = getValueByPath(fromObject, ['mode']);
2999
- if (fromMode != null) {
3000
- setValueByPath(toObject, ['mode'], fromMode);
2951
+ const fromName = getValueByPath(fromObject, ['name']);
2952
+ if (fromName != null) {
2953
+ setValueByPath(toObject, ['_url', 'file'], tFileName(apiClient, fromName));
3001
2954
  }
3002
- const fromDynamicThreshold = getValueByPath(fromObject, [
3003
- 'dynamicThreshold',
3004
- ]);
3005
- if (fromDynamicThreshold != null) {
3006
- setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
2955
+ const fromConfig = getValueByPath(fromObject, ['config']);
2956
+ if (fromConfig != null) {
2957
+ setValueByPath(toObject, ['config'], fromConfig);
3007
2958
  }
3008
2959
  return toObject;
3009
2960
  }
3010
- function googleSearchRetrievalToMldev(apiClient, fromObject) {
2961
+ function fileStatusFromMldev(apiClient, fromObject) {
3011
2962
  const toObject = {};
3012
- const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
3013
- 'dynamicRetrievalConfig',
3014
- ]);
3015
- if (fromDynamicRetrievalConfig != null) {
3016
- setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev(apiClient, fromDynamicRetrievalConfig));
2963
+ const fromDetails = getValueByPath(fromObject, ['details']);
2964
+ if (fromDetails != null) {
2965
+ setValueByPath(toObject, ['details'], fromDetails);
2966
+ }
2967
+ const fromMessage = getValueByPath(fromObject, ['message']);
2968
+ if (fromMessage != null) {
2969
+ setValueByPath(toObject, ['message'], fromMessage);
2970
+ }
2971
+ const fromCode = getValueByPath(fromObject, ['code']);
2972
+ if (fromCode != null) {
2973
+ setValueByPath(toObject, ['code'], fromCode);
3017
2974
  }
3018
2975
  return toObject;
3019
2976
  }
3020
- function toolToMldev(apiClient, fromObject) {
2977
+ function fileFromMldev(apiClient, fromObject) {
3021
2978
  const toObject = {};
3022
- const fromFunctionDeclarations = getValueByPath(fromObject, [
3023
- 'functionDeclarations',
3024
- ]);
3025
- if (fromFunctionDeclarations != null) {
3026
- if (Array.isArray(fromFunctionDeclarations)) {
3027
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
3028
- return functionDeclarationToMldev(apiClient, item);
3029
- }));
3030
- }
3031
- else {
3032
- setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
3033
- }
2979
+ const fromName = getValueByPath(fromObject, ['name']);
2980
+ if (fromName != null) {
2981
+ setValueByPath(toObject, ['name'], fromName);
3034
2982
  }
3035
- if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
3036
- throw new Error('retrieval parameter is not supported in Gemini API.');
2983
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
2984
+ if (fromDisplayName != null) {
2985
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
3037
2986
  }
3038
- const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
3039
- if (fromGoogleSearch != null) {
3040
- setValueByPath(toObject, ['googleSearch'], googleSearchToMldev());
2987
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
2988
+ if (fromMimeType != null) {
2989
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3041
2990
  }
3042
- const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
3043
- 'googleSearchRetrieval',
3044
- ]);
3045
- if (fromGoogleSearchRetrieval != null) {
3046
- setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev(apiClient, fromGoogleSearchRetrieval));
2991
+ const fromSizeBytes = getValueByPath(fromObject, ['sizeBytes']);
2992
+ if (fromSizeBytes != null) {
2993
+ setValueByPath(toObject, ['sizeBytes'], fromSizeBytes);
3047
2994
  }
3048
- const fromCodeExecution = getValueByPath(fromObject, [
3049
- 'codeExecution',
2995
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
2996
+ if (fromCreateTime != null) {
2997
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
2998
+ }
2999
+ const fromExpirationTime = getValueByPath(fromObject, [
3000
+ 'expirationTime',
3050
3001
  ]);
3051
- if (fromCodeExecution != null) {
3052
- setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
3002
+ if (fromExpirationTime != null) {
3003
+ setValueByPath(toObject, ['expirationTime'], fromExpirationTime);
3053
3004
  }
3054
- return toObject;
3055
- }
3056
- function functionCallingConfigToMldev(apiClient, fromObject) {
3057
- const toObject = {};
3058
- const fromMode = getValueByPath(fromObject, ['mode']);
3059
- if (fromMode != null) {
3060
- setValueByPath(toObject, ['mode'], fromMode);
3005
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
3006
+ if (fromUpdateTime != null) {
3007
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
3061
3008
  }
3062
- const fromAllowedFunctionNames = getValueByPath(fromObject, [
3063
- 'allowedFunctionNames',
3064
- ]);
3065
- if (fromAllowedFunctionNames != null) {
3066
- setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
3009
+ const fromSha256Hash = getValueByPath(fromObject, ['sha256Hash']);
3010
+ if (fromSha256Hash != null) {
3011
+ setValueByPath(toObject, ['sha256Hash'], fromSha256Hash);
3067
3012
  }
3068
- return toObject;
3069
- }
3070
- function toolConfigToMldev(apiClient, fromObject) {
3071
- const toObject = {};
3072
- const fromFunctionCallingConfig = getValueByPath(fromObject, [
3073
- 'functionCallingConfig',
3013
+ const fromUri = getValueByPath(fromObject, ['uri']);
3014
+ if (fromUri != null) {
3015
+ setValueByPath(toObject, ['uri'], fromUri);
3016
+ }
3017
+ const fromDownloadUri = getValueByPath(fromObject, ['downloadUri']);
3018
+ if (fromDownloadUri != null) {
3019
+ setValueByPath(toObject, ['downloadUri'], fromDownloadUri);
3020
+ }
3021
+ const fromState = getValueByPath(fromObject, ['state']);
3022
+ if (fromState != null) {
3023
+ setValueByPath(toObject, ['state'], fromState);
3024
+ }
3025
+ const fromSource = getValueByPath(fromObject, ['source']);
3026
+ if (fromSource != null) {
3027
+ setValueByPath(toObject, ['source'], fromSource);
3028
+ }
3029
+ const fromVideoMetadata = getValueByPath(fromObject, [
3030
+ 'videoMetadata',
3074
3031
  ]);
3075
- if (fromFunctionCallingConfig != null) {
3076
- setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(apiClient, fromFunctionCallingConfig));
3032
+ if (fromVideoMetadata != null) {
3033
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
3077
3034
  }
3078
- return toObject;
3079
- }
3080
- function prebuiltVoiceConfigToMldev(apiClient, fromObject) {
3081
- const toObject = {};
3082
- const fromVoiceName = getValueByPath(fromObject, ['voiceName']);
3083
- if (fromVoiceName != null) {
3084
- setValueByPath(toObject, ['voiceName'], fromVoiceName);
3035
+ const fromError = getValueByPath(fromObject, ['error']);
3036
+ if (fromError != null) {
3037
+ setValueByPath(toObject, ['error'], fileStatusFromMldev(apiClient, fromError));
3085
3038
  }
3086
3039
  return toObject;
3087
3040
  }
3088
- function voiceConfigToMldev(apiClient, fromObject) {
3041
+ function listFilesResponseFromMldev(apiClient, fromObject) {
3089
3042
  const toObject = {};
3090
- const fromPrebuiltVoiceConfig = getValueByPath(fromObject, [
3091
- 'prebuiltVoiceConfig',
3043
+ const fromNextPageToken = getValueByPath(fromObject, [
3044
+ 'nextPageToken',
3092
3045
  ]);
3093
- if (fromPrebuiltVoiceConfig != null) {
3094
- setValueByPath(toObject, ['prebuiltVoiceConfig'], prebuiltVoiceConfigToMldev(apiClient, fromPrebuiltVoiceConfig));
3046
+ if (fromNextPageToken != null) {
3047
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
3048
+ }
3049
+ const fromFiles = getValueByPath(fromObject, ['files']);
3050
+ if (fromFiles != null) {
3051
+ if (Array.isArray(fromFiles)) {
3052
+ setValueByPath(toObject, ['files'], fromFiles.map((item) => {
3053
+ return fileFromMldev(apiClient, item);
3054
+ }));
3055
+ }
3056
+ else {
3057
+ setValueByPath(toObject, ['files'], fromFiles);
3058
+ }
3095
3059
  }
3096
3060
  return toObject;
3097
3061
  }
3098
- function speechConfigToMldev(apiClient, fromObject) {
3062
+ function createFileResponseFromMldev(apiClient, fromObject) {
3099
3063
  const toObject = {};
3100
- const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
3101
- if (fromVoiceConfig != null) {
3102
- setValueByPath(toObject, ['voiceConfig'], voiceConfigToMldev(apiClient, fromVoiceConfig));
3064
+ const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
3065
+ if (fromHttpHeaders != null) {
3066
+ setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
3103
3067
  }
3104
3068
  return toObject;
3105
3069
  }
3106
- function thinkingConfigToMldev(apiClient, fromObject) {
3070
+ function deleteFileResponseFromMldev() {
3107
3071
  const toObject = {};
3108
- const fromIncludeThoughts = getValueByPath(fromObject, [
3109
- 'includeThoughts',
3110
- ]);
3111
- if (fromIncludeThoughts != null) {
3112
- setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
3113
- }
3114
3072
  return toObject;
3115
3073
  }
3116
- function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
3117
- const toObject = {};
3118
- const fromSystemInstruction = getValueByPath(fromObject, [
3119
- 'systemInstruction',
3120
- ]);
3121
- if (parentObject !== undefined && fromSystemInstruction != null) {
3122
- setValueByPath(parentObject, ['systemInstruction'], contentToMldev(apiClient, tContent(apiClient, fromSystemInstruction)));
3123
- }
3124
- const fromTemperature = getValueByPath(fromObject, ['temperature']);
3125
- if (fromTemperature != null) {
3126
- setValueByPath(toObject, ['temperature'], fromTemperature);
3127
- }
3128
- const fromTopP = getValueByPath(fromObject, ['topP']);
3129
- if (fromTopP != null) {
3130
- setValueByPath(toObject, ['topP'], fromTopP);
3074
+
3075
+ /**
3076
+ * @license
3077
+ * Copyright 2025 Google LLC
3078
+ * SPDX-License-Identifier: Apache-2.0
3079
+ */
3080
+ class Files extends BaseModule {
3081
+ constructor(apiClient) {
3082
+ super();
3083
+ this.apiClient = apiClient;
3084
+ /**
3085
+ * Lists all current project files from the service.
3086
+ *
3087
+ * @param params - The parameters for the list request
3088
+ * @return The paginated results of the list of files
3089
+ *
3090
+ * @example
3091
+ * The following code prints the names of all files from the service, the
3092
+ * size of each page is 10.
3093
+ *
3094
+ * ```ts
3095
+ * const listResponse = await ai.files.list({config: {'pageSize': 10}});
3096
+ * for await (const file of listResponse) {
3097
+ * console.log(file.name);
3098
+ * }
3099
+ * ```
3100
+ */
3101
+ this.list = async (params = {}) => {
3102
+ return new Pager(PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
3103
+ };
3131
3104
  }
3132
- const fromTopK = getValueByPath(fromObject, ['topK']);
3133
- if (fromTopK != null) {
3134
- setValueByPath(toObject, ['topK'], fromTopK);
3105
+ /**
3106
+ * Uploads a file asynchronously to the Gemini API.
3107
+ * This method is not available in Vertex AI.
3108
+ * Supported upload sources:
3109
+ * - Node.js: File path (string) or Blob object.
3110
+ * - Browser: Blob object (e.g., File).
3111
+ *
3112
+ * @remarks
3113
+ * The `mimeType` can be specified in the `config` parameter. If omitted:
3114
+ * - For file path (string) inputs, the `mimeType` will be inferred from the
3115
+ * file extension.
3116
+ * - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
3117
+ * property.
3118
+ * Somex eamples for file extension to mimeType mapping:
3119
+ * .txt -> text/plain
3120
+ * .json -> application/json
3121
+ * .jpg -> image/jpeg
3122
+ * .png -> image/png
3123
+ * .mp3 -> audio/mpeg
3124
+ * .mp4 -> video/mp4
3125
+ *
3126
+ * This section can contain multiple paragraphs and code examples.
3127
+ *
3128
+ * @param params - Optional parameters specified in the
3129
+ * `common.UploadFileParameters` interface.
3130
+ * @return A promise that resolves to a `types.File` object.
3131
+ * @throws An error if called on a Vertex AI client.
3132
+ * @throws An error if the `mimeType` is not provided and can not be inferred,
3133
+ * the `mimeType` can be provided in the `params.config` parameter.
3134
+ * @throws An error occurs if a suitable upload location cannot be established.
3135
+ *
3136
+ * @example
3137
+ * The following code uploads a file to Gemini API.
3138
+ *
3139
+ * ```ts
3140
+ * const file = await ai.files.upload({file: 'file.txt', config: {
3141
+ * mimeType: 'text/plain',
3142
+ * }});
3143
+ * console.log(file.name);
3144
+ * ```
3145
+ */
3146
+ async upload(params) {
3147
+ if (this.apiClient.isVertexAI()) {
3148
+ throw new Error('Vertex AI does not support uploading files. You can share files through a GCS bucket.');
3149
+ }
3150
+ return this.apiClient
3151
+ .uploadFile(params.file, params.config)
3152
+ .then((response) => {
3153
+ const file = fileFromMldev(this.apiClient, response);
3154
+ return file;
3155
+ });
3135
3156
  }
3136
- const fromCandidateCount = getValueByPath(fromObject, [
3137
- 'candidateCount',
3138
- ]);
3139
- if (fromCandidateCount != null) {
3140
- setValueByPath(toObject, ['candidateCount'], fromCandidateCount);
3157
+ async listInternal(params) {
3158
+ var _a;
3159
+ let response;
3160
+ let path = '';
3161
+ let queryParams = {};
3162
+ if (this.apiClient.isVertexAI()) {
3163
+ throw new Error('This method is only supported by the Gemini Developer API.');
3164
+ }
3165
+ else {
3166
+ const body = listFilesParametersToMldev(this.apiClient, params);
3167
+ path = formatMap('files', body['_url']);
3168
+ queryParams = body['_query'];
3169
+ delete body['config'];
3170
+ delete body['_url'];
3171
+ delete body['_query'];
3172
+ response = this.apiClient
3173
+ .request({
3174
+ path: path,
3175
+ queryParams: queryParams,
3176
+ body: JSON.stringify(body),
3177
+ httpMethod: 'GET',
3178
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3179
+ })
3180
+ .then((httpResponse) => {
3181
+ return httpResponse.json();
3182
+ });
3183
+ return response.then((apiResponse) => {
3184
+ const resp = listFilesResponseFromMldev(this.apiClient, apiResponse);
3185
+ const typedResp = new ListFilesResponse();
3186
+ Object.assign(typedResp, resp);
3187
+ return typedResp;
3188
+ });
3189
+ }
3141
3190
  }
3142
- const fromMaxOutputTokens = getValueByPath(fromObject, [
3143
- 'maxOutputTokens',
3144
- ]);
3145
- if (fromMaxOutputTokens != null) {
3146
- setValueByPath(toObject, ['maxOutputTokens'], fromMaxOutputTokens);
3191
+ async createInternal(params) {
3192
+ var _a;
3193
+ let response;
3194
+ let path = '';
3195
+ let queryParams = {};
3196
+ if (this.apiClient.isVertexAI()) {
3197
+ throw new Error('This method is only supported by the Gemini Developer API.');
3198
+ }
3199
+ else {
3200
+ const body = createFileParametersToMldev(this.apiClient, params);
3201
+ path = formatMap('upload/v1beta/files', body['_url']);
3202
+ queryParams = body['_query'];
3203
+ delete body['config'];
3204
+ delete body['_url'];
3205
+ delete body['_query'];
3206
+ response = this.apiClient
3207
+ .request({
3208
+ path: path,
3209
+ queryParams: queryParams,
3210
+ body: JSON.stringify(body),
3211
+ httpMethod: 'POST',
3212
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3213
+ })
3214
+ .then((httpResponse) => {
3215
+ return httpResponse.json();
3216
+ });
3217
+ return response.then((apiResponse) => {
3218
+ const resp = createFileResponseFromMldev(this.apiClient, apiResponse);
3219
+ const typedResp = new CreateFileResponse();
3220
+ Object.assign(typedResp, resp);
3221
+ return typedResp;
3222
+ });
3223
+ }
3147
3224
  }
3148
- const fromStopSequences = getValueByPath(fromObject, [
3149
- 'stopSequences',
3150
- ]);
3151
- if (fromStopSequences != null) {
3152
- setValueByPath(toObject, ['stopSequences'], fromStopSequences);
3225
+ /**
3226
+ * Retrieves the file information from the service.
3227
+ *
3228
+ * @param params - The parameters for the get request
3229
+ * @return The Promise that resolves to the types.File object requested.
3230
+ *
3231
+ * @example
3232
+ * ```ts
3233
+ * const config: GetFileParameters = {
3234
+ * name: fileName,
3235
+ * };
3236
+ * file = await ai.files.get(config);
3237
+ * console.log(file.name);
3238
+ * ```
3239
+ */
3240
+ async get(params) {
3241
+ var _a;
3242
+ let response;
3243
+ let path = '';
3244
+ let queryParams = {};
3245
+ if (this.apiClient.isVertexAI()) {
3246
+ throw new Error('This method is only supported by the Gemini Developer API.');
3247
+ }
3248
+ else {
3249
+ const body = getFileParametersToMldev(this.apiClient, params);
3250
+ path = formatMap('files/{file}', body['_url']);
3251
+ queryParams = body['_query'];
3252
+ delete body['config'];
3253
+ delete body['_url'];
3254
+ delete body['_query'];
3255
+ response = this.apiClient
3256
+ .request({
3257
+ path: path,
3258
+ queryParams: queryParams,
3259
+ body: JSON.stringify(body),
3260
+ httpMethod: 'GET',
3261
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3262
+ })
3263
+ .then((httpResponse) => {
3264
+ return httpResponse.json();
3265
+ });
3266
+ return response.then((apiResponse) => {
3267
+ const resp = fileFromMldev(this.apiClient, apiResponse);
3268
+ return resp;
3269
+ });
3270
+ }
3153
3271
  }
3154
- const fromResponseLogprobs = getValueByPath(fromObject, [
3155
- 'responseLogprobs',
3156
- ]);
3157
- if (fromResponseLogprobs != null) {
3158
- setValueByPath(toObject, ['responseLogprobs'], fromResponseLogprobs);
3272
+ /**
3273
+ * Deletes a remotely stored file.
3274
+ *
3275
+ * @param params - The parameters for the delete request.
3276
+ * @return The DeleteFileResponse, the response for the delete method.
3277
+ *
3278
+ * @example
3279
+ * The following code deletes an example file named "files/mehozpxf877d".
3280
+ *
3281
+ * ```ts
3282
+ * await ai.files.delete({name: file.name});
3283
+ * ```
3284
+ */
3285
+ async delete(params) {
3286
+ var _a;
3287
+ let response;
3288
+ let path = '';
3289
+ let queryParams = {};
3290
+ if (this.apiClient.isVertexAI()) {
3291
+ throw new Error('This method is only supported by the Gemini Developer API.');
3292
+ }
3293
+ else {
3294
+ const body = deleteFileParametersToMldev(this.apiClient, params);
3295
+ path = formatMap('files/{file}', body['_url']);
3296
+ queryParams = body['_query'];
3297
+ delete body['config'];
3298
+ delete body['_url'];
3299
+ delete body['_query'];
3300
+ response = this.apiClient
3301
+ .request({
3302
+ path: path,
3303
+ queryParams: queryParams,
3304
+ body: JSON.stringify(body),
3305
+ httpMethod: 'DELETE',
3306
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3307
+ })
3308
+ .then((httpResponse) => {
3309
+ return httpResponse.json();
3310
+ });
3311
+ return response.then(() => {
3312
+ const resp = deleteFileResponseFromMldev();
3313
+ const typedResp = new DeleteFileResponse();
3314
+ Object.assign(typedResp, resp);
3315
+ return typedResp;
3316
+ });
3317
+ }
3159
3318
  }
3160
- const fromLogprobs = getValueByPath(fromObject, ['logprobs']);
3161
- if (fromLogprobs != null) {
3162
- setValueByPath(toObject, ['logprobs'], fromLogprobs);
3319
+ }
3320
+
3321
+ /**
3322
+ * @license
3323
+ * Copyright 2025 Google LLC
3324
+ * SPDX-License-Identifier: Apache-2.0
3325
+ */
3326
+ function partToMldev(apiClient, fromObject) {
3327
+ const toObject = {};
3328
+ if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
3329
+ throw new Error('videoMetadata parameter is not supported in Gemini API.');
3163
3330
  }
3164
- const fromPresencePenalty = getValueByPath(fromObject, [
3165
- 'presencePenalty',
3331
+ const fromThought = getValueByPath(fromObject, ['thought']);
3332
+ if (fromThought != null) {
3333
+ setValueByPath(toObject, ['thought'], fromThought);
3334
+ }
3335
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
3336
+ 'codeExecutionResult',
3166
3337
  ]);
3167
- if (fromPresencePenalty != null) {
3168
- setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
3338
+ if (fromCodeExecutionResult != null) {
3339
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
3169
3340
  }
3170
- const fromFrequencyPenalty = getValueByPath(fromObject, [
3171
- 'frequencyPenalty',
3341
+ const fromExecutableCode = getValueByPath(fromObject, [
3342
+ 'executableCode',
3172
3343
  ]);
3173
- if (fromFrequencyPenalty != null) {
3174
- setValueByPath(toObject, ['frequencyPenalty'], fromFrequencyPenalty);
3344
+ if (fromExecutableCode != null) {
3345
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
3175
3346
  }
3176
- const fromSeed = getValueByPath(fromObject, ['seed']);
3177
- if (fromSeed != null) {
3178
- setValueByPath(toObject, ['seed'], fromSeed);
3347
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
3348
+ if (fromFileData != null) {
3349
+ setValueByPath(toObject, ['fileData'], fromFileData);
3179
3350
  }
3180
- const fromResponseMimeType = getValueByPath(fromObject, [
3181
- 'responseMimeType',
3182
- ]);
3183
- if (fromResponseMimeType != null) {
3184
- setValueByPath(toObject, ['responseMimeType'], fromResponseMimeType);
3351
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
3352
+ if (fromFunctionCall != null) {
3353
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
3185
3354
  }
3186
- const fromResponseSchema = getValueByPath(fromObject, [
3187
- 'responseSchema',
3355
+ const fromFunctionResponse = getValueByPath(fromObject, [
3356
+ 'functionResponse',
3188
3357
  ]);
3189
- if (fromResponseSchema != null) {
3190
- setValueByPath(toObject, ['responseSchema'], schemaToMldev(apiClient, tSchema(apiClient, fromResponseSchema)));
3358
+ if (fromFunctionResponse != null) {
3359
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
3191
3360
  }
3192
- if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
3193
- throw new Error('routingConfig parameter is not supported in Gemini API.');
3361
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3362
+ if (fromInlineData != null) {
3363
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
3194
3364
  }
3195
- const fromSafetySettings = getValueByPath(fromObject, [
3196
- 'safetySettings',
3197
- ]);
3198
- if (parentObject !== undefined && fromSafetySettings != null) {
3199
- if (Array.isArray(fromSafetySettings)) {
3200
- setValueByPath(parentObject, ['safetySettings'], fromSafetySettings.map((item) => {
3201
- return safetySettingToMldev(apiClient, item);
3365
+ const fromText = getValueByPath(fromObject, ['text']);
3366
+ if (fromText != null) {
3367
+ setValueByPath(toObject, ['text'], fromText);
3368
+ }
3369
+ return toObject;
3370
+ }
3371
+ function contentToMldev(apiClient, fromObject) {
3372
+ const toObject = {};
3373
+ const fromParts = getValueByPath(fromObject, ['parts']);
3374
+ if (fromParts != null) {
3375
+ if (Array.isArray(fromParts)) {
3376
+ setValueByPath(toObject, ['parts'], fromParts.map((item) => {
3377
+ return partToMldev(apiClient, item);
3202
3378
  }));
3203
3379
  }
3204
3380
  else {
3205
- setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
3381
+ setValueByPath(toObject, ['parts'], fromParts);
3206
3382
  }
3207
3383
  }
3208
- const fromTools = getValueByPath(fromObject, ['tools']);
3209
- if (parentObject !== undefined && fromTools != null) {
3210
- if (Array.isArray(fromTools)) {
3211
- setValueByPath(parentObject, ['tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
3212
- return toolToMldev(apiClient, tTool(apiClient, item));
3213
- })));
3214
- }
3215
- else {
3216
- setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
3217
- }
3384
+ const fromRole = getValueByPath(fromObject, ['role']);
3385
+ if (fromRole != null) {
3386
+ setValueByPath(toObject, ['role'], fromRole);
3218
3387
  }
3219
- const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
3220
- if (parentObject !== undefined && fromToolConfig != null) {
3221
- setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev(apiClient, fromToolConfig));
3388
+ return toObject;
3389
+ }
3390
+ function schemaToMldev(apiClient, fromObject) {
3391
+ const toObject = {};
3392
+ if (getValueByPath(fromObject, ['example']) !== undefined) {
3393
+ throw new Error('example parameter is not supported in Gemini API.');
3222
3394
  }
3223
- if (getValueByPath(fromObject, ['labels']) !== undefined) {
3224
- throw new Error('labels parameter is not supported in Gemini API.');
3395
+ if (getValueByPath(fromObject, ['pattern']) !== undefined) {
3396
+ throw new Error('pattern parameter is not supported in Gemini API.');
3225
3397
  }
3226
- const fromCachedContent = getValueByPath(fromObject, [
3227
- 'cachedContent',
3228
- ]);
3229
- if (parentObject !== undefined && fromCachedContent != null) {
3230
- setValueByPath(parentObject, ['cachedContent'], tCachedContentName(apiClient, fromCachedContent));
3398
+ if (getValueByPath(fromObject, ['default']) !== undefined) {
3399
+ throw new Error('default parameter is not supported in Gemini API.');
3231
3400
  }
3232
- const fromResponseModalities = getValueByPath(fromObject, [
3233
- 'responseModalities',
3234
- ]);
3235
- if (fromResponseModalities != null) {
3236
- setValueByPath(toObject, ['responseModalities'], fromResponseModalities);
3401
+ if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
3402
+ throw new Error('maxLength parameter is not supported in Gemini API.');
3237
3403
  }
3238
- const fromMediaResolution = getValueByPath(fromObject, [
3239
- 'mediaResolution',
3240
- ]);
3241
- if (fromMediaResolution != null) {
3242
- setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
3404
+ if (getValueByPath(fromObject, ['minLength']) !== undefined) {
3405
+ throw new Error('minLength parameter is not supported in Gemini API.');
3243
3406
  }
3244
- const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
3245
- if (fromSpeechConfig != null) {
3246
- setValueByPath(toObject, ['speechConfig'], speechConfigToMldev(apiClient, tSpeechConfig(apiClient, fromSpeechConfig)));
3407
+ if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
3408
+ throw new Error('minProperties parameter is not supported in Gemini API.');
3247
3409
  }
3248
- if (getValueByPath(fromObject, ['audioTimestamp']) !== undefined) {
3249
- throw new Error('audioTimestamp parameter is not supported in Gemini API.');
3410
+ if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
3411
+ throw new Error('maxProperties parameter is not supported in Gemini API.');
3250
3412
  }
3251
- const fromThinkingConfig = getValueByPath(fromObject, [
3252
- 'thinkingConfig',
3413
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
3414
+ if (fromAnyOf != null) {
3415
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
3416
+ }
3417
+ const fromDescription = getValueByPath(fromObject, ['description']);
3418
+ if (fromDescription != null) {
3419
+ setValueByPath(toObject, ['description'], fromDescription);
3420
+ }
3421
+ const fromEnum = getValueByPath(fromObject, ['enum']);
3422
+ if (fromEnum != null) {
3423
+ setValueByPath(toObject, ['enum'], fromEnum);
3424
+ }
3425
+ const fromFormat = getValueByPath(fromObject, ['format']);
3426
+ if (fromFormat != null) {
3427
+ setValueByPath(toObject, ['format'], fromFormat);
3428
+ }
3429
+ const fromItems = getValueByPath(fromObject, ['items']);
3430
+ if (fromItems != null) {
3431
+ setValueByPath(toObject, ['items'], fromItems);
3432
+ }
3433
+ const fromMaxItems = getValueByPath(fromObject, ['maxItems']);
3434
+ if (fromMaxItems != null) {
3435
+ setValueByPath(toObject, ['maxItems'], fromMaxItems);
3436
+ }
3437
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
3438
+ if (fromMaximum != null) {
3439
+ setValueByPath(toObject, ['maximum'], fromMaximum);
3440
+ }
3441
+ const fromMinItems = getValueByPath(fromObject, ['minItems']);
3442
+ if (fromMinItems != null) {
3443
+ setValueByPath(toObject, ['minItems'], fromMinItems);
3444
+ }
3445
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
3446
+ if (fromMinimum != null) {
3447
+ setValueByPath(toObject, ['minimum'], fromMinimum);
3448
+ }
3449
+ const fromNullable = getValueByPath(fromObject, ['nullable']);
3450
+ if (fromNullable != null) {
3451
+ setValueByPath(toObject, ['nullable'], fromNullable);
3452
+ }
3453
+ const fromProperties = getValueByPath(fromObject, ['properties']);
3454
+ if (fromProperties != null) {
3455
+ setValueByPath(toObject, ['properties'], fromProperties);
3456
+ }
3457
+ const fromPropertyOrdering = getValueByPath(fromObject, [
3458
+ 'propertyOrdering',
3253
3459
  ]);
3254
- if (fromThinkingConfig != null) {
3255
- setValueByPath(toObject, ['thinkingConfig'], thinkingConfigToMldev(apiClient, fromThinkingConfig));
3460
+ if (fromPropertyOrdering != null) {
3461
+ setValueByPath(toObject, ['propertyOrdering'], fromPropertyOrdering);
3462
+ }
3463
+ const fromRequired = getValueByPath(fromObject, ['required']);
3464
+ if (fromRequired != null) {
3465
+ setValueByPath(toObject, ['required'], fromRequired);
3466
+ }
3467
+ const fromTitle = getValueByPath(fromObject, ['title']);
3468
+ if (fromTitle != null) {
3469
+ setValueByPath(toObject, ['title'], fromTitle);
3470
+ }
3471
+ const fromType = getValueByPath(fromObject, ['type']);
3472
+ if (fromType != null) {
3473
+ setValueByPath(toObject, ['type'], fromType);
3256
3474
  }
3257
3475
  return toObject;
3258
3476
  }
3259
- function generateContentParametersToMldev(apiClient, fromObject) {
3477
+ function safetySettingToMldev(apiClient, fromObject) {
3260
3478
  const toObject = {};
3261
- const fromModel = getValueByPath(fromObject, ['model']);
3262
- if (fromModel != null) {
3263
- setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3479
+ if (getValueByPath(fromObject, ['method']) !== undefined) {
3480
+ throw new Error('method parameter is not supported in Gemini API.');
3264
3481
  }
3265
- const fromContents = getValueByPath(fromObject, ['contents']);
3266
- if (fromContents != null) {
3267
- if (Array.isArray(fromContents)) {
3268
- setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
3269
- return contentToMldev(apiClient, item);
3270
- })));
3271
- }
3272
- else {
3273
- setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
3274
- }
3482
+ const fromCategory = getValueByPath(fromObject, ['category']);
3483
+ if (fromCategory != null) {
3484
+ setValueByPath(toObject, ['category'], fromCategory);
3275
3485
  }
3276
- const fromConfig = getValueByPath(fromObject, ['config']);
3277
- if (fromConfig != null) {
3278
- setValueByPath(toObject, ['generationConfig'], generateContentConfigToMldev(apiClient, fromConfig, toObject));
3486
+ const fromThreshold = getValueByPath(fromObject, ['threshold']);
3487
+ if (fromThreshold != null) {
3488
+ setValueByPath(toObject, ['threshold'], fromThreshold);
3279
3489
  }
3280
3490
  return toObject;
3281
3491
  }
3282
- function embedContentConfigToMldev(apiClient, fromObject, parentObject) {
3492
+ function functionDeclarationToMldev(apiClient, fromObject) {
3283
3493
  const toObject = {};
3284
- const fromTaskType = getValueByPath(fromObject, ['taskType']);
3285
- if (parentObject !== undefined && fromTaskType != null) {
3286
- setValueByPath(parentObject, ['requests[]', 'taskType'], fromTaskType);
3287
- }
3288
- const fromTitle = getValueByPath(fromObject, ['title']);
3289
- if (parentObject !== undefined && fromTitle != null) {
3290
- setValueByPath(parentObject, ['requests[]', 'title'], fromTitle);
3494
+ if (getValueByPath(fromObject, ['response']) !== undefined) {
3495
+ throw new Error('response parameter is not supported in Gemini API.');
3291
3496
  }
3292
- const fromOutputDimensionality = getValueByPath(fromObject, [
3293
- 'outputDimensionality',
3294
- ]);
3295
- if (parentObject !== undefined && fromOutputDimensionality != null) {
3296
- setValueByPath(parentObject, ['requests[]', 'outputDimensionality'], fromOutputDimensionality);
3497
+ const fromDescription = getValueByPath(fromObject, ['description']);
3498
+ if (fromDescription != null) {
3499
+ setValueByPath(toObject, ['description'], fromDescription);
3297
3500
  }
3298
- if (getValueByPath(fromObject, ['mimeType']) !== undefined) {
3299
- throw new Error('mimeType parameter is not supported in Gemini API.');
3501
+ const fromName = getValueByPath(fromObject, ['name']);
3502
+ if (fromName != null) {
3503
+ setValueByPath(toObject, ['name'], fromName);
3300
3504
  }
3301
- if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
3302
- throw new Error('autoTruncate parameter is not supported in Gemini API.');
3505
+ const fromParameters = getValueByPath(fromObject, ['parameters']);
3506
+ if (fromParameters != null) {
3507
+ setValueByPath(toObject, ['parameters'], fromParameters);
3303
3508
  }
3304
3509
  return toObject;
3305
3510
  }
3306
- function embedContentParametersToMldev(apiClient, fromObject) {
3511
+ function googleSearchToMldev() {
3307
3512
  const toObject = {};
3308
- const fromModel = getValueByPath(fromObject, ['model']);
3309
- if (fromModel != null) {
3310
- setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3311
- }
3312
- const fromContents = getValueByPath(fromObject, ['contents']);
3313
- if (fromContents != null) {
3314
- setValueByPath(toObject, ['requests[]', 'content'], tContentsForEmbed(apiClient, fromContents));
3513
+ return toObject;
3514
+ }
3515
+ function dynamicRetrievalConfigToMldev(apiClient, fromObject) {
3516
+ const toObject = {};
3517
+ const fromMode = getValueByPath(fromObject, ['mode']);
3518
+ if (fromMode != null) {
3519
+ setValueByPath(toObject, ['mode'], fromMode);
3315
3520
  }
3316
- const fromConfig = getValueByPath(fromObject, ['config']);
3317
- if (fromConfig != null) {
3318
- setValueByPath(toObject, ['config'], embedContentConfigToMldev(apiClient, fromConfig, toObject));
3521
+ const fromDynamicThreshold = getValueByPath(fromObject, [
3522
+ 'dynamicThreshold',
3523
+ ]);
3524
+ if (fromDynamicThreshold != null) {
3525
+ setValueByPath(toObject, ['dynamicThreshold'], fromDynamicThreshold);
3319
3526
  }
3320
- const fromModelForEmbedContent = getValueByPath(fromObject, ['model']);
3321
- if (fromModelForEmbedContent !== undefined) {
3322
- setValueByPath(toObject, ['requests[]', 'model'], tModel(apiClient, fromModelForEmbedContent));
3527
+ return toObject;
3528
+ }
3529
+ function googleSearchRetrievalToMldev(apiClient, fromObject) {
3530
+ const toObject = {};
3531
+ const fromDynamicRetrievalConfig = getValueByPath(fromObject, [
3532
+ 'dynamicRetrievalConfig',
3533
+ ]);
3534
+ if (fromDynamicRetrievalConfig != null) {
3535
+ setValueByPath(toObject, ['dynamicRetrievalConfig'], dynamicRetrievalConfigToMldev(apiClient, fromDynamicRetrievalConfig));
3323
3536
  }
3324
3537
  return toObject;
3325
3538
  }
3326
- function generateImagesConfigToMldev(apiClient, fromObject, parentObject) {
3539
+ function toolToMldev(apiClient, fromObject) {
3327
3540
  const toObject = {};
3328
- if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
3329
- throw new Error('outputGcsUri parameter is not supported in Gemini API.');
3541
+ const fromFunctionDeclarations = getValueByPath(fromObject, [
3542
+ 'functionDeclarations',
3543
+ ]);
3544
+ if (fromFunctionDeclarations != null) {
3545
+ if (Array.isArray(fromFunctionDeclarations)) {
3546
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations.map((item) => {
3547
+ return functionDeclarationToMldev(apiClient, item);
3548
+ }));
3549
+ }
3550
+ else {
3551
+ setValueByPath(toObject, ['functionDeclarations'], fromFunctionDeclarations);
3552
+ }
3330
3553
  }
3331
- if (getValueByPath(fromObject, ['negativePrompt']) !== undefined) {
3332
- throw new Error('negativePrompt parameter is not supported in Gemini API.');
3554
+ if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
3555
+ throw new Error('retrieval parameter is not supported in Gemini API.');
3333
3556
  }
3334
- const fromNumberOfImages = getValueByPath(fromObject, [
3335
- 'numberOfImages',
3336
- ]);
3337
- if (parentObject !== undefined && fromNumberOfImages != null) {
3338
- setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
3557
+ const fromGoogleSearch = getValueByPath(fromObject, ['googleSearch']);
3558
+ if (fromGoogleSearch != null) {
3559
+ setValueByPath(toObject, ['googleSearch'], googleSearchToMldev());
3339
3560
  }
3340
- const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
3341
- if (parentObject !== undefined && fromAspectRatio != null) {
3342
- setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
3561
+ const fromGoogleSearchRetrieval = getValueByPath(fromObject, [
3562
+ 'googleSearchRetrieval',
3563
+ ]);
3564
+ if (fromGoogleSearchRetrieval != null) {
3565
+ setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev(apiClient, fromGoogleSearchRetrieval));
3343
3566
  }
3344
- const fromGuidanceScale = getValueByPath(fromObject, [
3345
- 'guidanceScale',
3567
+ const fromCodeExecution = getValueByPath(fromObject, [
3568
+ 'codeExecution',
3346
3569
  ]);
3347
- if (parentObject !== undefined && fromGuidanceScale != null) {
3348
- setValueByPath(parentObject, ['parameters', 'guidanceScale'], fromGuidanceScale);
3570
+ if (fromCodeExecution != null) {
3571
+ setValueByPath(toObject, ['codeExecution'], fromCodeExecution);
3349
3572
  }
3350
- if (getValueByPath(fromObject, ['seed']) !== undefined) {
3351
- throw new Error('seed parameter is not supported in Gemini API.');
3573
+ return toObject;
3574
+ }
3575
+ function functionCallingConfigToMldev(apiClient, fromObject) {
3576
+ const toObject = {};
3577
+ const fromMode = getValueByPath(fromObject, ['mode']);
3578
+ if (fromMode != null) {
3579
+ setValueByPath(toObject, ['mode'], fromMode);
3352
3580
  }
3353
- const fromSafetyFilterLevel = getValueByPath(fromObject, [
3354
- 'safetyFilterLevel',
3581
+ const fromAllowedFunctionNames = getValueByPath(fromObject, [
3582
+ 'allowedFunctionNames',
3355
3583
  ]);
3356
- if (parentObject !== undefined && fromSafetyFilterLevel != null) {
3357
- setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
3584
+ if (fromAllowedFunctionNames != null) {
3585
+ setValueByPath(toObject, ['allowedFunctionNames'], fromAllowedFunctionNames);
3358
3586
  }
3359
- const fromPersonGeneration = getValueByPath(fromObject, [
3360
- 'personGeneration',
3587
+ return toObject;
3588
+ }
3589
+ function toolConfigToMldev(apiClient, fromObject) {
3590
+ const toObject = {};
3591
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
3592
+ 'functionCallingConfig',
3361
3593
  ]);
3362
- if (parentObject !== undefined && fromPersonGeneration != null) {
3363
- setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
3594
+ if (fromFunctionCallingConfig != null) {
3595
+ setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(apiClient, fromFunctionCallingConfig));
3364
3596
  }
3365
- const fromIncludeSafetyAttributes = getValueByPath(fromObject, [
3366
- 'includeSafetyAttributes',
3597
+ return toObject;
3598
+ }
3599
+ function prebuiltVoiceConfigToMldev(apiClient, fromObject) {
3600
+ const toObject = {};
3601
+ const fromVoiceName = getValueByPath(fromObject, ['voiceName']);
3602
+ if (fromVoiceName != null) {
3603
+ setValueByPath(toObject, ['voiceName'], fromVoiceName);
3604
+ }
3605
+ return toObject;
3606
+ }
3607
+ function voiceConfigToMldev(apiClient, fromObject) {
3608
+ const toObject = {};
3609
+ const fromPrebuiltVoiceConfig = getValueByPath(fromObject, [
3610
+ 'prebuiltVoiceConfig',
3367
3611
  ]);
3368
- if (parentObject !== undefined && fromIncludeSafetyAttributes != null) {
3369
- setValueByPath(parentObject, ['parameters', 'includeSafetyAttributes'], fromIncludeSafetyAttributes);
3612
+ if (fromPrebuiltVoiceConfig != null) {
3613
+ setValueByPath(toObject, ['prebuiltVoiceConfig'], prebuiltVoiceConfigToMldev(apiClient, fromPrebuiltVoiceConfig));
3370
3614
  }
3371
- const fromIncludeRaiReason = getValueByPath(fromObject, [
3372
- 'includeRaiReason',
3615
+ return toObject;
3616
+ }
3617
+ function speechConfigToMldev(apiClient, fromObject) {
3618
+ const toObject = {};
3619
+ const fromVoiceConfig = getValueByPath(fromObject, ['voiceConfig']);
3620
+ if (fromVoiceConfig != null) {
3621
+ setValueByPath(toObject, ['voiceConfig'], voiceConfigToMldev(apiClient, fromVoiceConfig));
3622
+ }
3623
+ return toObject;
3624
+ }
3625
+ function thinkingConfigToMldev(apiClient, fromObject) {
3626
+ const toObject = {};
3627
+ const fromIncludeThoughts = getValueByPath(fromObject, [
3628
+ 'includeThoughts',
3373
3629
  ]);
3374
- if (parentObject !== undefined && fromIncludeRaiReason != null) {
3375
- setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
3630
+ if (fromIncludeThoughts != null) {
3631
+ setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
3376
3632
  }
3377
- const fromLanguage = getValueByPath(fromObject, ['language']);
3378
- if (parentObject !== undefined && fromLanguage != null) {
3379
- setValueByPath(parentObject, ['parameters', 'language'], fromLanguage);
3633
+ return toObject;
3634
+ }
3635
+ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
3636
+ const toObject = {};
3637
+ const fromSystemInstruction = getValueByPath(fromObject, [
3638
+ 'systemInstruction',
3639
+ ]);
3640
+ if (parentObject !== undefined && fromSystemInstruction != null) {
3641
+ setValueByPath(parentObject, ['systemInstruction'], contentToMldev(apiClient, tContent(apiClient, fromSystemInstruction)));
3380
3642
  }
3381
- const fromOutputMimeType = getValueByPath(fromObject, [
3382
- 'outputMimeType',
3643
+ const fromTemperature = getValueByPath(fromObject, ['temperature']);
3644
+ if (fromTemperature != null) {
3645
+ setValueByPath(toObject, ['temperature'], fromTemperature);
3646
+ }
3647
+ const fromTopP = getValueByPath(fromObject, ['topP']);
3648
+ if (fromTopP != null) {
3649
+ setValueByPath(toObject, ['topP'], fromTopP);
3650
+ }
3651
+ const fromTopK = getValueByPath(fromObject, ['topK']);
3652
+ if (fromTopK != null) {
3653
+ setValueByPath(toObject, ['topK'], fromTopK);
3654
+ }
3655
+ const fromCandidateCount = getValueByPath(fromObject, [
3656
+ 'candidateCount',
3383
3657
  ]);
3384
- if (parentObject !== undefined && fromOutputMimeType != null) {
3385
- setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
3658
+ if (fromCandidateCount != null) {
3659
+ setValueByPath(toObject, ['candidateCount'], fromCandidateCount);
3386
3660
  }
3387
- const fromOutputCompressionQuality = getValueByPath(fromObject, [
3388
- 'outputCompressionQuality',
3661
+ const fromMaxOutputTokens = getValueByPath(fromObject, [
3662
+ 'maxOutputTokens',
3389
3663
  ]);
3390
- if (parentObject !== undefined && fromOutputCompressionQuality != null) {
3391
- setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
3664
+ if (fromMaxOutputTokens != null) {
3665
+ setValueByPath(toObject, ['maxOutputTokens'], fromMaxOutputTokens);
3392
3666
  }
3393
- if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
3394
- throw new Error('addWatermark parameter is not supported in Gemini API.');
3667
+ const fromStopSequences = getValueByPath(fromObject, [
3668
+ 'stopSequences',
3669
+ ]);
3670
+ if (fromStopSequences != null) {
3671
+ setValueByPath(toObject, ['stopSequences'], fromStopSequences);
3395
3672
  }
3396
- if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
3397
- throw new Error('enhancePrompt parameter is not supported in Gemini API.');
3673
+ const fromResponseLogprobs = getValueByPath(fromObject, [
3674
+ 'responseLogprobs',
3675
+ ]);
3676
+ if (fromResponseLogprobs != null) {
3677
+ setValueByPath(toObject, ['responseLogprobs'], fromResponseLogprobs);
3398
3678
  }
3399
- return toObject;
3400
- }
3401
- function generateImagesParametersToMldev(apiClient, fromObject) {
3402
- const toObject = {};
3403
- const fromModel = getValueByPath(fromObject, ['model']);
3404
- if (fromModel != null) {
3405
- setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3679
+ const fromLogprobs = getValueByPath(fromObject, ['logprobs']);
3680
+ if (fromLogprobs != null) {
3681
+ setValueByPath(toObject, ['logprobs'], fromLogprobs);
3406
3682
  }
3407
- const fromPrompt = getValueByPath(fromObject, ['prompt']);
3408
- if (fromPrompt != null) {
3409
- setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
3683
+ const fromPresencePenalty = getValueByPath(fromObject, [
3684
+ 'presencePenalty',
3685
+ ]);
3686
+ if (fromPresencePenalty != null) {
3687
+ setValueByPath(toObject, ['presencePenalty'], fromPresencePenalty);
3410
3688
  }
3411
- const fromConfig = getValueByPath(fromObject, ['config']);
3412
- if (fromConfig != null) {
3413
- setValueByPath(toObject, ['config'], generateImagesConfigToMldev(apiClient, fromConfig, toObject));
3689
+ const fromFrequencyPenalty = getValueByPath(fromObject, [
3690
+ 'frequencyPenalty',
3691
+ ]);
3692
+ if (fromFrequencyPenalty != null) {
3693
+ setValueByPath(toObject, ['frequencyPenalty'], fromFrequencyPenalty);
3414
3694
  }
3415
- return toObject;
3416
- }
3417
- function countTokensConfigToMldev(apiClient, fromObject) {
3418
- const toObject = {};
3419
- if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
3420
- throw new Error('systemInstruction parameter is not supported in Gemini API.');
3695
+ const fromSeed = getValueByPath(fromObject, ['seed']);
3696
+ if (fromSeed != null) {
3697
+ setValueByPath(toObject, ['seed'], fromSeed);
3421
3698
  }
3422
- if (getValueByPath(fromObject, ['tools']) !== undefined) {
3423
- throw new Error('tools parameter is not supported in Gemini API.');
3699
+ const fromResponseMimeType = getValueByPath(fromObject, [
3700
+ 'responseMimeType',
3701
+ ]);
3702
+ if (fromResponseMimeType != null) {
3703
+ setValueByPath(toObject, ['responseMimeType'], fromResponseMimeType);
3424
3704
  }
3425
- if (getValueByPath(fromObject, ['generationConfig']) !== undefined) {
3426
- throw new Error('generationConfig parameter is not supported in Gemini API.');
3705
+ const fromResponseSchema = getValueByPath(fromObject, [
3706
+ 'responseSchema',
3707
+ ]);
3708
+ if (fromResponseSchema != null) {
3709
+ setValueByPath(toObject, ['responseSchema'], schemaToMldev(apiClient, tSchema(apiClient, fromResponseSchema)));
3710
+ }
3711
+ if (getValueByPath(fromObject, ['routingConfig']) !== undefined) {
3712
+ throw new Error('routingConfig parameter is not supported in Gemini API.');
3713
+ }
3714
+ const fromSafetySettings = getValueByPath(fromObject, [
3715
+ 'safetySettings',
3716
+ ]);
3717
+ if (parentObject !== undefined && fromSafetySettings != null) {
3718
+ if (Array.isArray(fromSafetySettings)) {
3719
+ setValueByPath(parentObject, ['safetySettings'], fromSafetySettings.map((item) => {
3720
+ return safetySettingToMldev(apiClient, item);
3721
+ }));
3722
+ }
3723
+ else {
3724
+ setValueByPath(parentObject, ['safetySettings'], fromSafetySettings);
3725
+ }
3726
+ }
3727
+ const fromTools = getValueByPath(fromObject, ['tools']);
3728
+ if (parentObject !== undefined && fromTools != null) {
3729
+ if (Array.isArray(fromTools)) {
3730
+ setValueByPath(parentObject, ['tools'], tTools(apiClient, tTools(apiClient, fromTools).map((item) => {
3731
+ return toolToMldev(apiClient, tTool(apiClient, item));
3732
+ })));
3733
+ }
3734
+ else {
3735
+ setValueByPath(parentObject, ['tools'], tTools(apiClient, fromTools));
3736
+ }
3737
+ }
3738
+ const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
3739
+ if (parentObject !== undefined && fromToolConfig != null) {
3740
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToMldev(apiClient, fromToolConfig));
3741
+ }
3742
+ if (getValueByPath(fromObject, ['labels']) !== undefined) {
3743
+ throw new Error('labels parameter is not supported in Gemini API.');
3744
+ }
3745
+ const fromCachedContent = getValueByPath(fromObject, [
3746
+ 'cachedContent',
3747
+ ]);
3748
+ if (parentObject !== undefined && fromCachedContent != null) {
3749
+ setValueByPath(parentObject, ['cachedContent'], tCachedContentName(apiClient, fromCachedContent));
3750
+ }
3751
+ const fromResponseModalities = getValueByPath(fromObject, [
3752
+ 'responseModalities',
3753
+ ]);
3754
+ if (fromResponseModalities != null) {
3755
+ setValueByPath(toObject, ['responseModalities'], fromResponseModalities);
3756
+ }
3757
+ const fromMediaResolution = getValueByPath(fromObject, [
3758
+ 'mediaResolution',
3759
+ ]);
3760
+ if (fromMediaResolution != null) {
3761
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
3762
+ }
3763
+ const fromSpeechConfig = getValueByPath(fromObject, ['speechConfig']);
3764
+ if (fromSpeechConfig != null) {
3765
+ setValueByPath(toObject, ['speechConfig'], speechConfigToMldev(apiClient, tSpeechConfig(apiClient, fromSpeechConfig)));
3766
+ }
3767
+ if (getValueByPath(fromObject, ['audioTimestamp']) !== undefined) {
3768
+ throw new Error('audioTimestamp parameter is not supported in Gemini API.');
3769
+ }
3770
+ const fromThinkingConfig = getValueByPath(fromObject, [
3771
+ 'thinkingConfig',
3772
+ ]);
3773
+ if (fromThinkingConfig != null) {
3774
+ setValueByPath(toObject, ['thinkingConfig'], thinkingConfigToMldev(apiClient, fromThinkingConfig));
3427
3775
  }
3428
3776
  return toObject;
3429
3777
  }
3430
- function countTokensParametersToMldev(apiClient, fromObject) {
3778
+ function generateContentParametersToMldev(apiClient, fromObject) {
3431
3779
  const toObject = {};
3432
3780
  const fromModel = getValueByPath(fromObject, ['model']);
3433
3781
  if (fromModel != null) {
@@ -3446,21 +3794,277 @@ function countTokensParametersToMldev(apiClient, fromObject) {
3446
3794
  }
3447
3795
  const fromConfig = getValueByPath(fromObject, ['config']);
3448
3796
  if (fromConfig != null) {
3449
- setValueByPath(toObject, ['config'], countTokensConfigToMldev(apiClient, fromConfig));
3797
+ setValueByPath(toObject, ['generationConfig'], generateContentConfigToMldev(apiClient, fromConfig, toObject));
3450
3798
  }
3451
3799
  return toObject;
3452
3800
  }
3453
- function partToVertex(apiClient, fromObject) {
3801
+ function embedContentConfigToMldev(apiClient, fromObject, parentObject) {
3454
3802
  const toObject = {};
3455
- const fromVideoMetadata = getValueByPath(fromObject, [
3456
- 'videoMetadata',
3457
- ]);
3458
- if (fromVideoMetadata != null) {
3459
- setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
3803
+ const fromTaskType = getValueByPath(fromObject, ['taskType']);
3804
+ if (parentObject !== undefined && fromTaskType != null) {
3805
+ setValueByPath(parentObject, ['requests[]', 'taskType'], fromTaskType);
3460
3806
  }
3461
- const fromThought = getValueByPath(fromObject, ['thought']);
3462
- if (fromThought != null) {
3463
- setValueByPath(toObject, ['thought'], fromThought);
3807
+ const fromTitle = getValueByPath(fromObject, ['title']);
3808
+ if (parentObject !== undefined && fromTitle != null) {
3809
+ setValueByPath(parentObject, ['requests[]', 'title'], fromTitle);
3810
+ }
3811
+ const fromOutputDimensionality = getValueByPath(fromObject, [
3812
+ 'outputDimensionality',
3813
+ ]);
3814
+ if (parentObject !== undefined && fromOutputDimensionality != null) {
3815
+ setValueByPath(parentObject, ['requests[]', 'outputDimensionality'], fromOutputDimensionality);
3816
+ }
3817
+ if (getValueByPath(fromObject, ['mimeType']) !== undefined) {
3818
+ throw new Error('mimeType parameter is not supported in Gemini API.');
3819
+ }
3820
+ if (getValueByPath(fromObject, ['autoTruncate']) !== undefined) {
3821
+ throw new Error('autoTruncate parameter is not supported in Gemini API.');
3822
+ }
3823
+ return toObject;
3824
+ }
3825
+ function embedContentParametersToMldev(apiClient, fromObject) {
3826
+ const toObject = {};
3827
+ const fromModel = getValueByPath(fromObject, ['model']);
3828
+ if (fromModel != null) {
3829
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3830
+ }
3831
+ const fromContents = getValueByPath(fromObject, ['contents']);
3832
+ if (fromContents != null) {
3833
+ setValueByPath(toObject, ['requests[]', 'content'], tContentsForEmbed(apiClient, fromContents));
3834
+ }
3835
+ const fromConfig = getValueByPath(fromObject, ['config']);
3836
+ if (fromConfig != null) {
3837
+ setValueByPath(toObject, ['config'], embedContentConfigToMldev(apiClient, fromConfig, toObject));
3838
+ }
3839
+ const fromModelForEmbedContent = getValueByPath(fromObject, ['model']);
3840
+ if (fromModelForEmbedContent !== undefined) {
3841
+ setValueByPath(toObject, ['requests[]', 'model'], tModel(apiClient, fromModelForEmbedContent));
3842
+ }
3843
+ return toObject;
3844
+ }
3845
+ function generateImagesConfigToMldev(apiClient, fromObject, parentObject) {
3846
+ const toObject = {};
3847
+ if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
3848
+ throw new Error('outputGcsUri parameter is not supported in Gemini API.');
3849
+ }
3850
+ if (getValueByPath(fromObject, ['negativePrompt']) !== undefined) {
3851
+ throw new Error('negativePrompt parameter is not supported in Gemini API.');
3852
+ }
3853
+ const fromNumberOfImages = getValueByPath(fromObject, [
3854
+ 'numberOfImages',
3855
+ ]);
3856
+ if (parentObject !== undefined && fromNumberOfImages != null) {
3857
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
3858
+ }
3859
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
3860
+ if (parentObject !== undefined && fromAspectRatio != null) {
3861
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
3862
+ }
3863
+ const fromGuidanceScale = getValueByPath(fromObject, [
3864
+ 'guidanceScale',
3865
+ ]);
3866
+ if (parentObject !== undefined && fromGuidanceScale != null) {
3867
+ setValueByPath(parentObject, ['parameters', 'guidanceScale'], fromGuidanceScale);
3868
+ }
3869
+ if (getValueByPath(fromObject, ['seed']) !== undefined) {
3870
+ throw new Error('seed parameter is not supported in Gemini API.');
3871
+ }
3872
+ const fromSafetyFilterLevel = getValueByPath(fromObject, [
3873
+ 'safetyFilterLevel',
3874
+ ]);
3875
+ if (parentObject !== undefined && fromSafetyFilterLevel != null) {
3876
+ setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
3877
+ }
3878
+ const fromPersonGeneration = getValueByPath(fromObject, [
3879
+ 'personGeneration',
3880
+ ]);
3881
+ if (parentObject !== undefined && fromPersonGeneration != null) {
3882
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
3883
+ }
3884
+ const fromIncludeSafetyAttributes = getValueByPath(fromObject, [
3885
+ 'includeSafetyAttributes',
3886
+ ]);
3887
+ if (parentObject !== undefined && fromIncludeSafetyAttributes != null) {
3888
+ setValueByPath(parentObject, ['parameters', 'includeSafetyAttributes'], fromIncludeSafetyAttributes);
3889
+ }
3890
+ const fromIncludeRaiReason = getValueByPath(fromObject, [
3891
+ 'includeRaiReason',
3892
+ ]);
3893
+ if (parentObject !== undefined && fromIncludeRaiReason != null) {
3894
+ setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
3895
+ }
3896
+ const fromLanguage = getValueByPath(fromObject, ['language']);
3897
+ if (parentObject !== undefined && fromLanguage != null) {
3898
+ setValueByPath(parentObject, ['parameters', 'language'], fromLanguage);
3899
+ }
3900
+ const fromOutputMimeType = getValueByPath(fromObject, [
3901
+ 'outputMimeType',
3902
+ ]);
3903
+ if (parentObject !== undefined && fromOutputMimeType != null) {
3904
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
3905
+ }
3906
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
3907
+ 'outputCompressionQuality',
3908
+ ]);
3909
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
3910
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
3911
+ }
3912
+ if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
3913
+ throw new Error('addWatermark parameter is not supported in Gemini API.');
3914
+ }
3915
+ if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
3916
+ throw new Error('enhancePrompt parameter is not supported in Gemini API.');
3917
+ }
3918
+ return toObject;
3919
+ }
3920
+ function generateImagesParametersToMldev(apiClient, fromObject) {
3921
+ const toObject = {};
3922
+ const fromModel = getValueByPath(fromObject, ['model']);
3923
+ if (fromModel != null) {
3924
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3925
+ }
3926
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
3927
+ if (fromPrompt != null) {
3928
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
3929
+ }
3930
+ const fromConfig = getValueByPath(fromObject, ['config']);
3931
+ if (fromConfig != null) {
3932
+ setValueByPath(toObject, ['config'], generateImagesConfigToMldev(apiClient, fromConfig, toObject));
3933
+ }
3934
+ return toObject;
3935
+ }
3936
+ function countTokensConfigToMldev(apiClient, fromObject) {
3937
+ const toObject = {};
3938
+ if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
3939
+ throw new Error('systemInstruction parameter is not supported in Gemini API.');
3940
+ }
3941
+ if (getValueByPath(fromObject, ['tools']) !== undefined) {
3942
+ throw new Error('tools parameter is not supported in Gemini API.');
3943
+ }
3944
+ if (getValueByPath(fromObject, ['generationConfig']) !== undefined) {
3945
+ throw new Error('generationConfig parameter is not supported in Gemini API.');
3946
+ }
3947
+ return toObject;
3948
+ }
3949
+ function countTokensParametersToMldev(apiClient, fromObject) {
3950
+ const toObject = {};
3951
+ const fromModel = getValueByPath(fromObject, ['model']);
3952
+ if (fromModel != null) {
3953
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
3954
+ }
3955
+ const fromContents = getValueByPath(fromObject, ['contents']);
3956
+ if (fromContents != null) {
3957
+ if (Array.isArray(fromContents)) {
3958
+ setValueByPath(toObject, ['contents'], tContents(apiClient, tContents(apiClient, fromContents).map((item) => {
3959
+ return contentToMldev(apiClient, item);
3960
+ })));
3961
+ }
3962
+ else {
3963
+ setValueByPath(toObject, ['contents'], tContents(apiClient, fromContents));
3964
+ }
3965
+ }
3966
+ const fromConfig = getValueByPath(fromObject, ['config']);
3967
+ if (fromConfig != null) {
3968
+ setValueByPath(toObject, ['config'], countTokensConfigToMldev(apiClient, fromConfig));
3969
+ }
3970
+ return toObject;
3971
+ }
3972
+ function imageToMldev(apiClient, fromObject) {
3973
+ const toObject = {};
3974
+ if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
3975
+ throw new Error('gcsUri parameter is not supported in Gemini API.');
3976
+ }
3977
+ const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
3978
+ if (fromImageBytes != null) {
3979
+ setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
3980
+ }
3981
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3982
+ if (fromMimeType != null) {
3983
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3984
+ }
3985
+ return toObject;
3986
+ }
3987
+ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
3988
+ const toObject = {};
3989
+ const fromNumberOfVideos = getValueByPath(fromObject, [
3990
+ 'numberOfVideos',
3991
+ ]);
3992
+ if (parentObject !== undefined && fromNumberOfVideos != null) {
3993
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
3994
+ }
3995
+ if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
3996
+ throw new Error('outputGcsUri parameter is not supported in Gemini API.');
3997
+ }
3998
+ if (getValueByPath(fromObject, ['fps']) !== undefined) {
3999
+ throw new Error('fps parameter is not supported in Gemini API.');
4000
+ }
4001
+ const fromDurationSeconds = getValueByPath(fromObject, [
4002
+ 'durationSeconds',
4003
+ ]);
4004
+ if (parentObject !== undefined && fromDurationSeconds != null) {
4005
+ setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
4006
+ }
4007
+ if (getValueByPath(fromObject, ['seed']) !== undefined) {
4008
+ throw new Error('seed parameter is not supported in Gemini API.');
4009
+ }
4010
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
4011
+ if (parentObject !== undefined && fromAspectRatio != null) {
4012
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
4013
+ }
4014
+ if (getValueByPath(fromObject, ['resolution']) !== undefined) {
4015
+ throw new Error('resolution parameter is not supported in Gemini API.');
4016
+ }
4017
+ const fromPersonGeneration = getValueByPath(fromObject, [
4018
+ 'personGeneration',
4019
+ ]);
4020
+ if (parentObject !== undefined && fromPersonGeneration != null) {
4021
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
4022
+ }
4023
+ if (getValueByPath(fromObject, ['pubsubTopic']) !== undefined) {
4024
+ throw new Error('pubsubTopic parameter is not supported in Gemini API.');
4025
+ }
4026
+ const fromNegativePrompt = getValueByPath(fromObject, [
4027
+ 'negativePrompt',
4028
+ ]);
4029
+ if (parentObject !== undefined && fromNegativePrompt != null) {
4030
+ setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
4031
+ }
4032
+ if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
4033
+ throw new Error('enhancePrompt parameter is not supported in Gemini API.');
4034
+ }
4035
+ return toObject;
4036
+ }
4037
+ function generateVideosParametersToMldev(apiClient, fromObject) {
4038
+ const toObject = {};
4039
+ const fromModel = getValueByPath(fromObject, ['model']);
4040
+ if (fromModel != null) {
4041
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
4042
+ }
4043
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
4044
+ if (fromPrompt != null) {
4045
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
4046
+ }
4047
+ const fromImage = getValueByPath(fromObject, ['image']);
4048
+ if (fromImage != null) {
4049
+ setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
4050
+ }
4051
+ const fromConfig = getValueByPath(fromObject, ['config']);
4052
+ if (fromConfig != null) {
4053
+ setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
4054
+ }
4055
+ return toObject;
4056
+ }
4057
+ function partToVertex(apiClient, fromObject) {
4058
+ const toObject = {};
4059
+ const fromVideoMetadata = getValueByPath(fromObject, [
4060
+ 'videoMetadata',
4061
+ ]);
4062
+ if (fromVideoMetadata != null) {
4063
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
4064
+ }
4065
+ const fromThought = getValueByPath(fromObject, ['thought']);
4066
+ if (fromThought != null) {
4067
+ setValueByPath(toObject, ['thought'], fromThought);
3464
4068
  }
3465
4069
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3466
4070
  'codeExecutionResult',
@@ -4164,25 +4768,119 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
4164
4768
  }
4165
4769
  return toObject;
4166
4770
  }
4167
- function partFromMldev(apiClient, fromObject) {
4771
+ function imageToVertex(apiClient, fromObject) {
4168
4772
  const toObject = {};
4169
- const fromThought = getValueByPath(fromObject, ['thought']);
4170
- if (fromThought != null) {
4171
- setValueByPath(toObject, ['thought'], fromThought);
4773
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
4774
+ if (fromGcsUri != null) {
4775
+ setValueByPath(toObject, ['gcsUri'], fromGcsUri);
4172
4776
  }
4173
- const fromCodeExecutionResult = getValueByPath(fromObject, [
4174
- 'codeExecutionResult',
4175
- ]);
4176
- if (fromCodeExecutionResult != null) {
4177
- setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
4777
+ const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
4778
+ if (fromImageBytes != null) {
4779
+ setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
4178
4780
  }
4179
- const fromExecutableCode = getValueByPath(fromObject, [
4180
- 'executableCode',
4181
- ]);
4182
- if (fromExecutableCode != null) {
4183
- setValueByPath(toObject, ['executableCode'], fromExecutableCode);
4781
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
4782
+ if (fromMimeType != null) {
4783
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
4184
4784
  }
4185
- const fromFileData = getValueByPath(fromObject, ['fileData']);
4785
+ return toObject;
4786
+ }
4787
+ function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
4788
+ const toObject = {};
4789
+ const fromNumberOfVideos = getValueByPath(fromObject, [
4790
+ 'numberOfVideos',
4791
+ ]);
4792
+ if (parentObject !== undefined && fromNumberOfVideos != null) {
4793
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
4794
+ }
4795
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
4796
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
4797
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
4798
+ }
4799
+ const fromFps = getValueByPath(fromObject, ['fps']);
4800
+ if (parentObject !== undefined && fromFps != null) {
4801
+ setValueByPath(parentObject, ['parameters', 'fps'], fromFps);
4802
+ }
4803
+ const fromDurationSeconds = getValueByPath(fromObject, [
4804
+ 'durationSeconds',
4805
+ ]);
4806
+ if (parentObject !== undefined && fromDurationSeconds != null) {
4807
+ setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
4808
+ }
4809
+ const fromSeed = getValueByPath(fromObject, ['seed']);
4810
+ if (parentObject !== undefined && fromSeed != null) {
4811
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
4812
+ }
4813
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
4814
+ if (parentObject !== undefined && fromAspectRatio != null) {
4815
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
4816
+ }
4817
+ const fromResolution = getValueByPath(fromObject, ['resolution']);
4818
+ if (parentObject !== undefined && fromResolution != null) {
4819
+ setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
4820
+ }
4821
+ const fromPersonGeneration = getValueByPath(fromObject, [
4822
+ 'personGeneration',
4823
+ ]);
4824
+ if (parentObject !== undefined && fromPersonGeneration != null) {
4825
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
4826
+ }
4827
+ const fromPubsubTopic = getValueByPath(fromObject, ['pubsubTopic']);
4828
+ if (parentObject !== undefined && fromPubsubTopic != null) {
4829
+ setValueByPath(parentObject, ['parameters', 'pubsubTopic'], fromPubsubTopic);
4830
+ }
4831
+ const fromNegativePrompt = getValueByPath(fromObject, [
4832
+ 'negativePrompt',
4833
+ ]);
4834
+ if (parentObject !== undefined && fromNegativePrompt != null) {
4835
+ setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
4836
+ }
4837
+ const fromEnhancePrompt = getValueByPath(fromObject, [
4838
+ 'enhancePrompt',
4839
+ ]);
4840
+ if (parentObject !== undefined && fromEnhancePrompt != null) {
4841
+ setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
4842
+ }
4843
+ return toObject;
4844
+ }
4845
+ function generateVideosParametersToVertex(apiClient, fromObject) {
4846
+ const toObject = {};
4847
+ const fromModel = getValueByPath(fromObject, ['model']);
4848
+ if (fromModel != null) {
4849
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
4850
+ }
4851
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
4852
+ if (fromPrompt != null) {
4853
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
4854
+ }
4855
+ const fromImage = getValueByPath(fromObject, ['image']);
4856
+ if (fromImage != null) {
4857
+ setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
4858
+ }
4859
+ const fromConfig = getValueByPath(fromObject, ['config']);
4860
+ if (fromConfig != null) {
4861
+ setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
4862
+ }
4863
+ return toObject;
4864
+ }
4865
+ function partFromMldev(apiClient, fromObject) {
4866
+ const toObject = {};
4867
+ const fromThought = getValueByPath(fromObject, ['thought']);
4868
+ if (fromThought != null) {
4869
+ setValueByPath(toObject, ['thought'], fromThought);
4870
+ }
4871
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
4872
+ 'codeExecutionResult',
4873
+ ]);
4874
+ if (fromCodeExecutionResult != null) {
4875
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
4876
+ }
4877
+ const fromExecutableCode = getValueByPath(fromObject, [
4878
+ 'executableCode',
4879
+ ]);
4880
+ if (fromExecutableCode != null) {
4881
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
4882
+ }
4883
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
4186
4884
  if (fromFileData != null) {
4187
4885
  setValueByPath(toObject, ['fileData'], fromFileData);
4188
4886
  }
@@ -4434,6 +5132,93 @@ function countTokensResponseFromMldev(apiClient, fromObject) {
4434
5132
  }
4435
5133
  return toObject;
4436
5134
  }
5135
+ function videoFromMldev$1(apiClient, fromObject) {
5136
+ const toObject = {};
5137
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
5138
+ if (fromUri != null) {
5139
+ setValueByPath(toObject, ['uri'], fromUri);
5140
+ }
5141
+ const fromVideoBytes = getValueByPath(fromObject, [
5142
+ 'video',
5143
+ 'encodedVideo',
5144
+ ]);
5145
+ if (fromVideoBytes != null) {
5146
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
5147
+ }
5148
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
5149
+ if (fromMimeType != null) {
5150
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
5151
+ }
5152
+ return toObject;
5153
+ }
5154
+ function generatedVideoFromMldev$1(apiClient, fromObject) {
5155
+ const toObject = {};
5156
+ const fromVideo = getValueByPath(fromObject, ['_self']);
5157
+ if (fromVideo != null) {
5158
+ setValueByPath(toObject, ['video'], videoFromMldev$1(apiClient, fromVideo));
5159
+ }
5160
+ return toObject;
5161
+ }
5162
+ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
5163
+ const toObject = {};
5164
+ const fromGeneratedVideos = getValueByPath(fromObject, [
5165
+ 'generatedSamples',
5166
+ ]);
5167
+ if (fromGeneratedVideos != null) {
5168
+ if (Array.isArray(fromGeneratedVideos)) {
5169
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
5170
+ return generatedVideoFromMldev$1(apiClient, item);
5171
+ }));
5172
+ }
5173
+ else {
5174
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
5175
+ }
5176
+ }
5177
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
5178
+ 'raiMediaFilteredCount',
5179
+ ]);
5180
+ if (fromRaiMediaFilteredCount != null) {
5181
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
5182
+ }
5183
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
5184
+ 'raiMediaFilteredReasons',
5185
+ ]);
5186
+ if (fromRaiMediaFilteredReasons != null) {
5187
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
5188
+ }
5189
+ return toObject;
5190
+ }
5191
+ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
5192
+ const toObject = {};
5193
+ const fromName = getValueByPath(fromObject, ['name']);
5194
+ if (fromName != null) {
5195
+ setValueByPath(toObject, ['name'], fromName);
5196
+ }
5197
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
5198
+ if (fromMetadata != null) {
5199
+ setValueByPath(toObject, ['metadata'], fromMetadata);
5200
+ }
5201
+ const fromDone = getValueByPath(fromObject, ['done']);
5202
+ if (fromDone != null) {
5203
+ setValueByPath(toObject, ['done'], fromDone);
5204
+ }
5205
+ const fromError = getValueByPath(fromObject, ['error']);
5206
+ if (fromError != null) {
5207
+ setValueByPath(toObject, ['error'], fromError);
5208
+ }
5209
+ const fromResponse = getValueByPath(fromObject, ['response']);
5210
+ if (fromResponse != null) {
5211
+ setValueByPath(toObject, ['response'], fromResponse);
5212
+ }
5213
+ const fromResult = getValueByPath(fromObject, [
5214
+ 'response',
5215
+ 'generateVideoResponse',
5216
+ ]);
5217
+ if (fromResult != null) {
5218
+ setValueByPath(toObject, ['result'], generateVideosResponseFromMldev$1(apiClient, fromResult));
5219
+ }
5220
+ return toObject;
5221
+ }
4437
5222
  function partFromVertex(apiClient, fromObject) {
4438
5223
  const toObject = {};
4439
5224
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -4755,6 +5540,87 @@ function computeTokensResponseFromVertex(apiClient, fromObject) {
4755
5540
  }
4756
5541
  return toObject;
4757
5542
  }
5543
+ function videoFromVertex$1(apiClient, fromObject) {
5544
+ const toObject = {};
5545
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
5546
+ if (fromUri != null) {
5547
+ setValueByPath(toObject, ['uri'], fromUri);
5548
+ }
5549
+ const fromVideoBytes = getValueByPath(fromObject, [
5550
+ 'bytesBase64Encoded',
5551
+ ]);
5552
+ if (fromVideoBytes != null) {
5553
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
5554
+ }
5555
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
5556
+ if (fromMimeType != null) {
5557
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
5558
+ }
5559
+ return toObject;
5560
+ }
5561
+ function generatedVideoFromVertex$1(apiClient, fromObject) {
5562
+ const toObject = {};
5563
+ const fromVideo = getValueByPath(fromObject, ['_self']);
5564
+ if (fromVideo != null) {
5565
+ setValueByPath(toObject, ['video'], videoFromVertex$1(apiClient, fromVideo));
5566
+ }
5567
+ return toObject;
5568
+ }
5569
+ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
5570
+ const toObject = {};
5571
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
5572
+ if (fromGeneratedVideos != null) {
5573
+ if (Array.isArray(fromGeneratedVideos)) {
5574
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
5575
+ return generatedVideoFromVertex$1(apiClient, item);
5576
+ }));
5577
+ }
5578
+ else {
5579
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
5580
+ }
5581
+ }
5582
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
5583
+ 'raiMediaFilteredCount',
5584
+ ]);
5585
+ if (fromRaiMediaFilteredCount != null) {
5586
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
5587
+ }
5588
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
5589
+ 'raiMediaFilteredReasons',
5590
+ ]);
5591
+ if (fromRaiMediaFilteredReasons != null) {
5592
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
5593
+ }
5594
+ return toObject;
5595
+ }
5596
+ function generateVideosOperationFromVertex$1(apiClient, fromObject) {
5597
+ const toObject = {};
5598
+ const fromName = getValueByPath(fromObject, ['name']);
5599
+ if (fromName != null) {
5600
+ setValueByPath(toObject, ['name'], fromName);
5601
+ }
5602
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
5603
+ if (fromMetadata != null) {
5604
+ setValueByPath(toObject, ['metadata'], fromMetadata);
5605
+ }
5606
+ const fromDone = getValueByPath(fromObject, ['done']);
5607
+ if (fromDone != null) {
5608
+ setValueByPath(toObject, ['done'], fromDone);
5609
+ }
5610
+ const fromError = getValueByPath(fromObject, ['error']);
5611
+ if (fromError != null) {
5612
+ setValueByPath(toObject, ['error'], fromError);
5613
+ }
5614
+ const fromResponse = getValueByPath(fromObject, ['response']);
5615
+ if (fromResponse != null) {
5616
+ setValueByPath(toObject, ['response'], fromResponse);
5617
+ }
5618
+ const fromResult = getValueByPath(fromObject, ['response']);
5619
+ if (fromResult != null) {
5620
+ setValueByPath(toObject, ['result'], generateVideosResponseFromVertex$1(apiClient, fromResult));
5621
+ }
5622
+ return toObject;
5623
+ }
4758
5624
 
4759
5625
  /**
4760
5626
  * @license
@@ -5221,6 +6087,9 @@ class Session {
5221
6087
  if (!Array.isArray(params.functionResponses)) {
5222
6088
  functionResponses = [params.functionResponses];
5223
6089
  }
6090
+ else {
6091
+ functionResponses = params.functionResponses;
6092
+ }
5224
6093
  if (functionResponses.length === 0) {
5225
6094
  throw new Error('functionResponses is required.');
5226
6095
  }
@@ -5950,6 +6819,81 @@ class Models extends BaseModule {
5950
6819
  throw new Error('This method is only supported by the Vertex AI.');
5951
6820
  }
5952
6821
  }
6822
+ /**
6823
+ * Generates videos based on a text description and configuration.
6824
+ *
6825
+ * @param params - The parameters for generating videos.
6826
+ * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
6827
+ *
6828
+ * @example
6829
+ * ```ts
6830
+ * const operation = await ai.models.generateVideos({
6831
+ * model: 'veo-2.0-generate-001',
6832
+ * prompt: 'A neon hologram of a cat driving at top speed',
6833
+ * config: {
6834
+ * numberOfVideos: 1
6835
+ * });
6836
+ *
6837
+ * while (!operation.done) {
6838
+ * await new Promise(resolve => setTimeout(resolve, 10000));
6839
+ * operation = await ai.operations.get({operation: operation});
6840
+ * }
6841
+ *
6842
+ * console.log(operation.result?.generatedVideos?.[0]?.video?.uri);
6843
+ * ```
6844
+ */
6845
+ async generateVideos(params) {
6846
+ var _a, _b;
6847
+ let response;
6848
+ let path = '';
6849
+ let queryParams = {};
6850
+ if (this.apiClient.isVertexAI()) {
6851
+ const body = generateVideosParametersToVertex(this.apiClient, params);
6852
+ path = formatMap('{model}:predictLongRunning', body['_url']);
6853
+ queryParams = body['_query'];
6854
+ delete body['config'];
6855
+ delete body['_url'];
6856
+ delete body['_query'];
6857
+ response = this.apiClient
6858
+ .request({
6859
+ path: path,
6860
+ queryParams: queryParams,
6861
+ body: JSON.stringify(body),
6862
+ httpMethod: 'POST',
6863
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6864
+ })
6865
+ .then((httpResponse) => {
6866
+ return httpResponse.json();
6867
+ });
6868
+ return response.then((apiResponse) => {
6869
+ const resp = generateVideosOperationFromVertex$1(this.apiClient, apiResponse);
6870
+ return resp;
6871
+ });
6872
+ }
6873
+ else {
6874
+ const body = generateVideosParametersToMldev(this.apiClient, params);
6875
+ path = formatMap('{model}:predictLongRunning', body['_url']);
6876
+ queryParams = body['_query'];
6877
+ delete body['config'];
6878
+ delete body['_url'];
6879
+ delete body['_query'];
6880
+ response = this.apiClient
6881
+ .request({
6882
+ path: path,
6883
+ queryParams: queryParams,
6884
+ body: JSON.stringify(body),
6885
+ httpMethod: 'POST',
6886
+ httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
6887
+ })
6888
+ .then((httpResponse) => {
6889
+ return httpResponse.json();
6890
+ });
6891
+ return response.then((apiResponse) => {
6892
+ const resp = generateVideosOperationFromMldev$1(this.apiClient, apiResponse);
6893
+ return resp;
6894
+ });
6895
+ }
6896
+ }
5953
6897
  }
5954
6898
 
5955
6899
  /**
@@ -5957,32 +6901,379 @@ class Models extends BaseModule {
5957
6901
  * Copyright 2025 Google LLC
5958
6902
  * SPDX-License-Identifier: Apache-2.0
5959
6903
  */
5960
- const CONTENT_TYPE_HEADER = 'Content-Type';
5961
- const USER_AGENT_HEADER = 'User-Agent';
5962
- const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
5963
- const SDK_VERSION = '0.6.1'; // x-release-please-version
5964
- const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
5965
- const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
5966
- const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
5967
- const responseLineRE = /^data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;
5968
- /**
5969
- * Client errors raised by the GenAI API.
5970
- */
5971
- class ClientError extends Error {
5972
- constructor(message, stackTrace) {
5973
- if (stackTrace) {
5974
- super(message, { cause: stackTrace });
5975
- }
5976
- else {
5977
- super(message, { cause: new Error().stack });
5978
- }
5979
- this.message = message;
5980
- this.name = 'ClientError';
6904
+ function getOperationParametersToMldev(apiClient, fromObject) {
6905
+ const toObject = {};
6906
+ const fromOperationName = getValueByPath(fromObject, [
6907
+ 'operationName',
6908
+ ]);
6909
+ if (fromOperationName != null) {
6910
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
5981
6911
  }
5982
- }
5983
- /**
5984
- * Server errors raised by the GenAI API.
5985
- */
6912
+ const fromConfig = getValueByPath(fromObject, ['config']);
6913
+ if (fromConfig != null) {
6914
+ setValueByPath(toObject, ['config'], fromConfig);
6915
+ }
6916
+ return toObject;
6917
+ }
6918
+ function getOperationParametersToVertex(apiClient, fromObject) {
6919
+ const toObject = {};
6920
+ const fromOperationName = getValueByPath(fromObject, [
6921
+ 'operationName',
6922
+ ]);
6923
+ if (fromOperationName != null) {
6924
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
6925
+ }
6926
+ const fromConfig = getValueByPath(fromObject, ['config']);
6927
+ if (fromConfig != null) {
6928
+ setValueByPath(toObject, ['config'], fromConfig);
6929
+ }
6930
+ return toObject;
6931
+ }
6932
+ function fetchPredictOperationParametersToVertex(apiClient, fromObject) {
6933
+ const toObject = {};
6934
+ const fromOperationName = getValueByPath(fromObject, [
6935
+ 'operationName',
6936
+ ]);
6937
+ if (fromOperationName != null) {
6938
+ setValueByPath(toObject, ['operationName'], fromOperationName);
6939
+ }
6940
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
6941
+ if (fromResourceName != null) {
6942
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
6943
+ }
6944
+ const fromConfig = getValueByPath(fromObject, ['config']);
6945
+ if (fromConfig != null) {
6946
+ setValueByPath(toObject, ['config'], fromConfig);
6947
+ }
6948
+ return toObject;
6949
+ }
6950
+ function videoFromMldev(apiClient, fromObject) {
6951
+ const toObject = {};
6952
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
6953
+ if (fromUri != null) {
6954
+ setValueByPath(toObject, ['uri'], fromUri);
6955
+ }
6956
+ const fromVideoBytes = getValueByPath(fromObject, [
6957
+ 'video',
6958
+ 'encodedVideo',
6959
+ ]);
6960
+ if (fromVideoBytes != null) {
6961
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
6962
+ }
6963
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
6964
+ if (fromMimeType != null) {
6965
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
6966
+ }
6967
+ return toObject;
6968
+ }
6969
+ function generatedVideoFromMldev(apiClient, fromObject) {
6970
+ const toObject = {};
6971
+ const fromVideo = getValueByPath(fromObject, ['_self']);
6972
+ if (fromVideo != null) {
6973
+ setValueByPath(toObject, ['video'], videoFromMldev(apiClient, fromVideo));
6974
+ }
6975
+ return toObject;
6976
+ }
6977
+ function generateVideosResponseFromMldev(apiClient, fromObject) {
6978
+ const toObject = {};
6979
+ const fromGeneratedVideos = getValueByPath(fromObject, [
6980
+ 'generatedSamples',
6981
+ ]);
6982
+ if (fromGeneratedVideos != null) {
6983
+ if (Array.isArray(fromGeneratedVideos)) {
6984
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
6985
+ return generatedVideoFromMldev(apiClient, item);
6986
+ }));
6987
+ }
6988
+ else {
6989
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
6990
+ }
6991
+ }
6992
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
6993
+ 'raiMediaFilteredCount',
6994
+ ]);
6995
+ if (fromRaiMediaFilteredCount != null) {
6996
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
6997
+ }
6998
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
6999
+ 'raiMediaFilteredReasons',
7000
+ ]);
7001
+ if (fromRaiMediaFilteredReasons != null) {
7002
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
7003
+ }
7004
+ return toObject;
7005
+ }
7006
+ function generateVideosOperationFromMldev(apiClient, fromObject) {
7007
+ const toObject = {};
7008
+ const fromName = getValueByPath(fromObject, ['name']);
7009
+ if (fromName != null) {
7010
+ setValueByPath(toObject, ['name'], fromName);
7011
+ }
7012
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
7013
+ if (fromMetadata != null) {
7014
+ setValueByPath(toObject, ['metadata'], fromMetadata);
7015
+ }
7016
+ const fromDone = getValueByPath(fromObject, ['done']);
7017
+ if (fromDone != null) {
7018
+ setValueByPath(toObject, ['done'], fromDone);
7019
+ }
7020
+ const fromError = getValueByPath(fromObject, ['error']);
7021
+ if (fromError != null) {
7022
+ setValueByPath(toObject, ['error'], fromError);
7023
+ }
7024
+ const fromResponse = getValueByPath(fromObject, ['response']);
7025
+ if (fromResponse != null) {
7026
+ setValueByPath(toObject, ['response'], fromResponse);
7027
+ }
7028
+ const fromResult = getValueByPath(fromObject, [
7029
+ 'response',
7030
+ 'generateVideoResponse',
7031
+ ]);
7032
+ if (fromResult != null) {
7033
+ setValueByPath(toObject, ['result'], generateVideosResponseFromMldev(apiClient, fromResult));
7034
+ }
7035
+ return toObject;
7036
+ }
7037
+ function videoFromVertex(apiClient, fromObject) {
7038
+ const toObject = {};
7039
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
7040
+ if (fromUri != null) {
7041
+ setValueByPath(toObject, ['uri'], fromUri);
7042
+ }
7043
+ const fromVideoBytes = getValueByPath(fromObject, [
7044
+ 'bytesBase64Encoded',
7045
+ ]);
7046
+ if (fromVideoBytes != null) {
7047
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
7048
+ }
7049
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
7050
+ if (fromMimeType != null) {
7051
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
7052
+ }
7053
+ return toObject;
7054
+ }
7055
+ function generatedVideoFromVertex(apiClient, fromObject) {
7056
+ const toObject = {};
7057
+ const fromVideo = getValueByPath(fromObject, ['_self']);
7058
+ if (fromVideo != null) {
7059
+ setValueByPath(toObject, ['video'], videoFromVertex(apiClient, fromVideo));
7060
+ }
7061
+ return toObject;
7062
+ }
7063
+ function generateVideosResponseFromVertex(apiClient, fromObject) {
7064
+ const toObject = {};
7065
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
7066
+ if (fromGeneratedVideos != null) {
7067
+ if (Array.isArray(fromGeneratedVideos)) {
7068
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
7069
+ return generatedVideoFromVertex(apiClient, item);
7070
+ }));
7071
+ }
7072
+ else {
7073
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
7074
+ }
7075
+ }
7076
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
7077
+ 'raiMediaFilteredCount',
7078
+ ]);
7079
+ if (fromRaiMediaFilteredCount != null) {
7080
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
7081
+ }
7082
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
7083
+ 'raiMediaFilteredReasons',
7084
+ ]);
7085
+ if (fromRaiMediaFilteredReasons != null) {
7086
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
7087
+ }
7088
+ return toObject;
7089
+ }
7090
+ function generateVideosOperationFromVertex(apiClient, fromObject) {
7091
+ const toObject = {};
7092
+ const fromName = getValueByPath(fromObject, ['name']);
7093
+ if (fromName != null) {
7094
+ setValueByPath(toObject, ['name'], fromName);
7095
+ }
7096
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
7097
+ if (fromMetadata != null) {
7098
+ setValueByPath(toObject, ['metadata'], fromMetadata);
7099
+ }
7100
+ const fromDone = getValueByPath(fromObject, ['done']);
7101
+ if (fromDone != null) {
7102
+ setValueByPath(toObject, ['done'], fromDone);
7103
+ }
7104
+ const fromError = getValueByPath(fromObject, ['error']);
7105
+ if (fromError != null) {
7106
+ setValueByPath(toObject, ['error'], fromError);
7107
+ }
7108
+ const fromResponse = getValueByPath(fromObject, ['response']);
7109
+ if (fromResponse != null) {
7110
+ setValueByPath(toObject, ['response'], fromResponse);
7111
+ }
7112
+ const fromResult = getValueByPath(fromObject, ['response']);
7113
+ if (fromResult != null) {
7114
+ setValueByPath(toObject, ['result'], generateVideosResponseFromVertex(apiClient, fromResult));
7115
+ }
7116
+ return toObject;
7117
+ }
7118
+
7119
+ /**
7120
+ * @license
7121
+ * Copyright 2025 Google LLC
7122
+ * SPDX-License-Identifier: Apache-2.0
7123
+ */
7124
+ class Operations extends BaseModule {
7125
+ constructor(apiClient) {
7126
+ super();
7127
+ this.apiClient = apiClient;
7128
+ }
7129
+ /**
7130
+ * Gets the status of a long-running operation.
7131
+ *
7132
+ * @param operation The Operation object returned by a previous API call.
7133
+ * @return The updated Operation object, with the latest status or result.
7134
+ */
7135
+ async get(parameters) {
7136
+ const operation = parameters.operation;
7137
+ const config = parameters.config;
7138
+ if (operation.name === undefined || operation.name === '') {
7139
+ throw new Error('Operation name is required.');
7140
+ }
7141
+ if (this.apiClient.isVertexAI()) {
7142
+ const resourceName = operation.name.split('/operations/')[0];
7143
+ var httpOptions = undefined;
7144
+ if (config && 'httpOptions' in config) {
7145
+ httpOptions = config.httpOptions;
7146
+ }
7147
+ return this.fetchPredictVideosOperationInternal({
7148
+ operationName: operation.name,
7149
+ resourceName: resourceName,
7150
+ config: { httpOptions: httpOptions },
7151
+ });
7152
+ }
7153
+ else {
7154
+ return this.getVideosOperationInternal({
7155
+ operationName: operation.name,
7156
+ config: config,
7157
+ });
7158
+ }
7159
+ }
7160
+ async getVideosOperationInternal(params) {
7161
+ var _a, _b;
7162
+ let response;
7163
+ let path = '';
7164
+ let queryParams = {};
7165
+ if (this.apiClient.isVertexAI()) {
7166
+ const body = getOperationParametersToVertex(this.apiClient, params);
7167
+ path = formatMap('{operationName}', body['_url']);
7168
+ queryParams = body['_query'];
7169
+ delete body['config'];
7170
+ delete body['_url'];
7171
+ delete body['_query'];
7172
+ response = this.apiClient
7173
+ .request({
7174
+ path: path,
7175
+ queryParams: queryParams,
7176
+ body: JSON.stringify(body),
7177
+ httpMethod: 'GET',
7178
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7179
+ })
7180
+ .then((httpResponse) => {
7181
+ return httpResponse.json();
7182
+ });
7183
+ return response.then((apiResponse) => {
7184
+ const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
7185
+ return resp;
7186
+ });
7187
+ }
7188
+ else {
7189
+ const body = getOperationParametersToMldev(this.apiClient, params);
7190
+ path = formatMap('{operationName}', body['_url']);
7191
+ queryParams = body['_query'];
7192
+ delete body['config'];
7193
+ delete body['_url'];
7194
+ delete body['_query'];
7195
+ response = this.apiClient
7196
+ .request({
7197
+ path: path,
7198
+ queryParams: queryParams,
7199
+ body: JSON.stringify(body),
7200
+ httpMethod: 'GET',
7201
+ httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
7202
+ })
7203
+ .then((httpResponse) => {
7204
+ return httpResponse.json();
7205
+ });
7206
+ return response.then((apiResponse) => {
7207
+ const resp = generateVideosOperationFromMldev(this.apiClient, apiResponse);
7208
+ return resp;
7209
+ });
7210
+ }
7211
+ }
7212
+ async fetchPredictVideosOperationInternal(params) {
7213
+ var _a;
7214
+ let response;
7215
+ let path = '';
7216
+ let queryParams = {};
7217
+ if (this.apiClient.isVertexAI()) {
7218
+ const body = fetchPredictOperationParametersToVertex(this.apiClient, params);
7219
+ path = formatMap('{resourceName}:fetchPredictOperation', body['_url']);
7220
+ queryParams = body['_query'];
7221
+ delete body['config'];
7222
+ delete body['_url'];
7223
+ delete body['_query'];
7224
+ response = this.apiClient
7225
+ .request({
7226
+ path: path,
7227
+ queryParams: queryParams,
7228
+ body: JSON.stringify(body),
7229
+ httpMethod: 'POST',
7230
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7231
+ })
7232
+ .then((httpResponse) => {
7233
+ return httpResponse.json();
7234
+ });
7235
+ return response.then((apiResponse) => {
7236
+ const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
7237
+ return resp;
7238
+ });
7239
+ }
7240
+ else {
7241
+ throw new Error('This method is only supported by the Vertex AI.');
7242
+ }
7243
+ }
7244
+ }
7245
+
7246
+ /**
7247
+ * @license
7248
+ * Copyright 2025 Google LLC
7249
+ * SPDX-License-Identifier: Apache-2.0
7250
+ */
7251
+ const CONTENT_TYPE_HEADER = 'Content-Type';
7252
+ const USER_AGENT_HEADER = 'User-Agent';
7253
+ const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7254
+ const SDK_VERSION = '0.7.0'; // x-release-please-version
7255
+ const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7256
+ const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7257
+ const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
7258
+ const responseLineRE = /^data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;
7259
+ /**
7260
+ * Client errors raised by the GenAI API.
7261
+ */
7262
+ class ClientError extends Error {
7263
+ constructor(message, stackTrace) {
7264
+ if (stackTrace) {
7265
+ super(message, { cause: stackTrace });
7266
+ }
7267
+ else {
7268
+ super(message, { cause: new Error().stack });
7269
+ }
7270
+ this.message = message;
7271
+ this.name = 'ClientError';
7272
+ }
7273
+ }
7274
+ /**
7275
+ * Server errors raised by the GenAI API.
7276
+ */
5986
7277
  class ServerError extends Error {
5987
7278
  constructor(message, stackTrace) {
5988
7279
  if (stackTrace) {
@@ -6296,7 +7587,7 @@ class ApiClient {
6296
7587
  }
6297
7588
  const uploader = this.clientOptions.uploader;
6298
7589
  const fileStat = await uploader.stat(file);
6299
- fileToUpload.sizeBytes = fileStat.size;
7590
+ fileToUpload.sizeBytes = String(fileStat.size);
6300
7591
  const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
6301
7592
  if (mimeType === undefined || mimeType === '') {
6302
7593
  throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
@@ -6376,508 +7667,6 @@ async function throwErrorIfNotOK(response) {
6376
7667
  }
6377
7668
  }
6378
7669
 
6379
- /**
6380
- * @license
6381
- * Copyright 2025 Google LLC
6382
- * SPDX-License-Identifier: Apache-2.0
6383
- */
6384
- function listFilesConfigToMldev(apiClient, fromObject, parentObject) {
6385
- const toObject = {};
6386
- const fromPageSize = getValueByPath(fromObject, ['pageSize']);
6387
- if (parentObject !== undefined && fromPageSize != null) {
6388
- setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
6389
- }
6390
- const fromPageToken = getValueByPath(fromObject, ['pageToken']);
6391
- if (parentObject !== undefined && fromPageToken != null) {
6392
- setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
6393
- }
6394
- return toObject;
6395
- }
6396
- function listFilesParametersToMldev(apiClient, fromObject) {
6397
- const toObject = {};
6398
- const fromConfig = getValueByPath(fromObject, ['config']);
6399
- if (fromConfig != null) {
6400
- setValueByPath(toObject, ['config'], listFilesConfigToMldev(apiClient, fromConfig, toObject));
6401
- }
6402
- return toObject;
6403
- }
6404
- function fileStatusToMldev(apiClient, fromObject) {
6405
- const toObject = {};
6406
- const fromDetails = getValueByPath(fromObject, ['details']);
6407
- if (fromDetails != null) {
6408
- setValueByPath(toObject, ['details'], fromDetails);
6409
- }
6410
- const fromMessage = getValueByPath(fromObject, ['message']);
6411
- if (fromMessage != null) {
6412
- setValueByPath(toObject, ['message'], fromMessage);
6413
- }
6414
- const fromCode = getValueByPath(fromObject, ['code']);
6415
- if (fromCode != null) {
6416
- setValueByPath(toObject, ['code'], fromCode);
6417
- }
6418
- return toObject;
6419
- }
6420
- function fileToMldev(apiClient, fromObject) {
6421
- const toObject = {};
6422
- const fromName = getValueByPath(fromObject, ['name']);
6423
- if (fromName != null) {
6424
- setValueByPath(toObject, ['name'], fromName);
6425
- }
6426
- const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6427
- if (fromDisplayName != null) {
6428
- setValueByPath(toObject, ['displayName'], fromDisplayName);
6429
- }
6430
- const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6431
- if (fromMimeType != null) {
6432
- setValueByPath(toObject, ['mimeType'], fromMimeType);
6433
- }
6434
- const fromSizeBytes = getValueByPath(fromObject, ['sizeBytes']);
6435
- if (fromSizeBytes != null) {
6436
- setValueByPath(toObject, ['sizeBytes'], fromSizeBytes);
6437
- }
6438
- const fromCreateTime = getValueByPath(fromObject, ['createTime']);
6439
- if (fromCreateTime != null) {
6440
- setValueByPath(toObject, ['createTime'], fromCreateTime);
6441
- }
6442
- const fromExpirationTime = getValueByPath(fromObject, [
6443
- 'expirationTime',
6444
- ]);
6445
- if (fromExpirationTime != null) {
6446
- setValueByPath(toObject, ['expirationTime'], fromExpirationTime);
6447
- }
6448
- const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
6449
- if (fromUpdateTime != null) {
6450
- setValueByPath(toObject, ['updateTime'], fromUpdateTime);
6451
- }
6452
- const fromSha256Hash = getValueByPath(fromObject, ['sha256Hash']);
6453
- if (fromSha256Hash != null) {
6454
- setValueByPath(toObject, ['sha256Hash'], fromSha256Hash);
6455
- }
6456
- const fromUri = getValueByPath(fromObject, ['uri']);
6457
- if (fromUri != null) {
6458
- setValueByPath(toObject, ['uri'], fromUri);
6459
- }
6460
- const fromDownloadUri = getValueByPath(fromObject, ['downloadUri']);
6461
- if (fromDownloadUri != null) {
6462
- setValueByPath(toObject, ['downloadUri'], fromDownloadUri);
6463
- }
6464
- const fromState = getValueByPath(fromObject, ['state']);
6465
- if (fromState != null) {
6466
- setValueByPath(toObject, ['state'], fromState);
6467
- }
6468
- const fromSource = getValueByPath(fromObject, ['source']);
6469
- if (fromSource != null) {
6470
- setValueByPath(toObject, ['source'], fromSource);
6471
- }
6472
- const fromVideoMetadata = getValueByPath(fromObject, [
6473
- 'videoMetadata',
6474
- ]);
6475
- if (fromVideoMetadata != null) {
6476
- setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
6477
- }
6478
- const fromError = getValueByPath(fromObject, ['error']);
6479
- if (fromError != null) {
6480
- setValueByPath(toObject, ['error'], fileStatusToMldev(apiClient, fromError));
6481
- }
6482
- return toObject;
6483
- }
6484
- function createFileParametersToMldev(apiClient, fromObject) {
6485
- const toObject = {};
6486
- const fromFile = getValueByPath(fromObject, ['file']);
6487
- if (fromFile != null) {
6488
- setValueByPath(toObject, ['file'], fileToMldev(apiClient, fromFile));
6489
- }
6490
- const fromConfig = getValueByPath(fromObject, ['config']);
6491
- if (fromConfig != null) {
6492
- setValueByPath(toObject, ['config'], fromConfig);
6493
- }
6494
- return toObject;
6495
- }
6496
- function getFileParametersToMldev(apiClient, fromObject) {
6497
- const toObject = {};
6498
- const fromName = getValueByPath(fromObject, ['name']);
6499
- if (fromName != null) {
6500
- setValueByPath(toObject, ['_url', 'file'], tFileName(apiClient, fromName));
6501
- }
6502
- const fromConfig = getValueByPath(fromObject, ['config']);
6503
- if (fromConfig != null) {
6504
- setValueByPath(toObject, ['config'], fromConfig);
6505
- }
6506
- return toObject;
6507
- }
6508
- function deleteFileParametersToMldev(apiClient, fromObject) {
6509
- const toObject = {};
6510
- const fromName = getValueByPath(fromObject, ['name']);
6511
- if (fromName != null) {
6512
- setValueByPath(toObject, ['_url', 'file'], tFileName(apiClient, fromName));
6513
- }
6514
- const fromConfig = getValueByPath(fromObject, ['config']);
6515
- if (fromConfig != null) {
6516
- setValueByPath(toObject, ['config'], fromConfig);
6517
- }
6518
- return toObject;
6519
- }
6520
- function fileStatusFromMldev(apiClient, fromObject) {
6521
- const toObject = {};
6522
- const fromDetails = getValueByPath(fromObject, ['details']);
6523
- if (fromDetails != null) {
6524
- setValueByPath(toObject, ['details'], fromDetails);
6525
- }
6526
- const fromMessage = getValueByPath(fromObject, ['message']);
6527
- if (fromMessage != null) {
6528
- setValueByPath(toObject, ['message'], fromMessage);
6529
- }
6530
- const fromCode = getValueByPath(fromObject, ['code']);
6531
- if (fromCode != null) {
6532
- setValueByPath(toObject, ['code'], fromCode);
6533
- }
6534
- return toObject;
6535
- }
6536
- function fileFromMldev(apiClient, fromObject) {
6537
- const toObject = {};
6538
- const fromName = getValueByPath(fromObject, ['name']);
6539
- if (fromName != null) {
6540
- setValueByPath(toObject, ['name'], fromName);
6541
- }
6542
- const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6543
- if (fromDisplayName != null) {
6544
- setValueByPath(toObject, ['displayName'], fromDisplayName);
6545
- }
6546
- const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6547
- if (fromMimeType != null) {
6548
- setValueByPath(toObject, ['mimeType'], fromMimeType);
6549
- }
6550
- const fromSizeBytes = getValueByPath(fromObject, ['sizeBytes']);
6551
- if (fromSizeBytes != null) {
6552
- setValueByPath(toObject, ['sizeBytes'], fromSizeBytes);
6553
- }
6554
- const fromCreateTime = getValueByPath(fromObject, ['createTime']);
6555
- if (fromCreateTime != null) {
6556
- setValueByPath(toObject, ['createTime'], fromCreateTime);
6557
- }
6558
- const fromExpirationTime = getValueByPath(fromObject, [
6559
- 'expirationTime',
6560
- ]);
6561
- if (fromExpirationTime != null) {
6562
- setValueByPath(toObject, ['expirationTime'], fromExpirationTime);
6563
- }
6564
- const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
6565
- if (fromUpdateTime != null) {
6566
- setValueByPath(toObject, ['updateTime'], fromUpdateTime);
6567
- }
6568
- const fromSha256Hash = getValueByPath(fromObject, ['sha256Hash']);
6569
- if (fromSha256Hash != null) {
6570
- setValueByPath(toObject, ['sha256Hash'], fromSha256Hash);
6571
- }
6572
- const fromUri = getValueByPath(fromObject, ['uri']);
6573
- if (fromUri != null) {
6574
- setValueByPath(toObject, ['uri'], fromUri);
6575
- }
6576
- const fromDownloadUri = getValueByPath(fromObject, ['downloadUri']);
6577
- if (fromDownloadUri != null) {
6578
- setValueByPath(toObject, ['downloadUri'], fromDownloadUri);
6579
- }
6580
- const fromState = getValueByPath(fromObject, ['state']);
6581
- if (fromState != null) {
6582
- setValueByPath(toObject, ['state'], fromState);
6583
- }
6584
- const fromSource = getValueByPath(fromObject, ['source']);
6585
- if (fromSource != null) {
6586
- setValueByPath(toObject, ['source'], fromSource);
6587
- }
6588
- const fromVideoMetadata = getValueByPath(fromObject, [
6589
- 'videoMetadata',
6590
- ]);
6591
- if (fromVideoMetadata != null) {
6592
- setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
6593
- }
6594
- const fromError = getValueByPath(fromObject, ['error']);
6595
- if (fromError != null) {
6596
- setValueByPath(toObject, ['error'], fileStatusFromMldev(apiClient, fromError));
6597
- }
6598
- return toObject;
6599
- }
6600
- function listFilesResponseFromMldev(apiClient, fromObject) {
6601
- const toObject = {};
6602
- const fromNextPageToken = getValueByPath(fromObject, [
6603
- 'nextPageToken',
6604
- ]);
6605
- if (fromNextPageToken != null) {
6606
- setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
6607
- }
6608
- const fromFiles = getValueByPath(fromObject, ['files']);
6609
- if (fromFiles != null) {
6610
- if (Array.isArray(fromFiles)) {
6611
- setValueByPath(toObject, ['files'], fromFiles.map((item) => {
6612
- return fileFromMldev(apiClient, item);
6613
- }));
6614
- }
6615
- else {
6616
- setValueByPath(toObject, ['files'], fromFiles);
6617
- }
6618
- }
6619
- return toObject;
6620
- }
6621
- function createFileResponseFromMldev(apiClient, fromObject) {
6622
- const toObject = {};
6623
- const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
6624
- if (fromHttpHeaders != null) {
6625
- setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
6626
- }
6627
- return toObject;
6628
- }
6629
- function deleteFileResponseFromMldev() {
6630
- const toObject = {};
6631
- return toObject;
6632
- }
6633
-
6634
- /**
6635
- * @license
6636
- * Copyright 2025 Google LLC
6637
- * SPDX-License-Identifier: Apache-2.0
6638
- */
6639
- class Files extends BaseModule {
6640
- constructor(apiClient) {
6641
- super();
6642
- this.apiClient = apiClient;
6643
- /**
6644
- * Lists all current project files from the service.
6645
- *
6646
- * @param params - The parameters for the list request
6647
- * @return The paginated results of the list of files
6648
- *
6649
- * @example
6650
- * The following code prints the names of all files from the service, the
6651
- * size of each page is 10.
6652
- *
6653
- * ```ts
6654
- * const listResponse = await ai.files.list({config: {'pageSize': 10}});
6655
- * for await (const file of listResponse) {
6656
- * console.log(file.name);
6657
- * }
6658
- * ```
6659
- */
6660
- this.list = async (params = {}) => {
6661
- return new Pager(PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
6662
- };
6663
- }
6664
- /**
6665
- * Uploads a file asynchronously to the Gemini API.
6666
- * This method is not available in Vertex AI.
6667
- * Supported upload sources:
6668
- * - Node.js: File path (string) or Blob object.
6669
- * - Browser: Blob object (e.g., File).
6670
- *
6671
- * @remarks
6672
- * The `mimeType` can be specified in the `config` parameter. If omitted:
6673
- * - For file path (string) inputs, the `mimeType` will be inferred from the
6674
- * file extension.
6675
- * - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
6676
- * property.
6677
- * Somex eamples for file extension to mimeType mapping:
6678
- * .txt -> text/plain
6679
- * .json -> application/json
6680
- * .jpg -> image/jpeg
6681
- * .png -> image/png
6682
- * .mp3 -> audio/mpeg
6683
- * .mp4 -> video/mp4
6684
- *
6685
- * This section can contain multiple paragraphs and code examples.
6686
- *
6687
- * @param params - Optional parameters specified in the
6688
- * `common.UploadFileParameters` interface.
6689
- * Optional @see {@link common.UploadFileParameters}
6690
- * @return A promise that resolves to a `types.File` object.
6691
- * @throws An error if called on a Vertex AI client.
6692
- * @throws An error if the `mimeType` is not provided and can not be inferred,
6693
- * the `mimeType` can be provided in the `params.config` parameter.
6694
- * @throws An error occurs if a suitable upload location cannot be established.
6695
- *
6696
- * @example
6697
- * The following code uploads a file to Gemini API.
6698
- *
6699
- * ```ts
6700
- * const file = await ai.files.upload({file: 'file.txt', config: {
6701
- * mimeType: 'text/plain',
6702
- * }});
6703
- * console.log(file.name);
6704
- * ```
6705
- */
6706
- async upload(params) {
6707
- if (this.apiClient.isVertexAI()) {
6708
- throw new Error('Vertex AI does not support uploading files. You can share files through a GCS bucket.');
6709
- }
6710
- return this.apiClient
6711
- .uploadFile(params.file, params.config)
6712
- .then((response) => {
6713
- const file = fileFromMldev(this.apiClient, response);
6714
- return file;
6715
- });
6716
- }
6717
- async listInternal(params) {
6718
- var _a;
6719
- let response;
6720
- let path = '';
6721
- let queryParams = {};
6722
- if (this.apiClient.isVertexAI()) {
6723
- throw new Error('This method is only supported by the Gemini Developer API.');
6724
- }
6725
- else {
6726
- const body = listFilesParametersToMldev(this.apiClient, params);
6727
- path = formatMap('files', body['_url']);
6728
- queryParams = body['_query'];
6729
- delete body['config'];
6730
- delete body['_url'];
6731
- delete body['_query'];
6732
- response = this.apiClient
6733
- .request({
6734
- path: path,
6735
- queryParams: queryParams,
6736
- body: JSON.stringify(body),
6737
- httpMethod: 'GET',
6738
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6739
- })
6740
- .then((httpResponse) => {
6741
- return httpResponse.json();
6742
- });
6743
- return response.then((apiResponse) => {
6744
- const resp = listFilesResponseFromMldev(this.apiClient, apiResponse);
6745
- const typedResp = new ListFilesResponse();
6746
- Object.assign(typedResp, resp);
6747
- return typedResp;
6748
- });
6749
- }
6750
- }
6751
- async createInternal(params) {
6752
- var _a;
6753
- let response;
6754
- let path = '';
6755
- let queryParams = {};
6756
- if (this.apiClient.isVertexAI()) {
6757
- throw new Error('This method is only supported by the Gemini Developer API.');
6758
- }
6759
- else {
6760
- const body = createFileParametersToMldev(this.apiClient, params);
6761
- path = formatMap('upload/v1beta/files', body['_url']);
6762
- queryParams = body['_query'];
6763
- delete body['config'];
6764
- delete body['_url'];
6765
- delete body['_query'];
6766
- response = this.apiClient
6767
- .request({
6768
- path: path,
6769
- queryParams: queryParams,
6770
- body: JSON.stringify(body),
6771
- httpMethod: 'POST',
6772
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6773
- })
6774
- .then((httpResponse) => {
6775
- return httpResponse.json();
6776
- });
6777
- return response.then((apiResponse) => {
6778
- const resp = createFileResponseFromMldev(this.apiClient, apiResponse);
6779
- const typedResp = new CreateFileResponse();
6780
- Object.assign(typedResp, resp);
6781
- return typedResp;
6782
- });
6783
- }
6784
- }
6785
- /**
6786
- * Retrieves the file information from the service.
6787
- *
6788
- * @param params - The parameters for the get request
6789
- * @return The Promise that resolves to the types.File object requested.
6790
- *
6791
- * @example
6792
- * ```ts
6793
- * const config: GetFileParameters = {
6794
- * name: fileName,
6795
- * };
6796
- * file = await ai.files.get(config);
6797
- * console.log(file.name);
6798
- * ```
6799
- */
6800
- async get(params) {
6801
- var _a;
6802
- let response;
6803
- let path = '';
6804
- let queryParams = {};
6805
- if (this.apiClient.isVertexAI()) {
6806
- throw new Error('This method is only supported by the Gemini Developer API.');
6807
- }
6808
- else {
6809
- const body = getFileParametersToMldev(this.apiClient, params);
6810
- path = formatMap('files/{file}', body['_url']);
6811
- queryParams = body['_query'];
6812
- delete body['config'];
6813
- delete body['_url'];
6814
- delete body['_query'];
6815
- response = this.apiClient
6816
- .request({
6817
- path: path,
6818
- queryParams: queryParams,
6819
- body: JSON.stringify(body),
6820
- httpMethod: 'GET',
6821
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6822
- })
6823
- .then((httpResponse) => {
6824
- return httpResponse.json();
6825
- });
6826
- return response.then((apiResponse) => {
6827
- const resp = fileFromMldev(this.apiClient, apiResponse);
6828
- return resp;
6829
- });
6830
- }
6831
- }
6832
- /**
6833
- * Deletes a remotely stored file.
6834
- *
6835
- * @param params - The parameters for the delete request.
6836
- * @return The DeleteFileResponse, the response for the delete method.
6837
- *
6838
- * @example
6839
- * The following code deletes an example file named "files/mehozpxf877d".
6840
- *
6841
- * ```ts
6842
- * await ai.files.delete({name: file.name});
6843
- * ```
6844
- */
6845
- async delete(params) {
6846
- var _a;
6847
- let response;
6848
- let path = '';
6849
- let queryParams = {};
6850
- if (this.apiClient.isVertexAI()) {
6851
- throw new Error('This method is only supported by the Gemini Developer API.');
6852
- }
6853
- else {
6854
- const body = deleteFileParametersToMldev(this.apiClient, params);
6855
- path = formatMap('files/{file}', body['_url']);
6856
- queryParams = body['_query'];
6857
- delete body['config'];
6858
- delete body['_url'];
6859
- delete body['_query'];
6860
- response = this.apiClient
6861
- .request({
6862
- path: path,
6863
- queryParams: queryParams,
6864
- body: JSON.stringify(body),
6865
- httpMethod: 'DELETE',
6866
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6867
- })
6868
- .then((httpResponse) => {
6869
- return httpResponse.json();
6870
- });
6871
- return response.then(() => {
6872
- const resp = deleteFileResponseFromMldev();
6873
- const typedResp = new DeleteFileResponse();
6874
- Object.assign(typedResp, resp);
6875
- return typedResp;
6876
- });
6877
- }
6878
- }
6879
- }
6880
-
6881
7670
  const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
6882
7671
  async function uploadBlob(file, uploadUrl, apiClient) {
6883
7672
  var _a, _b;
@@ -7075,8 +7864,9 @@ class GoogleGenAI {
7075
7864
  this.chats = new Chats(this.models, this.apiClient);
7076
7865
  this.caches = new Caches(this.apiClient);
7077
7866
  this.files = new Files(this.apiClient);
7867
+ this.operations = new Operations(this.apiClient);
7078
7868
  }
7079
7869
  }
7080
7870
 
7081
- export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaResolution, Modality, Mode, Models, Outcome, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, State, SubjectReferenceType, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent };
7871
+ export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, State, SubjectReferenceType, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent };
7082
7872
  //# sourceMappingURL=index.mjs.map