Skip to content

Commit 0fa1f05

Browse files
IvanLHcopybara-github
authored andcommitted
feat: Add experimental generate_video support
PiperOrigin-RevId: 741253145
1 parent 61f4f9b commit 0fa1f05

File tree

8 files changed

+84
-0
lines changed

8 files changed

+84
-0
lines changed

api-report/genai-node.api.md

+10
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,10 @@ export class GoogleGenAI {
734734
readonly live: Live;
735735
// (undocumented)
736736
readonly models: Models;
737+
// Warning: (ae-forgotten-export) The symbol "Operations" needs to be exported by the entry point index.d.ts
738+
//
739+
// (undocumented)
740+
readonly operations: Operations;
737741
// (undocumented)
738742
readonly vertexai: boolean;
739743
}
@@ -1185,6 +1189,12 @@ export class Models extends BaseModule {
11851189
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
11861190
}
11871191

1192+
// @public
1193+
export interface OperationGetParameters {
1194+
config?: GetOperationConfig;
1195+
operation: GenerateVideosOperation;
1196+
}
1197+
11881198
// @public
11891199
export enum Outcome {
11901200
// (undocumented)

api-report/genai-web.api.md

+10
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,10 @@ export class GoogleGenAI {
734734
readonly live: Live;
735735
// (undocumented)
736736
readonly models: Models;
737+
// Warning: (ae-forgotten-export) The symbol "Operations" needs to be exported by the entry point index.d.ts
738+
//
739+
// (undocumented)
740+
readonly operations: Operations;
737741
// (undocumented)
738742
readonly vertexai: boolean;
739743
}
@@ -1185,6 +1189,12 @@ export class Models extends BaseModule {
11851189
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
11861190
}
11871191

1192+
// @public
1193+
export interface OperationGetParameters {
1194+
config?: GetOperationConfig;
1195+
operation: GenerateVideosOperation;
1196+
}
1197+
11881198
// @public
11891199
export enum Outcome {
11901200
// (undocumented)

api-report/genai.api.md

+10
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,10 @@ export class GoogleGenAI {
734734
readonly live: Live;
735735
// (undocumented)
736736
readonly models: Models;
737+
// Warning: (ae-forgotten-export) The symbol "Operations" needs to be exported by the entry point index.d.ts
738+
//
739+
// (undocumented)
740+
readonly operations: Operations;
737741
// (undocumented)
738742
readonly vertexai: boolean;
739743
}
@@ -1185,6 +1189,12 @@ export class Models extends BaseModule {
11851189
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
11861190
}
11871191

1192+
// @public
1193+
export interface OperationGetParameters {
1194+
config?: GetOperationConfig;
1195+
operation: GenerateVideosOperation;
1196+
}
1197+
11881198
// @public
11891199
export enum Outcome {
11901200
// (undocumented)

src/client.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {CrossWebSocketFactory} from './cross/_cross_websocket';
1515
import {Files} from './files';
1616
import {Live} from './live';
1717
import {Models} from './models';
18+
import {Operations} from './operations';
1819
import {HttpOptions} from './types';
1920
import {WebAuth} from './web/_web_auth';
2021

@@ -122,6 +123,7 @@ export class GoogleGenAI {
122123
readonly chats: Chats;
123124
readonly caches: Caches;
124125
readonly files: Files;
126+
readonly operations: Operations;
125127

126128
constructor(options: GoogleGenAIOptions) {
127129
if (options.apiKey == null) {
@@ -147,5 +149,6 @@ export class GoogleGenAI {
147149
this.chats = new Chats(this.models, this.apiClient);
148150
this.caches = new Caches(this.apiClient);
149151
this.files = new Files(this.apiClient);
152+
this.operations = new Operations(this.apiClient);
150153
}
151154
}

src/node/node_client.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {Live} from '../live';
1515
import {Models} from '../models';
1616
import {NodeAuth} from '../node/_node_auth';
1717
import {NodeWebSocketFactory} from '../node/_node_websocket';
18+
import {Operations} from '../operations';
1819

1920
import {NodeUploader} from './_node_uploader';
2021

@@ -73,6 +74,7 @@ export class GoogleGenAI {
7374
readonly chats: Chats;
7475
readonly caches: Caches;
7576
readonly files: Files;
77+
readonly operations: Operations;
7678

7779
constructor(options: GoogleGenAIOptions) {
7880
// Validate explicitly set initializer values.
@@ -141,6 +143,7 @@ export class GoogleGenAI {
141143
this.chats = new Chats(this.models, this.apiClient);
142144
this.caches = new Caches(this.apiClient);
143145
this.files = new Files(this.apiClient);
146+
this.operations = new Operations(this.apiClient);
144147
}
145148
}
146149

src/operations.ts

+37
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,43 @@ export class Operations extends BaseModule {
1717
super();
1818
}
1919

20+
/**
21+
* Gets the status of a long-running operation.
22+
*
23+
* @param operation The Operation object returned by a previous API call.
24+
* @return The updated Operation object, with the latest status or result.
25+
*/
26+
async get(
27+
parameters: types.OperationGetParameters,
28+
): Promise<types.GenerateVideosOperation> {
29+
const operation = parameters.operation;
30+
const config = parameters.config;
31+
32+
if (operation.name === undefined || operation.name === '') {
33+
throw new Error('Operation name is required.');
34+
}
35+
36+
if (this.apiClient.isVertexAI()) {
37+
const resourceName = operation.name.split('/operations/')[0];
38+
var httpOptions: types.HttpOptions | undefined = undefined;
39+
40+
if (config && 'httpOptions' in config) {
41+
httpOptions = config.httpOptions;
42+
}
43+
44+
return this.fetchPredictVideosOperationInternal({
45+
operationName: operation.name,
46+
resourceName: resourceName,
47+
config: {httpOptions: httpOptions},
48+
});
49+
} else {
50+
return this.getVideosOperationInternal({
51+
operationName: operation.name,
52+
config: config,
53+
});
54+
}
55+
}
56+
2057
private async getVideosOperationInternal(
2158
params: types.GetOperationParameters,
2259
): Promise<types.GenerateVideosOperation> {

src/types.ts

+8
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,14 @@ export class LiveSendToolResponseParameters {
24582458
functionResponses: FunctionResponse[] | FunctionResponse = [];
24592459
}
24602460

2461+
/** Parameters for the get method of the operations module. */
2462+
export declare interface OperationGetParameters {
2463+
/** The operation to be retrieved. */
2464+
operation: GenerateVideosOperation;
2465+
/** Used to override the default configuration. */
2466+
config?: GetOperationConfig;
2467+
}
2468+
24612469
export type PartUnion = Part | string;
24622470

24632471
export type PartListUnion = PartUnion[] | PartUnion;

src/web/web_client.ts

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {GoogleGenAIOptions} from '../client';
1111
import {Files} from '../files';
1212
import {Live} from '../live';
1313
import {Models} from '../models';
14+
import {Operations} from '../operations';
1415

1516
import {BrowserUploader} from './_browser_uploader';
1617
import {BrowserWebSocketFactory} from './_browser_websocket';
@@ -64,6 +65,7 @@ export class GoogleGenAI {
6465
readonly chats: Chats;
6566
readonly caches: Caches;
6667
readonly files: Files;
68+
readonly operations: Operations;
6769

6870
constructor(options: GoogleGenAIOptions) {
6971
if (options.apiKey == null) {
@@ -94,5 +96,6 @@ export class GoogleGenAI {
9496
this.chats = new Chats(this.models, this.apiClient);
9597
this.caches = new Caches(this.apiClient);
9698
this.files = new Files(this.apiClient);
99+
this.operations = new Operations(this.apiClient);
97100
}
98101
}

0 commit comments

Comments
 (0)