Skip to content

Commit f05fb0c

Browse files
google-genai-botamirh
authored andcommitted
No public description
COPYBARA_INTEGRATE_REVIEW=#1090 from googleapis:release-please--branches--main--components--genai bbf62d2 PiperOrigin-RevId: 835600229
1 parent a9a4458 commit f05fb0c

File tree

11 files changed

+39
-15
lines changed

11 files changed

+39
-15
lines changed

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
with:
1919
node-version: 22.x
2020
cache: 'npm'
21-
- run: npm ci
21+
- run: USE_LOCAL_BUILD=true npm ci
2222
- run: npm run coverage-report

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
node-version: 22.x
2020
cache: 'npm'
21-
- run: npm ci
21+
- run: USE_LOCAL_BUILD=true npm ci
2222
- name: Run format
2323
run: npx prettier '**/*.ts' '**/*.mjs' '**/*.mjs' '**/*.json' --check
2424
- name: Run linter

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
cache: 'npm'
26-
- run: npm ci
26+
- run: USE_LOCAL_BUILD=true npm ci
2727
- run: npm run build
2828
- run: npm run unit-test
2929
- run: npm run test-server-tests

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
},
3939
"scripts": {
40-
"prepare": "npm run build-prod",
40+
"prepare": "node scripts/prepare.js",
4141
"build": "patch-package && rollup -c && npm-run-all --parallel api-extractor:dev:* && node scripts/ignore_missing_mcp_dep.js",
4242
"build-prod": "patch-package && rollup -c && npm-run-all --parallel api-extractor:prod:* && node scripts/ignore_missing_mcp_dep.js",
4343
"api-extractor:dev:main": "api-extractor run --local --verbose",

scripts/prepare.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import { execSync } from 'node:child_process';
8+
import process from 'node:process';
9+
10+
const isLocal = process.env.USE_LOCAL_BUILD === 'true';
11+
const command = isLocal ? 'npm run build' : 'npm run build-prod';
12+
13+
console.log(`> Executing: ${command}`);
14+
15+
try {
16+
execSync(command, { stdio: 'inherit' });
17+
} catch (err) {
18+
process.exit(1);
19+
}

sdk-samples/file_search_stores.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function uploadBlobToFileSearchStore(fileSearchStoreName: string) {
6767
file: BLOB,
6868
config: {
6969
customMetadata: [{key: 'author', stringValue: 'foo'}],
70+
displayName: 'a blob name',
7071
},
7172
});
7273
while (!op.done) {

src/_api_client.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {Auth} from './_auth.js';
88
import * as common from './_common.js';
99
import {Downloader} from './_downloader.js';
1010
import {Uploader} from './_uploader.js';
11+
import {uploadToFileSearchStoreConfigToMldev} from './converters/_filesearchstores_converters.js';
1112
import {ApiError} from './errors.js';
1213
import * as types from './types.js';
1314

@@ -726,11 +727,8 @@ export class ApiClient {
726727
const path = `upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`;
727728
const fileName = this.getFileName(file);
728729
const body: Record<string, unknown> = {};
729-
if (config?.customMetadata) {
730-
body['customMetadata'] = config.customMetadata;
731-
}
732-
if (config?.chunkingConfig) {
733-
body['chunkingConfig'] = config.chunkingConfig;
730+
if (config != null) {
731+
uploadToFileSearchStoreConfigToMldev(config, body);
734732
}
735733
const uploadUrl = await this.fetchUploadUrl(
736734
path,

src/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class GoogleGenAI {
125125
private readonly apiKey?: string;
126126
public readonly vertexai: boolean;
127127
private readonly apiVersion?: string;
128+
private readonly httpOptions?: HttpOptions;
128129
readonly models: Models;
129130
readonly live: Live;
130131
readonly batches: Batches;
@@ -145,13 +146,14 @@ export class GoogleGenAI {
145146
this.vertexai = options.vertexai ?? false;
146147
this.apiKey = options.apiKey;
147148
this.apiVersion = options.apiVersion;
149+
this.httpOptions = options.httpOptions;
148150
const auth = new WebAuth(this.apiKey);
149151
this.apiClient = new ApiClient({
150152
auth: auth,
151153
apiVersion: this.apiVersion,
152154
apiKey: this.apiKey,
153155
vertexai: this.vertexai,
154-
httpOptions: options.httpOptions,
156+
httpOptions: this.httpOptions,
155157
userAgentExtra: LANGUAGE_LABEL_PREFIX + 'cross',
156158
uploader: new CrossUploader(),
157159
downloader: new CrossDownloader(),

src/node/node_client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {NodeWebSocketFactory} from '../node/_node_websocket.js';
2222
import {Operations} from '../operations.js';
2323
import {Tokens} from '../tokens.js';
2424
import {Tunings} from '../tunings.js';
25+
import {HttpOptions} from '../types.js';
2526
import {NodeUploader} from './_node_uploader.js';
2627

2728
const LANGUAGE_LABEL_PREFIX = 'gl-node/';
@@ -74,6 +75,7 @@ export class GoogleGenAI {
7475
private readonly project?: string;
7576
private readonly location?: string;
7677
private readonly apiVersion?: string;
78+
private readonly httpOptions?: HttpOptions;
7779
readonly models: Models;
7880
readonly live: Live;
7981
readonly batches: Batches;
@@ -84,7 +86,6 @@ export class GoogleGenAI {
8486
readonly authTokens: Tokens;
8587
readonly tunings: Tunings;
8688
readonly fileSearchStores: FileSearchStores;
87-
8889
constructor(options: GoogleGenAIOptions) {
8990
// Validate explicitly set initializer values.
9091
if ((options.project || options.location) && options.apiKey) {
@@ -158,6 +159,7 @@ export class GoogleGenAI {
158159
}
159160

160161
this.apiVersion = options.apiVersion;
162+
this.httpOptions = options.httpOptions;
161163
const auth = new NodeAuth({
162164
apiKey: this.apiKey,
163165
googleAuthOptions: options.googleAuthOptions,
@@ -169,7 +171,7 @@ export class GoogleGenAI {
169171
apiVersion: this.apiVersion,
170172
apiKey: this.apiKey,
171173
vertexai: this.vertexai,
172-
httpOptions: options.httpOptions,
174+
httpOptions: this.httpOptions,
173175
userAgentExtra: LANGUAGE_LABEL_PREFIX + process.version,
174176
uploader: new NodeUploader(),
175177
downloader: new NodeDownloader(),

src/web/web_client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {Models} from '../models.js';
1717
import {Operations} from '../operations.js';
1818
import {Tokens} from '../tokens.js';
1919
import {Tunings} from '../tunings.js';
20+
import {HttpOptions} from '../types.js';
2021

2122
import {BrowserDownloader} from './_browser_downloader.js';
2223
import {BrowserUploader} from './_browser_uploader.js';
@@ -66,6 +67,7 @@ export class GoogleGenAI {
6667
private readonly apiKey?: string;
6768
public readonly vertexai: boolean;
6869
private readonly apiVersion?: string;
70+
private readonly httpOptions?: HttpOptions;
6971
readonly models: Models;
7072
readonly live: Live;
7173
readonly batches: Batches;
@@ -76,7 +78,6 @@ export class GoogleGenAI {
7678
readonly authTokens: Tokens;
7779
readonly tunings: Tunings;
7880
readonly fileSearchStores: FileSearchStores;
79-
8081
constructor(options: GoogleGenAIOptions) {
8182
if (options.apiKey == null) {
8283
throw new Error('An API Key must be set when running in a browser');
@@ -106,13 +107,14 @@ export class GoogleGenAI {
106107
}
107108

108109
this.apiVersion = options.apiVersion;
110+
this.httpOptions = options.httpOptions;
109111
const auth = new WebAuth(this.apiKey);
110112
this.apiClient = new ApiClient({
111113
auth: auth,
112114
apiVersion: this.apiVersion,
113115
apiKey: this.apiKey,
114116
vertexai: this.vertexai,
115-
httpOptions: options.httpOptions,
117+
httpOptions: this.httpOptions,
116118
userAgentExtra: LANGUAGE_LABEL_PREFIX + 'web',
117119
uploader: new BrowserUploader(),
118120
downloader: new BrowserDownloader(),

0 commit comments

Comments
 (0)