@google/genai 0.2.0 → 0.4.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.
- package/README.md +1 -1
- package/dist/genai.d.ts +141 -83
- package/dist/index.js +201 -295
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -295
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +209 -305
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +145 -89
- package/dist/web/index.mjs +207 -297
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +143 -85
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ The submodules bundle together related API methods:
|
|
|
157
157
|
## Samples
|
|
158
158
|
|
|
159
159
|
More samples can be found in the
|
|
160
|
-
[github samples directory](https://github.com/google-gemini/generative-ai-js/tree/main/samples).
|
|
160
|
+
[github samples directory](https://github.com/google-gemini/generative-ai-js/tree/main/sdk-samples).
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
### Streaming
|
package/dist/genai.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ declare interface ApiClientInitOptions {
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* @license
|
|
102
|
-
* Copyright
|
|
102
|
+
* Copyright 2025 Google LLC
|
|
103
103
|
* SPDX-License-Identifier: Apache-2.0
|
|
104
104
|
*/
|
|
105
105
|
/**
|
|
@@ -114,11 +114,6 @@ declare interface Auth {
|
|
|
114
114
|
addAuthHeaders(headers: Headers): Promise<void>;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
* @license
|
|
119
|
-
* Copyright 2024 Google LLC
|
|
120
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
121
|
-
*/
|
|
122
117
|
declare class BaseModule {
|
|
123
118
|
}
|
|
124
119
|
|
|
@@ -182,7 +177,7 @@ export declare class Caches extends BaseModule {
|
|
|
182
177
|
*
|
|
183
178
|
* @example
|
|
184
179
|
* ```ts
|
|
185
|
-
* const cachedContents = await
|
|
180
|
+
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
186
181
|
* for (const cachedContent of cachedContents) {
|
|
187
182
|
* console.log(cachedContent);
|
|
188
183
|
* }
|
|
@@ -198,7 +193,7 @@ export declare class Caches extends BaseModule {
|
|
|
198
193
|
* @example
|
|
199
194
|
* ```ts
|
|
200
195
|
* const contents = ...; // Initialize the content to cache.
|
|
201
|
-
* const response = await
|
|
196
|
+
* const response = await ai.caches.create({
|
|
202
197
|
* model: 'gemini-2.0-flash',
|
|
203
198
|
* config: {
|
|
204
199
|
* 'contents': contents,
|
|
@@ -218,7 +213,7 @@ export declare class Caches extends BaseModule {
|
|
|
218
213
|
*
|
|
219
214
|
* @example
|
|
220
215
|
* ```ts
|
|
221
|
-
* await
|
|
216
|
+
* await ai.caches.get({name: 'gemini-1.5-flash'});
|
|
222
217
|
* ```
|
|
223
218
|
*/
|
|
224
219
|
get(params: types.GetCachedContentParameters): Promise<types.CachedContent>;
|
|
@@ -230,7 +225,7 @@ export declare class Caches extends BaseModule {
|
|
|
230
225
|
*
|
|
231
226
|
* @example
|
|
232
227
|
* ```ts
|
|
233
|
-
* await
|
|
228
|
+
* await ai.caches.delete({name: 'gemini-1.5-flash'});
|
|
234
229
|
* ```
|
|
235
230
|
*/
|
|
236
231
|
delete(params: types.DeleteCachedContentParameters): Promise<types.DeleteCachedContentResponse>;
|
|
@@ -242,7 +237,7 @@ export declare class Caches extends BaseModule {
|
|
|
242
237
|
*
|
|
243
238
|
* @example
|
|
244
239
|
* ```ts
|
|
245
|
-
* const response = await
|
|
240
|
+
* const response = await ai.caches.update({
|
|
246
241
|
* name: 'gemini-1.5-flash',
|
|
247
242
|
* config: {'ttl': '7600s'}
|
|
248
243
|
* });
|
|
@@ -281,8 +276,11 @@ export declare interface Candidate {
|
|
|
281
276
|
}
|
|
282
277
|
|
|
283
278
|
/**
|
|
284
|
-
* Chat session that enables sending messages
|
|
285
|
-
*
|
|
279
|
+
* Chat session that enables sending messages to the model with previous
|
|
280
|
+
* conversation context.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* The session maintains all the turns between user and model.
|
|
286
284
|
*/
|
|
287
285
|
export declare class Chat {
|
|
288
286
|
private readonly apiClient;
|
|
@@ -302,6 +300,15 @@ export declare class Chat {
|
|
|
302
300
|
* @see {@link Chat#sendMessageStream} for streaming method.
|
|
303
301
|
* @param params - parameters for sending messages within a chat session.
|
|
304
302
|
* @returns The model's response.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
307
|
+
* const response = await chat.sendMessage({
|
|
308
|
+
* message: 'Why is the sky blue?'
|
|
309
|
+
* });
|
|
310
|
+
* console.log(response.text);
|
|
311
|
+
* ```
|
|
305
312
|
*/
|
|
306
313
|
sendMessage(params: types.SendMessageParameters): Promise<types.GenerateContentResponse>;
|
|
307
314
|
/**
|
|
@@ -314,6 +321,17 @@ export declare class Chat {
|
|
|
314
321
|
* @see {@link Chat#sendMessage} for non-streaming method.
|
|
315
322
|
* @param params - parameters for sending the message.
|
|
316
323
|
* @return The model's response.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
328
|
+
* const response = await chat.sendMessageStream({
|
|
329
|
+
* message: 'Why is the sky blue?'
|
|
330
|
+
* });
|
|
331
|
+
* for await (const chunk of response) {
|
|
332
|
+
* console.log(chunk.text);
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
317
335
|
*/
|
|
318
336
|
sendMessageStream(params: types.SendMessageParameters): Promise<AsyncGenerator<types.GenerateContentResponse>>;
|
|
319
337
|
/**
|
|
@@ -354,8 +372,24 @@ export declare class Chats {
|
|
|
354
372
|
/**
|
|
355
373
|
* Creates a new chat session.
|
|
356
374
|
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* The config in the params will be used for all requests within the chat
|
|
377
|
+
* session unless overridden by a per-request `config` in
|
|
378
|
+
* {@link ./types.SendMessageParameters}.
|
|
379
|
+
*
|
|
357
380
|
* @param params - Parameters for creating a chat session.
|
|
358
381
|
* @returns A new chat session.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* const chat = ai.chats.create({
|
|
386
|
+
* model: 'gemini-2.0-flash'
|
|
387
|
+
* config: {
|
|
388
|
+
* temperature: 0.5,
|
|
389
|
+
* maxOutputTokens: 1024,
|
|
390
|
+
* }
|
|
391
|
+
* });
|
|
392
|
+
* ```
|
|
359
393
|
*/
|
|
360
394
|
create(params: types.CreateChatParameters): Chat;
|
|
361
395
|
}
|
|
@@ -393,6 +427,16 @@ export declare interface CodeExecutionResult {
|
|
|
393
427
|
output?: string;
|
|
394
428
|
}
|
|
395
429
|
|
|
430
|
+
declare namespace common {
|
|
431
|
+
export {
|
|
432
|
+
formatMap,
|
|
433
|
+
setValueByPath,
|
|
434
|
+
getValueByPath,
|
|
435
|
+
BaseModule,
|
|
436
|
+
UploadFileParameters
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
396
440
|
/** Optional parameters for computing tokens. */
|
|
397
441
|
export declare interface ComputeTokensConfig {
|
|
398
442
|
/** Used to override HTTP request options. */
|
|
@@ -660,11 +704,6 @@ export declare function createPartFromText(text: string): Part;
|
|
|
660
704
|
*/
|
|
661
705
|
export declare function createPartFromUri(uri: string, mimeType: string): Part;
|
|
662
706
|
|
|
663
|
-
/**
|
|
664
|
-
* Creates a `Part` object from the `startOffset` and `endOffset` of a `VideoMetadata` object.
|
|
665
|
-
*/
|
|
666
|
-
export declare function createPartFromVideoMetadata(startOffset: string, endOffset: string): Part;
|
|
667
|
-
|
|
668
707
|
/**
|
|
669
708
|
* Creates a `Content` object with a user role from a `PartListUnion` object or `string`.
|
|
670
709
|
*/
|
|
@@ -830,7 +869,7 @@ declare class Files extends BaseModule {
|
|
|
830
869
|
* size of each page is 10.
|
|
831
870
|
*
|
|
832
871
|
* ```ts
|
|
833
|
-
* const listResponse = await
|
|
872
|
+
* const listResponse = await ai.files.list({config: {'pageSize': 10}});
|
|
834
873
|
* for await (const file of listResponse) {
|
|
835
874
|
* console.log(file.name);
|
|
836
875
|
* }
|
|
@@ -860,26 +899,26 @@ declare class Files extends BaseModule {
|
|
|
860
899
|
*
|
|
861
900
|
* This section can contain multiple paragraphs and code examples.
|
|
862
901
|
*
|
|
863
|
-
* @param
|
|
864
|
-
*
|
|
865
|
-
*
|
|
902
|
+
* @param params - Optional parameters specified in the
|
|
903
|
+
* `common.UploadFileParameters` interface.
|
|
904
|
+
* Optional @see {@link common.UploadFileParameters}
|
|
866
905
|
* @return A promise that resolves to a `types.File` object.
|
|
867
906
|
* @throws An error if called on a Vertex AI client.
|
|
868
907
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
869
|
-
* the `mimeType` can be provided in the `config` parameter.
|
|
908
|
+
* the `mimeType` can be provided in the `params.config` parameter.
|
|
870
909
|
* @throws An error occurs if a suitable upload location cannot be established.
|
|
871
910
|
*
|
|
872
911
|
* @example
|
|
873
912
|
* The following code uploads a file to Gemini API.
|
|
874
913
|
*
|
|
875
914
|
* ```ts
|
|
876
|
-
* const file = await
|
|
915
|
+
* const file = await ai.files.upload({file: 'file.txt', config: {
|
|
877
916
|
* mimeType: 'text/plain',
|
|
878
|
-
* });
|
|
917
|
+
* }});
|
|
879
918
|
* console.log(file.name);
|
|
880
919
|
* ```
|
|
881
920
|
*/
|
|
882
|
-
upload(
|
|
921
|
+
upload(params: common.UploadFileParameters): Promise<types.File>;
|
|
883
922
|
private listInternal;
|
|
884
923
|
private createInternal;
|
|
885
924
|
/**
|
|
@@ -893,7 +932,7 @@ declare class Files extends BaseModule {
|
|
|
893
932
|
* const config: GetFileParameters = {
|
|
894
933
|
* name: fileName,
|
|
895
934
|
* };
|
|
896
|
-
* file = await
|
|
935
|
+
* file = await ai.files.get(config);
|
|
897
936
|
* console.log(file.name);
|
|
898
937
|
* ```
|
|
899
938
|
*/
|
|
@@ -953,6 +992,8 @@ export declare enum FinishReason {
|
|
|
953
992
|
MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL"
|
|
954
993
|
}
|
|
955
994
|
|
|
995
|
+
declare function formatMap(templateString: string, valueMap: Record<string, unknown>): string;
|
|
996
|
+
|
|
956
997
|
/** A function call. */
|
|
957
998
|
export declare interface FunctionCall {
|
|
958
999
|
/** The unique id of the function call. If populated, the client to execute the
|
|
@@ -1295,6 +1336,10 @@ export declare interface GeneratedImage {
|
|
|
1295
1336
|
response.
|
|
1296
1337
|
*/
|
|
1297
1338
|
raiFilteredReason?: string;
|
|
1339
|
+
/** Safety attributes of the image. Lists of RAI categories and their
|
|
1340
|
+
scores of each content.
|
|
1341
|
+
*/
|
|
1342
|
+
safetyAttributes?: SafetyAttributes;
|
|
1298
1343
|
/** The rewritten prompt used for the image generation if the prompt
|
|
1299
1344
|
enhancer is enabled.
|
|
1300
1345
|
*/
|
|
@@ -1461,6 +1506,8 @@ export declare interface GetFileParameters {
|
|
|
1461
1506
|
config?: GetFileConfig;
|
|
1462
1507
|
}
|
|
1463
1508
|
|
|
1509
|
+
declare function getValueByPath(data: unknown, keys: string[]): unknown;
|
|
1510
|
+
|
|
1464
1511
|
/**
|
|
1465
1512
|
* The Google GenAI SDK.
|
|
1466
1513
|
*
|
|
@@ -1564,13 +1611,6 @@ export declare interface GoogleGenAIOptions {
|
|
|
1564
1611
|
* Optional. A set of customizable configuration for HTTP requests.
|
|
1565
1612
|
*/
|
|
1566
1613
|
httpOptions?: HttpOptions;
|
|
1567
|
-
/**
|
|
1568
|
-
* The object used for adding authentication headers to API requests.
|
|
1569
|
-
*
|
|
1570
|
-
* @remarks
|
|
1571
|
-
* Only used for internal testing, will be removed in the future.
|
|
1572
|
-
*/
|
|
1573
|
-
auth?: Auth;
|
|
1574
1614
|
}
|
|
1575
1615
|
|
|
1576
1616
|
/** Tool to support Google Search in Model. Powered by Google. */
|
|
@@ -1841,20 +1881,14 @@ export declare class Live {
|
|
|
1841
1881
|
Establishes a connection to the specified model with the given
|
|
1842
1882
|
configuration and returns a Session object representing that connection.
|
|
1843
1883
|
|
|
1844
|
-
> [!CAUTION] This SDK does not yet support the live API for **Google Vertex AI**.
|
|
1845
|
-
|
|
1846
1884
|
@experimental
|
|
1847
1885
|
|
|
1848
|
-
@param
|
|
1849
|
-
@
|
|
1850
|
-
@param callbacks - Optional callbacks for websocket events. If not
|
|
1851
|
-
provided, default no-op callbacks will be used. Generally, prefer to
|
|
1852
|
-
provide explicit callbacks to allow for proper handling of websocket
|
|
1853
|
-
events (e.g. connection errors).
|
|
1886
|
+
@param params - The parameters for establishing a connection to the model.
|
|
1887
|
+
@return A live session.
|
|
1854
1888
|
|
|
1855
1889
|
@example
|
|
1856
1890
|
```ts
|
|
1857
|
-
const session = await
|
|
1891
|
+
const session = await ai.live.connect({
|
|
1858
1892
|
model: 'gemini-2.0-flash-exp',
|
|
1859
1893
|
config: {
|
|
1860
1894
|
responseModalities: [Modality.AUDIO],
|
|
@@ -1881,10 +1915,10 @@ export declare class Live {
|
|
|
1881
1915
|
|
|
1882
1916
|
/** Callbacks for the live API. */
|
|
1883
1917
|
export declare interface LiveCallbacks {
|
|
1884
|
-
onopen
|
|
1918
|
+
onopen?: (() => void) | null;
|
|
1885
1919
|
onmessage: (e: LiveServerMessage) => void;
|
|
1886
|
-
onerror
|
|
1887
|
-
onclose
|
|
1920
|
+
onerror?: ((e: ErrorEvent) => void) | null;
|
|
1921
|
+
onclose?: ((e: CloseEvent) => void) | null;
|
|
1888
1922
|
}
|
|
1889
1923
|
|
|
1890
1924
|
/** Incremental update of the current conversation delivered from the client.
|
|
@@ -2179,14 +2213,12 @@ export declare class Models extends BaseModule {
|
|
|
2179
2213
|
*
|
|
2180
2214
|
* Some models support multimodal input and output.
|
|
2181
2215
|
*
|
|
2182
|
-
* @param
|
|
2183
|
-
* @param contents - The input contents to use for generating content.
|
|
2184
|
-
* @param [config] - The configuration for generating content.
|
|
2216
|
+
* @param params - The parameters for generating content.
|
|
2185
2217
|
* @return The response from generating content.
|
|
2186
2218
|
*
|
|
2187
2219
|
* @example
|
|
2188
2220
|
* ```ts
|
|
2189
|
-
* const response = await
|
|
2221
|
+
* const response = await ai.models.generateContent({
|
|
2190
2222
|
* model: 'gemini-2.0-flash',
|
|
2191
2223
|
* contents: 'why is the sky blue?',
|
|
2192
2224
|
* config: {
|
|
@@ -2221,14 +2253,12 @@ export declare class Models extends BaseModule {
|
|
|
2221
2253
|
*
|
|
2222
2254
|
* Some models support multimodal input and output.
|
|
2223
2255
|
*
|
|
2224
|
-
* @param
|
|
2225
|
-
* @param contents - The input contents to use for generating content.
|
|
2226
|
-
* @param [config] - The configuration for generating content.
|
|
2256
|
+
* @param params - The parameters for generating content with streaming response.
|
|
2227
2257
|
* @return The response from generating content.
|
|
2228
2258
|
*
|
|
2229
2259
|
* @example
|
|
2230
2260
|
* ```ts
|
|
2231
|
-
* const response = await
|
|
2261
|
+
* const response = await ai.models.generateContentStream({
|
|
2232
2262
|
* model: 'gemini-2.0-flash',
|
|
2233
2263
|
* contents: 'why is the sky blue?',
|
|
2234
2264
|
* config: {
|
|
@@ -2246,14 +2276,12 @@ export declare class Models extends BaseModule {
|
|
|
2246
2276
|
/**
|
|
2247
2277
|
* Calculates embeddings for the given contents. Only text is supported.
|
|
2248
2278
|
*
|
|
2249
|
-
* @param
|
|
2250
|
-
* @param contents - The contents to embed.
|
|
2251
|
-
* @param [config] - The config for embedding contents.
|
|
2279
|
+
* @param params - The parameters for embedding contents.
|
|
2252
2280
|
* @return The response from the API.
|
|
2253
2281
|
*
|
|
2254
2282
|
* @example
|
|
2255
2283
|
* ```ts
|
|
2256
|
-
* const response = await
|
|
2284
|
+
* const response = await ai.models.embedContent({
|
|
2257
2285
|
* model: 'text-embedding-004',
|
|
2258
2286
|
* contents: [
|
|
2259
2287
|
* 'What is your name?',
|
|
@@ -2270,14 +2298,12 @@ export declare class Models extends BaseModule {
|
|
|
2270
2298
|
/**
|
|
2271
2299
|
* Generates an image based on a text description and configuration.
|
|
2272
2300
|
*
|
|
2273
|
-
* @param
|
|
2274
|
-
* @param prompt - A text description of the image to generate.
|
|
2275
|
-
* @param [config] - The config for image generation.
|
|
2301
|
+
* @param params - The parameters for generating images.
|
|
2276
2302
|
* @return The response from the API.
|
|
2277
2303
|
*
|
|
2278
2304
|
* @example
|
|
2279
2305
|
* ```ts
|
|
2280
|
-
* const response = await
|
|
2306
|
+
* const response = await ai.models.generateImages({
|
|
2281
2307
|
* model: 'imagen-3.0-generate-002',
|
|
2282
2308
|
* prompt: 'Robot holding a red skateboard',
|
|
2283
2309
|
* config: {
|
|
@@ -2293,14 +2319,12 @@ export declare class Models extends BaseModule {
|
|
|
2293
2319
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
2294
2320
|
* supported for Gemini models.
|
|
2295
2321
|
*
|
|
2296
|
-
* @param
|
|
2297
|
-
* @param contents - The contents to count tokens for.
|
|
2298
|
-
* @param [config] - The config for counting tokens.
|
|
2322
|
+
* @param params - The parameters for counting tokens.
|
|
2299
2323
|
* @return The response from the API.
|
|
2300
2324
|
*
|
|
2301
2325
|
* @example
|
|
2302
2326
|
* ```ts
|
|
2303
|
-
* const response = await
|
|
2327
|
+
* const response = await ai.models.countTokens({
|
|
2304
2328
|
* model: 'gemini-2.0-flash',
|
|
2305
2329
|
* contents: 'The quick brown fox jumps over the lazy dog.'
|
|
2306
2330
|
* });
|
|
@@ -2314,14 +2338,12 @@ export declare class Models extends BaseModule {
|
|
|
2314
2338
|
*
|
|
2315
2339
|
* This method is not supported by the Gemini Developer API.
|
|
2316
2340
|
*
|
|
2317
|
-
* @param
|
|
2318
|
-
* @param contents - The content to compute tokens for.
|
|
2319
|
-
* @param [config] - The config for computing tokens.
|
|
2341
|
+
* @param params - The parameters for computing tokens.
|
|
2320
2342
|
* @return The response from the API.
|
|
2321
2343
|
*
|
|
2322
2344
|
* @example
|
|
2323
2345
|
* ```ts
|
|
2324
|
-
* const response = await
|
|
2346
|
+
* const response = await ai.models.computeTokens({
|
|
2325
2347
|
* model: 'gemini-2.0-flash',
|
|
2326
2348
|
* contents: 'What is your name?'
|
|
2327
2349
|
* });
|
|
@@ -2333,7 +2355,7 @@ export declare class Models extends BaseModule {
|
|
|
2333
2355
|
|
|
2334
2356
|
/**
|
|
2335
2357
|
* @license
|
|
2336
|
-
* Copyright
|
|
2358
|
+
* Copyright 2025 Google LLC
|
|
2337
2359
|
* SPDX-License-Identifier: Apache-2.0
|
|
2338
2360
|
*/
|
|
2339
2361
|
export declare enum Outcome {
|
|
@@ -2345,7 +2367,7 @@ export declare enum Outcome {
|
|
|
2345
2367
|
|
|
2346
2368
|
/**
|
|
2347
2369
|
* @license
|
|
2348
|
-
* Copyright
|
|
2370
|
+
* Copyright 2025 Google LLC
|
|
2349
2371
|
* SPDX-License-Identifier: Apache-2.0
|
|
2350
2372
|
*/
|
|
2351
2373
|
/**
|
|
@@ -2359,6 +2381,22 @@ declare enum PagedItem {
|
|
|
2359
2381
|
PAGED_ITEM_CACHED_CONTENTS = "cachedContents"
|
|
2360
2382
|
}
|
|
2361
2383
|
|
|
2384
|
+
declare interface PagedItemConfig {
|
|
2385
|
+
config?: {
|
|
2386
|
+
pageToken?: string;
|
|
2387
|
+
pageSize?: number;
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
declare interface PagedItemResponse<T> {
|
|
2392
|
+
nextPageToken?: string;
|
|
2393
|
+
batchJobs?: T[];
|
|
2394
|
+
models?: T[];
|
|
2395
|
+
tuningJobs?: T[];
|
|
2396
|
+
files?: T[];
|
|
2397
|
+
cachedContents?: T[];
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2362
2400
|
/**
|
|
2363
2401
|
* Pager class for iterating through paginated results.
|
|
2364
2402
|
*/
|
|
@@ -2367,9 +2405,9 @@ declare class Pager<T> implements AsyncIterable<T> {
|
|
|
2367
2405
|
private pageInternal;
|
|
2368
2406
|
private paramsInternal;
|
|
2369
2407
|
private pageInternalSize;
|
|
2370
|
-
protected requestInternal: (params:
|
|
2408
|
+
protected requestInternal: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>;
|
|
2371
2409
|
protected idxInternal: number;
|
|
2372
|
-
constructor(name: PagedItem, request: (params:
|
|
2410
|
+
constructor(name: PagedItem, request: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>, response: PagedItemResponse<T>, params: PagedItemConfig);
|
|
2373
2411
|
private init;
|
|
2374
2412
|
private initNextPage;
|
|
2375
2413
|
/**
|
|
@@ -2399,7 +2437,7 @@ declare class Pager<T> implements AsyncIterable<T> {
|
|
|
2399
2437
|
* used to customize the API request. For example, the `pageToken` parameter
|
|
2400
2438
|
* contains the token to request the next page.
|
|
2401
2439
|
*/
|
|
2402
|
-
get params():
|
|
2440
|
+
get params(): PagedItemConfig;
|
|
2403
2441
|
/**
|
|
2404
2442
|
* Returns the total number of items in the current page.
|
|
2405
2443
|
*/
|
|
@@ -2557,6 +2595,16 @@ export declare interface RetrievalMetadata {
|
|
|
2557
2595
|
googleSearchDynamicRetrievalScore?: number;
|
|
2558
2596
|
}
|
|
2559
2597
|
|
|
2598
|
+
/** Safety attributes of a GeneratedImage or the user-provided prompt. */
|
|
2599
|
+
export declare interface SafetyAttributes {
|
|
2600
|
+
/** List of RAI categories.
|
|
2601
|
+
*/
|
|
2602
|
+
categories?: string[];
|
|
2603
|
+
/** List of scores of each categories.
|
|
2604
|
+
*/
|
|
2605
|
+
scores?: number[];
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2560
2608
|
export declare enum SafetyFilterLevel {
|
|
2561
2609
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
2562
2610
|
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -2600,12 +2648,8 @@ export declare interface Schema {
|
|
|
2600
2648
|
example?: unknown;
|
|
2601
2649
|
/** Optional. Pattern of the Type.STRING to restrict a string to a regular expression. */
|
|
2602
2650
|
pattern?: string;
|
|
2603
|
-
/** Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER */
|
|
2604
|
-
minimum?: number;
|
|
2605
2651
|
/** Optional. Default value of the data. */
|
|
2606
2652
|
default?: unknown;
|
|
2607
|
-
/** Optional. The value should be validated against any (one or more) of the subschemas in the list. */
|
|
2608
|
-
anyOf?: Schema[];
|
|
2609
2653
|
/** Optional. Maximum length of the Type.STRING */
|
|
2610
2654
|
maxLength?: string;
|
|
2611
2655
|
/** Optional. The title of the Schema. */
|
|
@@ -2614,10 +2658,10 @@ export declare interface Schema {
|
|
|
2614
2658
|
minLength?: string;
|
|
2615
2659
|
/** Optional. Minimum number of the properties for Type.OBJECT. */
|
|
2616
2660
|
minProperties?: string;
|
|
2617
|
-
/** Optional. Maximum value of the Type.INTEGER and Type.NUMBER */
|
|
2618
|
-
maximum?: number;
|
|
2619
2661
|
/** Optional. Maximum number of the properties for Type.OBJECT. */
|
|
2620
2662
|
maxProperties?: string;
|
|
2663
|
+
/** Optional. The value should be validated against any (one or more) of the subschemas in the list. */
|
|
2664
|
+
anyOf?: Schema[];
|
|
2621
2665
|
/** Optional. The description of the data. */
|
|
2622
2666
|
description?: string;
|
|
2623
2667
|
/** Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]} */
|
|
@@ -2628,8 +2672,12 @@ export declare interface Schema {
|
|
|
2628
2672
|
items?: Schema;
|
|
2629
2673
|
/** Optional. Maximum number of the elements for Type.ARRAY. */
|
|
2630
2674
|
maxItems?: string;
|
|
2675
|
+
/** Optional. Maximum value of the Type.INTEGER and Type.NUMBER */
|
|
2676
|
+
maximum?: number;
|
|
2631
2677
|
/** Optional. Minimum number of the elements for Type.ARRAY. */
|
|
2632
2678
|
minItems?: string;
|
|
2679
|
+
/** Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER */
|
|
2680
|
+
minimum?: number;
|
|
2633
2681
|
/** Optional. Indicates if the value may be null. */
|
|
2634
2682
|
nullable?: boolean;
|
|
2635
2683
|
/** Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT. */
|
|
@@ -2791,7 +2839,7 @@ export declare class Session {
|
|
|
2791
2839
|
|
|
2792
2840
|
@example
|
|
2793
2841
|
```ts
|
|
2794
|
-
const session = await
|
|
2842
|
+
const session = await ai.live.connect({
|
|
2795
2843
|
model: 'gemini-2.0-flash-exp',
|
|
2796
2844
|
config: {
|
|
2797
2845
|
responseModalities: [Modality.AUDIO],
|
|
@@ -2826,6 +2874,8 @@ export declare class SessionSendToolResponseParameters {
|
|
|
2826
2874
|
functionResponses: FunctionResponse | FunctionResponse[];
|
|
2827
2875
|
}
|
|
2828
2876
|
|
|
2877
|
+
declare function setValueByPath(data: Record<string, unknown>, keys: string[], value: unknown): void;
|
|
2878
|
+
|
|
2829
2879
|
/** The speech generation configuration. */
|
|
2830
2880
|
export declare interface SpeechConfig {
|
|
2831
2881
|
/** The configuration for the speaker to use.
|
|
@@ -2994,7 +3044,6 @@ declare namespace types {
|
|
|
2994
3044
|
createPartFromFunctionCall,
|
|
2995
3045
|
createPartFromFunctionResponse,
|
|
2996
3046
|
createPartFromBase64,
|
|
2997
|
-
createPartFromVideoMetadata,
|
|
2998
3047
|
createPartFromCodeExecutionResult,
|
|
2999
3048
|
createPartFromExecutableCode,
|
|
3000
3049
|
createUserContent,
|
|
@@ -3084,6 +3133,7 @@ declare namespace types {
|
|
|
3084
3133
|
GenerateImagesConfig,
|
|
3085
3134
|
GenerateImagesParameters,
|
|
3086
3135
|
Image_2 as Image,
|
|
3136
|
+
SafetyAttributes,
|
|
3087
3137
|
GeneratedImage,
|
|
3088
3138
|
GenerateImagesResponse,
|
|
3089
3139
|
GenerationConfig,
|
|
@@ -3220,6 +3270,14 @@ export declare interface UploadFileConfig {
|
|
|
3220
3270
|
displayName?: string;
|
|
3221
3271
|
}
|
|
3222
3272
|
|
|
3273
|
+
/** Parameters for the upload file method. */
|
|
3274
|
+
declare interface UploadFileParameters {
|
|
3275
|
+
/** The string path to the file to be uploaded or a Blob object. */
|
|
3276
|
+
file: string | Blob;
|
|
3277
|
+
/** Configuration that contains optional parameters. */
|
|
3278
|
+
config?: UploadFileConfig;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3223
3281
|
/** Configuration for upscaling an image.
|
|
3224
3282
|
|
|
3225
3283
|
For more information on this configuration, refer to
|