@google/genai 1.51.0 → 1.52.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.
@@ -12675,20 +12675,25 @@ function videoToVertex(fromObject, _rootObject) {
12675
12675
  * Copyright 2025 Google LLC
12676
12676
  * SPDX-License-Identifier: Apache-2.0
12677
12677
  */
12678
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
12679
- function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
12678
+ function createFileSearchStoreConfigToMldev(apiClient, fromObject, parentObject) {
12680
12679
  const toObject = {};
12681
12680
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
12682
12681
  if (parentObject !== undefined && fromDisplayName != null) {
12683
12682
  setValueByPath(parentObject, ['displayName'], fromDisplayName);
12684
12683
  }
12684
+ const fromEmbeddingModel = getValueByPath(fromObject, [
12685
+ 'embeddingModel',
12686
+ ]);
12687
+ if (parentObject !== undefined && fromEmbeddingModel != null) {
12688
+ setValueByPath(parentObject, ['embeddingModel'], tModel(apiClient, fromEmbeddingModel));
12689
+ }
12685
12690
  return toObject;
12686
12691
  }
12687
- function createFileSearchStoreParametersToMldev(fromObject) {
12692
+ function createFileSearchStoreParametersToMldev(apiClient, fromObject) {
12688
12693
  const toObject = {};
12689
12694
  const fromConfig = getValueByPath(fromObject, ['config']);
12690
12695
  if (fromConfig != null) {
12691
- createFileSearchStoreConfigToMldev(fromConfig, toObject);
12696
+ createFileSearchStoreConfigToMldev(apiClient, fromConfig, toObject);
12692
12697
  }
12693
12698
  return toObject;
12694
12699
  }
@@ -12914,7 +12919,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12914
12919
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12915
12920
  const USER_AGENT_HEADER = 'User-Agent';
12916
12921
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12917
- const SDK_VERSION = '1.51.0'; // x-release-please-version
12922
+ const SDK_VERSION = '1.52.0'; // x-release-please-version
12918
12923
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12919
12924
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12920
12925
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -17276,6 +17281,46 @@ class FileSearchStores extends BaseModule {
17276
17281
  }
17277
17282
  return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
17278
17283
  }
17284
+ /**
17285
+ * Downloads media using a Media ID or URI.
17286
+ * This method is only supported in the Gemini Developer client.
17287
+ *
17288
+ * @param uri - The URI or Media ID of the blob.
17289
+ * @param config - Optional configuration for the download.
17290
+ * @returns A promise that resolves to the blob data as a Uint8Array.
17291
+ */
17292
+ async downloadMedia(uri, config) {
17293
+ if (this.apiClient.isVertexAI()) {
17294
+ throw new Error('This method is only supported in the Gemini Developer client.');
17295
+ }
17296
+ const parsedUri = new URL(uri, 'http://dummy.com');
17297
+ let pathname = parsedUri.pathname;
17298
+ if (pathname.startsWith('/')) {
17299
+ pathname = pathname.slice(1);
17300
+ }
17301
+ if (!pathname.includes('/media/')) {
17302
+ throw new Error(`Invalid uri format: ${uri}. Expected to contain /media/`);
17303
+ }
17304
+ const queryParams = {};
17305
+ parsedUri.searchParams.forEach((value, key) => {
17306
+ queryParams[key] = value;
17307
+ });
17308
+ queryParams['alt'] = 'media';
17309
+ const httpOptions = Object.assign({}, config === null || config === void 0 ? void 0 : config.httpOptions);
17310
+ const response = await this.apiClient.request({
17311
+ path: pathname,
17312
+ httpMethod: 'GET',
17313
+ queryParams: queryParams,
17314
+ httpOptions: httpOptions,
17315
+ });
17316
+ if (response instanceof HttpResponse) {
17317
+ const arrayBuffer = await response.responseInternal.arrayBuffer();
17318
+ return new Uint8Array(arrayBuffer);
17319
+ }
17320
+ else {
17321
+ throw new Error('Unexpected response type from downloadMedia');
17322
+ }
17323
+ }
17279
17324
  /**
17280
17325
  * Creates a File Search Store.
17281
17326
  *
@@ -17291,7 +17336,7 @@ class FileSearchStores extends BaseModule {
17291
17336
  throw new Error('This method is only supported by the Gemini Developer API.');
17292
17337
  }
17293
17338
  else {
17294
- const body = createFileSearchStoreParametersToMldev(params);
17339
+ const body = createFileSearchStoreParametersToMldev(this.apiClient, params);
17295
17340
  path = formatMap('fileSearchStores', body['_url']);
17296
17341
  queryParams = body['_query'];
17297
17342
  delete body['_url'];
@@ -12653,20 +12653,25 @@ function videoToVertex(fromObject, _rootObject) {
12653
12653
  * Copyright 2025 Google LLC
12654
12654
  * SPDX-License-Identifier: Apache-2.0
12655
12655
  */
12656
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
12657
- function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
12656
+ function createFileSearchStoreConfigToMldev(apiClient, fromObject, parentObject) {
12658
12657
  const toObject = {};
12659
12658
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
12660
12659
  if (parentObject !== undefined && fromDisplayName != null) {
12661
12660
  setValueByPath(parentObject, ['displayName'], fromDisplayName);
12662
12661
  }
12662
+ const fromEmbeddingModel = getValueByPath(fromObject, [
12663
+ 'embeddingModel',
12664
+ ]);
12665
+ if (parentObject !== undefined && fromEmbeddingModel != null) {
12666
+ setValueByPath(parentObject, ['embeddingModel'], tModel(apiClient, fromEmbeddingModel));
12667
+ }
12663
12668
  return toObject;
12664
12669
  }
12665
- function createFileSearchStoreParametersToMldev(fromObject) {
12670
+ function createFileSearchStoreParametersToMldev(apiClient, fromObject) {
12666
12671
  const toObject = {};
12667
12672
  const fromConfig = getValueByPath(fromObject, ['config']);
12668
12673
  if (fromConfig != null) {
12669
- createFileSearchStoreConfigToMldev(fromConfig, toObject);
12674
+ createFileSearchStoreConfigToMldev(apiClient, fromConfig, toObject);
12670
12675
  }
12671
12676
  return toObject;
12672
12677
  }
@@ -12892,7 +12897,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12892
12897
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12893
12898
  const USER_AGENT_HEADER = 'User-Agent';
12894
12899
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12895
- const SDK_VERSION = '1.51.0'; // x-release-please-version
12900
+ const SDK_VERSION = '1.52.0'; // x-release-please-version
12896
12901
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12897
12902
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12898
12903
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -17254,6 +17259,46 @@ class FileSearchStores extends BaseModule {
17254
17259
  }
17255
17260
  return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
17256
17261
  }
17262
+ /**
17263
+ * Downloads media using a Media ID or URI.
17264
+ * This method is only supported in the Gemini Developer client.
17265
+ *
17266
+ * @param uri - The URI or Media ID of the blob.
17267
+ * @param config - Optional configuration for the download.
17268
+ * @returns A promise that resolves to the blob data as a Uint8Array.
17269
+ */
17270
+ async downloadMedia(uri, config) {
17271
+ if (this.apiClient.isVertexAI()) {
17272
+ throw new Error('This method is only supported in the Gemini Developer client.');
17273
+ }
17274
+ const parsedUri = new URL(uri, 'http://dummy.com');
17275
+ let pathname = parsedUri.pathname;
17276
+ if (pathname.startsWith('/')) {
17277
+ pathname = pathname.slice(1);
17278
+ }
17279
+ if (!pathname.includes('/media/')) {
17280
+ throw new Error(`Invalid uri format: ${uri}. Expected to contain /media/`);
17281
+ }
17282
+ const queryParams = {};
17283
+ parsedUri.searchParams.forEach((value, key) => {
17284
+ queryParams[key] = value;
17285
+ });
17286
+ queryParams['alt'] = 'media';
17287
+ const httpOptions = Object.assign({}, config === null || config === void 0 ? void 0 : config.httpOptions);
17288
+ const response = await this.apiClient.request({
17289
+ path: pathname,
17290
+ httpMethod: 'GET',
17291
+ queryParams: queryParams,
17292
+ httpOptions: httpOptions,
17293
+ });
17294
+ if (response instanceof HttpResponse) {
17295
+ const arrayBuffer = await response.responseInternal.arrayBuffer();
17296
+ return new Uint8Array(arrayBuffer);
17297
+ }
17298
+ else {
17299
+ throw new Error('Unexpected response type from downloadMedia');
17300
+ }
17301
+ }
17257
17302
  /**
17258
17303
  * Creates a File Search Store.
17259
17304
  *
@@ -17269,7 +17314,7 @@ class FileSearchStores extends BaseModule {
17269
17314
  throw new Error('This method is only supported by the Gemini Developer API.');
17270
17315
  }
17271
17316
  else {
17272
- const body = createFileSearchStoreParametersToMldev(params);
17317
+ const body = createFileSearchStoreParametersToMldev(this.apiClient, params);
17273
17318
  path = formatMap('fileSearchStores', body['_url']);
17274
17319
  queryParams = body['_query'];
17275
17320
  delete body['_url'];