@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.
@@ -12645,20 +12645,25 @@ function videoToVertex(fromObject, _rootObject) {
12645
12645
  * Copyright 2025 Google LLC
12646
12646
  * SPDX-License-Identifier: Apache-2.0
12647
12647
  */
12648
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
12649
- function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
12648
+ function createFileSearchStoreConfigToMldev(apiClient, fromObject, parentObject) {
12650
12649
  const toObject = {};
12651
12650
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
12652
12651
  if (parentObject !== undefined && fromDisplayName != null) {
12653
12652
  setValueByPath(parentObject, ['displayName'], fromDisplayName);
12654
12653
  }
12654
+ const fromEmbeddingModel = getValueByPath(fromObject, [
12655
+ 'embeddingModel',
12656
+ ]);
12657
+ if (parentObject !== undefined && fromEmbeddingModel != null) {
12658
+ setValueByPath(parentObject, ['embeddingModel'], tModel(apiClient, fromEmbeddingModel));
12659
+ }
12655
12660
  return toObject;
12656
12661
  }
12657
- function createFileSearchStoreParametersToMldev(fromObject) {
12662
+ function createFileSearchStoreParametersToMldev(apiClient, fromObject) {
12658
12663
  const toObject = {};
12659
12664
  const fromConfig = getValueByPath(fromObject, ['config']);
12660
12665
  if (fromConfig != null) {
12661
- createFileSearchStoreConfigToMldev(fromConfig, toObject);
12666
+ createFileSearchStoreConfigToMldev(apiClient, fromConfig, toObject);
12662
12667
  }
12663
12668
  return toObject;
12664
12669
  }
@@ -12884,7 +12889,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12884
12889
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12885
12890
  const USER_AGENT_HEADER = 'User-Agent';
12886
12891
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12887
- const SDK_VERSION = '1.51.0'; // x-release-please-version
12892
+ const SDK_VERSION = '1.52.0'; // x-release-please-version
12888
12893
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12889
12894
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12890
12895
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -17246,6 +17251,46 @@ class FileSearchStores extends BaseModule {
17246
17251
  }
17247
17252
  return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
17248
17253
  }
17254
+ /**
17255
+ * Downloads media using a Media ID or URI.
17256
+ * This method is only supported in the Gemini Developer client.
17257
+ *
17258
+ * @param uri - The URI or Media ID of the blob.
17259
+ * @param config - Optional configuration for the download.
17260
+ * @returns A promise that resolves to the blob data as a Uint8Array.
17261
+ */
17262
+ async downloadMedia(uri, config) {
17263
+ if (this.apiClient.isVertexAI()) {
17264
+ throw new Error('This method is only supported in the Gemini Developer client.');
17265
+ }
17266
+ const parsedUri = new URL(uri, 'http://dummy.com');
17267
+ let pathname = parsedUri.pathname;
17268
+ if (pathname.startsWith('/')) {
17269
+ pathname = pathname.slice(1);
17270
+ }
17271
+ if (!pathname.includes('/media/')) {
17272
+ throw new Error(`Invalid uri format: ${uri}. Expected to contain /media/`);
17273
+ }
17274
+ const queryParams = {};
17275
+ parsedUri.searchParams.forEach((value, key) => {
17276
+ queryParams[key] = value;
17277
+ });
17278
+ queryParams['alt'] = 'media';
17279
+ const httpOptions = Object.assign({}, config === null || config === void 0 ? void 0 : config.httpOptions);
17280
+ const response = await this.apiClient.request({
17281
+ path: pathname,
17282
+ httpMethod: 'GET',
17283
+ queryParams: queryParams,
17284
+ httpOptions: httpOptions,
17285
+ });
17286
+ if (response instanceof HttpResponse) {
17287
+ const arrayBuffer = await response.responseInternal.arrayBuffer();
17288
+ return new Uint8Array(arrayBuffer);
17289
+ }
17290
+ else {
17291
+ throw new Error('Unexpected response type from downloadMedia');
17292
+ }
17293
+ }
17249
17294
  /**
17250
17295
  * Creates a File Search Store.
17251
17296
  *
@@ -17261,7 +17306,7 @@ class FileSearchStores extends BaseModule {
17261
17306
  throw new Error('This method is only supported by the Gemini Developer API.');
17262
17307
  }
17263
17308
  else {
17264
- const body = createFileSearchStoreParametersToMldev(params);
17309
+ const body = createFileSearchStoreParametersToMldev(this.apiClient, params);
17265
17310
  path = formatMap('fileSearchStores', body['_url']);
17266
17311
  queryParams = body['_query'];
17267
17312
  delete body['_url'];