@google/genai 0.6.1 → 0.7.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/dist/genai.d.ts +195 -11
- package/dist/index.js +802 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +795 -5
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +3848 -3054
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +195 -11
- package/dist/web/index.mjs +1809 -1019
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +195 -11
- package/package.json +2 -2
package/dist/web/web.d.ts
CHANGED
|
@@ -187,6 +187,12 @@ export declare class Caches extends BaseModule {
|
|
|
187
187
|
/**
|
|
188
188
|
* Creates a cached contents resource.
|
|
189
189
|
*
|
|
190
|
+
* @remarks
|
|
191
|
+
* Context caching is only supported for specific models. See [Gemini
|
|
192
|
+
* Developer API reference] (https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
|
|
193
|
+
* and [Vertex AI reference] (https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
|
|
194
|
+
* for more information.
|
|
195
|
+
*
|
|
190
196
|
* @param params - The parameters for the create request.
|
|
191
197
|
* @return The created cached content.
|
|
192
198
|
*
|
|
@@ -194,7 +200,7 @@ export declare class Caches extends BaseModule {
|
|
|
194
200
|
* ```ts
|
|
195
201
|
* const contents = ...; // Initialize the content to cache.
|
|
196
202
|
* const response = await ai.caches.create({
|
|
197
|
-
* model: 'gemini-
|
|
203
|
+
* model: 'gemini-1.5-flash',
|
|
198
204
|
* config: {
|
|
199
205
|
* 'contents': contents,
|
|
200
206
|
* 'displayName': 'test cache',
|
|
@@ -578,9 +584,9 @@ export declare class CountTokensResponse {
|
|
|
578
584
|
export declare interface CreateCachedContentConfig {
|
|
579
585
|
/** Used to override HTTP request options. */
|
|
580
586
|
httpOptions?: HttpOptions;
|
|
581
|
-
/** The TTL for this resource. The expiration time is computed: now + TTL. */
|
|
587
|
+
/** The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s". */
|
|
582
588
|
ttl?: string;
|
|
583
|
-
/** Timestamp of when this resource is considered expired. */
|
|
589
|
+
/** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
|
|
584
590
|
expireTime?: string;
|
|
585
591
|
/** The user-generated meaningful display name of the cached content.
|
|
586
592
|
*/
|
|
@@ -828,6 +834,20 @@ export declare interface ExecutableCode {
|
|
|
828
834
|
language?: Language;
|
|
829
835
|
}
|
|
830
836
|
|
|
837
|
+
export declare interface FetchPredictOperationConfig {
|
|
838
|
+
/** Used to override HTTP request options. */
|
|
839
|
+
httpOptions?: HttpOptions;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** Parameters for the fetchPredictOperation method. */
|
|
843
|
+
export declare interface FetchPredictOperationParameters {
|
|
844
|
+
/** The server-assigned name for the operation. */
|
|
845
|
+
operationName: string;
|
|
846
|
+
resourceName: string;
|
|
847
|
+
/** Used to override the default configuration. */
|
|
848
|
+
config?: FetchPredictOperationConfig;
|
|
849
|
+
}
|
|
850
|
+
|
|
831
851
|
/** A file uploaded to the API. */
|
|
832
852
|
declare interface File_2 {
|
|
833
853
|
/** The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456` */
|
|
@@ -837,7 +857,7 @@ declare interface File_2 {
|
|
|
837
857
|
/** Output only. MIME type of the file. */
|
|
838
858
|
mimeType?: string;
|
|
839
859
|
/** Output only. Size of the file in bytes. */
|
|
840
|
-
sizeBytes?:
|
|
860
|
+
sizeBytes?: string;
|
|
841
861
|
/** Output only. The timestamp of when the `File` was created. */
|
|
842
862
|
createTime?: string;
|
|
843
863
|
/** Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire. */
|
|
@@ -869,7 +889,7 @@ export declare interface FileData {
|
|
|
869
889
|
mimeType?: string;
|
|
870
890
|
}
|
|
871
891
|
|
|
872
|
-
declare class Files extends BaseModule {
|
|
892
|
+
export declare class Files extends BaseModule {
|
|
873
893
|
private readonly apiClient;
|
|
874
894
|
constructor(apiClient: ApiClient);
|
|
875
895
|
/**
|
|
@@ -915,7 +935,6 @@ declare class Files extends BaseModule {
|
|
|
915
935
|
*
|
|
916
936
|
* @param params - Optional parameters specified in the
|
|
917
937
|
* `common.UploadFileParameters` interface.
|
|
918
|
-
* Optional @see {@link common.UploadFileParameters}
|
|
919
938
|
* @return A promise that resolves to a `types.File` object.
|
|
920
939
|
* @throws An error if called on a Vertex AI client.
|
|
921
940
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -1387,6 +1406,12 @@ export declare interface GeneratedImage {
|
|
|
1387
1406
|
enhancedPrompt?: string;
|
|
1388
1407
|
}
|
|
1389
1408
|
|
|
1409
|
+
/** A generated video. */
|
|
1410
|
+
export declare interface GeneratedVideo {
|
|
1411
|
+
/** The output video */
|
|
1412
|
+
video?: Video;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1390
1415
|
/** The config for generating an images. */
|
|
1391
1416
|
export declare interface GenerateImagesConfig {
|
|
1392
1417
|
/** Used to override HTTP request options. */
|
|
@@ -1468,6 +1493,74 @@ export declare class GenerateImagesResponse {
|
|
|
1468
1493
|
positivePromptSafetyAttributes?: SafetyAttributes;
|
|
1469
1494
|
}
|
|
1470
1495
|
|
|
1496
|
+
/** Configuration for generating videos. */
|
|
1497
|
+
export declare interface GenerateVideosConfig {
|
|
1498
|
+
/** Used to override HTTP request options. */
|
|
1499
|
+
httpOptions?: HttpOptions;
|
|
1500
|
+
/** Number of output videos. */
|
|
1501
|
+
numberOfVideos?: number;
|
|
1502
|
+
/** The gcs bucket where to save the generated videos. */
|
|
1503
|
+
outputGcsUri?: string;
|
|
1504
|
+
/** Frames per second for video generation. */
|
|
1505
|
+
fps?: number;
|
|
1506
|
+
/** Duration of the clip for video generation in seconds. */
|
|
1507
|
+
durationSeconds?: number;
|
|
1508
|
+
/** The RNG seed. If RNG seed is exactly same for each request with unchanged inputs, the prediction results will be consistent. Otherwise, a random RNG seed will be used each time to produce a different result. */
|
|
1509
|
+
seed?: number;
|
|
1510
|
+
/** The aspect ratio for the generated video. 16:9 (landscape) and 9:16 (portrait) are supported. */
|
|
1511
|
+
aspectRatio?: string;
|
|
1512
|
+
/** The resolution for the generated video. 1280x720, 1920x1080 are supported. */
|
|
1513
|
+
resolution?: string;
|
|
1514
|
+
/** Whether allow to generate person videos, and restrict to specific ages. Supported values are: dont_allow, allow_adult. */
|
|
1515
|
+
personGeneration?: string;
|
|
1516
|
+
/** The pubsub topic where to publish the video generation progress. */
|
|
1517
|
+
pubsubTopic?: string;
|
|
1518
|
+
/** Optional field in addition to the text content. Negative prompts can be explicitly stated here to help generate the video. */
|
|
1519
|
+
negativePrompt?: string;
|
|
1520
|
+
/** Whether to use the prompt rewriting logic. */
|
|
1521
|
+
enhancePrompt?: boolean;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/** A video generation operation. */
|
|
1525
|
+
export declare interface GenerateVideosOperation {
|
|
1526
|
+
/** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
|
|
1527
|
+
name?: string;
|
|
1528
|
+
/** Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */
|
|
1529
|
+
metadata?: Record<string, unknown>;
|
|
1530
|
+
/** If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */
|
|
1531
|
+
done?: boolean;
|
|
1532
|
+
/** The error result of the operation in case of failure or cancellation. */
|
|
1533
|
+
error?: Record<string, unknown>;
|
|
1534
|
+
/** The normal response of the operation in case of success. */
|
|
1535
|
+
response?: Record<string, unknown>;
|
|
1536
|
+
/** The generated videos. */
|
|
1537
|
+
result?: GenerateVideosResponse;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/** Class that represents the parameters for generating an image. */
|
|
1541
|
+
export declare interface GenerateVideosParameters {
|
|
1542
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
1543
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
1544
|
+
model: string;
|
|
1545
|
+
/** The text prompt for generating the videos. Optional for image to video use cases. */
|
|
1546
|
+
prompt?: string;
|
|
1547
|
+
/** The input image for generating the videos.
|
|
1548
|
+
Optional if prompt is provided. */
|
|
1549
|
+
image?: Image_2;
|
|
1550
|
+
/** Configuration for generating videos. */
|
|
1551
|
+
config?: GenerateVideosConfig;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/** Response with generated videos. */
|
|
1555
|
+
export declare class GenerateVideosResponse {
|
|
1556
|
+
/** List of the generated videos */
|
|
1557
|
+
generatedVideos?: GeneratedVideo[];
|
|
1558
|
+
/** Returns if any videos were filtered due to RAI policies. */
|
|
1559
|
+
raiMediaFilteredCount?: number;
|
|
1560
|
+
/** Returns rai failure reasons if any. */
|
|
1561
|
+
raiMediaFilteredReasons?: string[];
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1471
1564
|
/** Generation config. */
|
|
1472
1565
|
export declare interface GenerationConfig {
|
|
1473
1566
|
/** Optional. If enabled, audio timestamp will be included in the request to the model. */
|
|
@@ -1552,6 +1645,19 @@ export declare interface GetFileParameters {
|
|
|
1552
1645
|
config?: GetFileConfig;
|
|
1553
1646
|
}
|
|
1554
1647
|
|
|
1648
|
+
export declare interface GetOperationConfig {
|
|
1649
|
+
/** Used to override HTTP request options. */
|
|
1650
|
+
httpOptions?: HttpOptions;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/** Parameters for the GET method. */
|
|
1654
|
+
export declare interface GetOperationParameters {
|
|
1655
|
+
/** The server-assigned name for the operation. */
|
|
1656
|
+
operationName: string;
|
|
1657
|
+
/** Used to override the default configuration. */
|
|
1658
|
+
config?: GetOperationConfig;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1555
1661
|
declare function getValueByPath(data: unknown, keys: string[]): unknown;
|
|
1556
1662
|
|
|
1557
1663
|
/**
|
|
@@ -1600,6 +1706,7 @@ export declare class GoogleGenAI {
|
|
|
1600
1706
|
readonly chats: Chats;
|
|
1601
1707
|
readonly caches: Caches;
|
|
1602
1708
|
readonly files: Files;
|
|
1709
|
+
readonly operations: Operations;
|
|
1603
1710
|
constructor(options: GoogleGenAIOptions);
|
|
1604
1711
|
}
|
|
1605
1712
|
|
|
@@ -2246,6 +2353,15 @@ export declare enum MaskReferenceMode {
|
|
|
2246
2353
|
MASK_MODE_SEMANTIC = "MASK_MODE_SEMANTIC"
|
|
2247
2354
|
}
|
|
2248
2355
|
|
|
2356
|
+
export declare enum MediaModality {
|
|
2357
|
+
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2358
|
+
TEXT = "TEXT",
|
|
2359
|
+
IMAGE = "IMAGE",
|
|
2360
|
+
VIDEO = "VIDEO",
|
|
2361
|
+
AUDIO = "AUDIO",
|
|
2362
|
+
DOCUMENT = "DOCUMENT"
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2249
2365
|
export declare enum MediaResolution {
|
|
2250
2366
|
MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
|
|
2251
2367
|
MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
|
|
@@ -2263,7 +2379,7 @@ export declare enum Modality {
|
|
|
2263
2379
|
/** Represents token counting info for a single modality. */
|
|
2264
2380
|
export declare interface ModalityTokenCount {
|
|
2265
2381
|
/** The modality associated with this token count. */
|
|
2266
|
-
modality?:
|
|
2382
|
+
modality?: MediaModality;
|
|
2267
2383
|
/** Number of tokens. */
|
|
2268
2384
|
tokenCount?: number;
|
|
2269
2385
|
}
|
|
@@ -2459,6 +2575,52 @@ export declare class Models extends BaseModule {
|
|
|
2459
2575
|
* ```
|
|
2460
2576
|
*/
|
|
2461
2577
|
computeTokens(params: types.ComputeTokensParameters): Promise<types.ComputeTokensResponse>;
|
|
2578
|
+
/**
|
|
2579
|
+
* Generates videos based on a text description and configuration.
|
|
2580
|
+
*
|
|
2581
|
+
* @param params - The parameters for generating videos.
|
|
2582
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
2583
|
+
*
|
|
2584
|
+
* @example
|
|
2585
|
+
* ```ts
|
|
2586
|
+
* const operation = await ai.models.generateVideos({
|
|
2587
|
+
* model: 'veo-2.0-generate-001',
|
|
2588
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
2589
|
+
* config: {
|
|
2590
|
+
* numberOfVideos: 1
|
|
2591
|
+
* });
|
|
2592
|
+
*
|
|
2593
|
+
* while (!operation.done) {
|
|
2594
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
2595
|
+
* operation = await ai.operations.get({operation: operation});
|
|
2596
|
+
* }
|
|
2597
|
+
*
|
|
2598
|
+
* console.log(operation.result?.generatedVideos?.[0]?.video?.uri);
|
|
2599
|
+
* ```
|
|
2600
|
+
*/
|
|
2601
|
+
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
/** Parameters for the get method of the operations module. */
|
|
2605
|
+
export declare interface OperationGetParameters {
|
|
2606
|
+
/** The operation to be retrieved. */
|
|
2607
|
+
operation: GenerateVideosOperation;
|
|
2608
|
+
/** Used to override the default configuration. */
|
|
2609
|
+
config?: GetOperationConfig;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
export declare class Operations extends BaseModule {
|
|
2613
|
+
private readonly apiClient;
|
|
2614
|
+
constructor(apiClient: ApiClient);
|
|
2615
|
+
/**
|
|
2616
|
+
* Gets the status of a long-running operation.
|
|
2617
|
+
*
|
|
2618
|
+
* @param operation The Operation object returned by a previous API call.
|
|
2619
|
+
* @return The updated Operation object, with the latest status or result.
|
|
2620
|
+
*/
|
|
2621
|
+
get(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
|
|
2622
|
+
private getVideosOperationInternal;
|
|
2623
|
+
private fetchPredictVideosOperationInternal;
|
|
2462
2624
|
}
|
|
2463
2625
|
|
|
2464
2626
|
/**
|
|
@@ -2481,7 +2643,7 @@ export declare enum Outcome {
|
|
|
2481
2643
|
/**
|
|
2482
2644
|
* Pagers for the GenAI List APIs.
|
|
2483
2645
|
*/
|
|
2484
|
-
declare enum PagedItem {
|
|
2646
|
+
export declare enum PagedItem {
|
|
2485
2647
|
PAGED_ITEM_BATCH_JOBS = "batchJobs",
|
|
2486
2648
|
PAGED_ITEM_MODELS = "models",
|
|
2487
2649
|
PAGED_ITEM_TUNING_JOBS = "tuningJobs",
|
|
@@ -2508,7 +2670,7 @@ declare interface PagedItemResponse<T> {
|
|
|
2508
2670
|
/**
|
|
2509
2671
|
* Pager class for iterating through paginated results.
|
|
2510
2672
|
*/
|
|
2511
|
-
declare class Pager<T> implements AsyncIterable<T> {
|
|
2673
|
+
export declare class Pager<T> implements AsyncIterable<T> {
|
|
2512
2674
|
private nameInternal;
|
|
2513
2675
|
private pageInternal;
|
|
2514
2676
|
private paramsInternal;
|
|
@@ -3158,6 +3320,7 @@ declare namespace types {
|
|
|
3158
3320
|
MaskReferenceMode,
|
|
3159
3321
|
ControlReferenceType,
|
|
3160
3322
|
SubjectReferenceType,
|
|
3323
|
+
MediaModality,
|
|
3161
3324
|
VideoMetadata,
|
|
3162
3325
|
CodeExecutionResult,
|
|
3163
3326
|
ExecutableCode,
|
|
@@ -3231,6 +3394,12 @@ declare namespace types {
|
|
|
3231
3394
|
ComputeTokensParameters,
|
|
3232
3395
|
TokensInfo,
|
|
3233
3396
|
ComputeTokensResponse,
|
|
3397
|
+
GenerateVideosConfig,
|
|
3398
|
+
GenerateVideosParameters,
|
|
3399
|
+
Video,
|
|
3400
|
+
GeneratedVideo,
|
|
3401
|
+
GenerateVideosResponse,
|
|
3402
|
+
GenerateVideosOperation,
|
|
3234
3403
|
CreateCachedContentConfig,
|
|
3235
3404
|
CreateCachedContentParameters,
|
|
3236
3405
|
CachedContentUsageMetadata,
|
|
@@ -3260,6 +3429,10 @@ declare namespace types {
|
|
|
3260
3429
|
DeleteFileConfig,
|
|
3261
3430
|
DeleteFileParameters,
|
|
3262
3431
|
DeleteFileResponse,
|
|
3432
|
+
GetOperationConfig,
|
|
3433
|
+
GetOperationParameters,
|
|
3434
|
+
FetchPredictOperationConfig,
|
|
3435
|
+
FetchPredictOperationParameters,
|
|
3263
3436
|
TestTableItem,
|
|
3264
3437
|
TestTableFile,
|
|
3265
3438
|
ReplayRequest,
|
|
@@ -3296,6 +3469,7 @@ declare namespace types {
|
|
|
3296
3469
|
LiveSendClientContentParameters,
|
|
3297
3470
|
LiveSendRealtimeInputParameters,
|
|
3298
3471
|
LiveSendToolResponseParameters,
|
|
3472
|
+
OperationGetParameters,
|
|
3299
3473
|
PartUnion,
|
|
3300
3474
|
PartListUnion,
|
|
3301
3475
|
ContentUnion,
|
|
@@ -3310,9 +3484,9 @@ declare namespace types {
|
|
|
3310
3484
|
export declare interface UpdateCachedContentConfig {
|
|
3311
3485
|
/** Used to override HTTP request options. */
|
|
3312
3486
|
httpOptions?: HttpOptions;
|
|
3313
|
-
/** The TTL for this resource. The expiration time is computed: now + TTL. */
|
|
3487
|
+
/** The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s". */
|
|
3314
3488
|
ttl?: string;
|
|
3315
|
-
/** Timestamp of when this resource is considered expired. */
|
|
3489
|
+
/** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
|
|
3316
3490
|
expireTime?: string;
|
|
3317
3491
|
}
|
|
3318
3492
|
|
|
@@ -3427,6 +3601,16 @@ export declare interface VertexRagStoreRagResource {
|
|
|
3427
3601
|
ragFileIds?: string[];
|
|
3428
3602
|
}
|
|
3429
3603
|
|
|
3604
|
+
/** A generated video. */
|
|
3605
|
+
export declare interface Video {
|
|
3606
|
+
/** Path to another storage. */
|
|
3607
|
+
uri?: string;
|
|
3608
|
+
/** Video bytes. */
|
|
3609
|
+
videoBytes?: string;
|
|
3610
|
+
/** Video encoding, for example "video/mp4". */
|
|
3611
|
+
mimeType?: string;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3430
3614
|
/** Metadata describes the input video content. */
|
|
3431
3615
|
export declare interface VideoMetadata {
|
|
3432
3616
|
/** Optional. The end offset of the video. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/genai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"module": "dist/web/index.mjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepare": "npm run build-prod",
|
|
39
39
|
"build": "rollup -c && api-extractor run --local --verbose && api-extractor run -c api-extractor.node.json --local --verbose&& api-extractor run -c api-extractor.web.json --local --verbose",
|
|
40
40
|
"build-prod": "rollup -c && api-extractor run --verbose && api-extractor run -c api-extractor.node.json --verbose && api-extractor run -c api-extractor.web.json --verbose",
|
|
41
|
-
"unit-test": "ts-node node_modules/jasmine/bin/jasmine test/unit
|
|
41
|
+
"unit-test": "ts-node node_modules/jasmine/bin/jasmine test/unit/**/*_test.ts test/unit/*_test.ts",
|
|
42
42
|
"system-test": "ts-node node_modules/jasmine/bin/jasmine test/system/**/*_test.ts",
|
|
43
43
|
"docs": "typedoc && ts-node scripts/add_docsite_license_headers.ts",
|
|
44
44
|
"format": "prettier '**/*.ts' '**/*.mjs' '**/*.json' --write",
|