@google/genai 1.52.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/genai.d.ts +438 -432
- package/dist/index.cjs +30 -10
- package/dist/index.mjs +30 -10
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +30 -10
- package/dist/node/index.mjs +30 -10
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +438 -432
- package/dist/vertex_internal/index.cjs +29 -8
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.js +29 -8
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +30 -10
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +438 -432
- package/package.json +2 -2
|
@@ -2050,7 +2050,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
2050
2050
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2051
2051
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2052
2052
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2053
|
-
const SDK_VERSION = '
|
|
2053
|
+
const SDK_VERSION = '2.0.1'; // x-release-please-version
|
|
2054
2054
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2055
2055
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2056
2056
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2315,6 +2315,24 @@ class ApiClient {
|
|
|
2315
2315
|
const abortController = new AbortController();
|
|
2316
2316
|
const signal = abortController.signal;
|
|
2317
2317
|
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
2318
|
+
// In Node > 18, the built-in fetch is backed by Undici. Undici sets a global
|
|
2319
|
+
// dispatcher on the global scope which tracks its internal headersTimeout and
|
|
2320
|
+
// bodyTimeout using Symbol properties.
|
|
2321
|
+
const dispatcherSymbol = Symbol.for('undici.globalDispatcher.1');
|
|
2322
|
+
const globalDispatcher = globalThis[dispatcherSymbol];
|
|
2323
|
+
if (globalDispatcher) {
|
|
2324
|
+
const symbols = Object.getOwnPropertySymbols(globalDispatcher);
|
|
2325
|
+
for (const sym of symbols) {
|
|
2326
|
+
const desc = sym.description;
|
|
2327
|
+
if ((desc === null || desc === void 0 ? void 0 : desc.includes('headers timeout')) ||
|
|
2328
|
+
(desc === null || desc === void 0 ? void 0 : desc.includes('body timeout'))) {
|
|
2329
|
+
const currentTimeout = globalDispatcher[sym];
|
|
2330
|
+
if (typeof currentTimeout === 'number') {
|
|
2331
|
+
globalDispatcher[sym] = Math.max(currentTimeout, httpOptions.timeout);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2318
2336
|
const timeoutHandle = setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
2319
2337
|
if (timeoutHandle &&
|
|
2320
2338
|
typeof timeoutHandle.unref ===
|
|
@@ -2348,7 +2366,7 @@ class ApiClient {
|
|
|
2348
2366
|
throw e;
|
|
2349
2367
|
}
|
|
2350
2368
|
else {
|
|
2351
|
-
throw new Error(
|
|
2369
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
2352
2370
|
}
|
|
2353
2371
|
});
|
|
2354
2372
|
}
|
|
@@ -2363,7 +2381,7 @@ class ApiClient {
|
|
|
2363
2381
|
throw e;
|
|
2364
2382
|
}
|
|
2365
2383
|
else {
|
|
2366
|
-
throw new Error(
|
|
2384
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
2367
2385
|
}
|
|
2368
2386
|
});
|
|
2369
2387
|
}
|
|
@@ -2491,11 +2509,14 @@ class ApiClient {
|
|
|
2491
2509
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
2492
2510
|
headers.append(key, value);
|
|
2493
2511
|
}
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2512
|
+
}
|
|
2513
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
2514
|
+
// in milliseconds but the header is in seconds.
|
|
2515
|
+
// NOTE: This is intentionally outside the httpOptions.headers guard above
|
|
2516
|
+
// so that the X-Server-Timeout header is always sent whenever a timeout
|
|
2517
|
+
// is configured, even if the caller did not supply any custom headers.
|
|
2518
|
+
if ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) && httpOptions.timeout > 0) {
|
|
2519
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
2499
2520
|
}
|
|
2500
2521
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
2501
2522
|
return headers;
|