@aigne/gemini 0.14.16 → 1.74.0-beta

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.
Files changed (58) hide show
  1. package/README.md +11 -11
  2. package/dist/gemini-chat-model.cjs +435 -0
  3. package/dist/gemini-chat-model.d.cts +123 -0
  4. package/dist/gemini-chat-model.d.cts.map +1 -0
  5. package/dist/gemini-chat-model.d.mts +123 -0
  6. package/dist/gemini-chat-model.d.mts.map +1 -0
  7. package/dist/gemini-chat-model.mjs +436 -0
  8. package/dist/gemini-chat-model.mjs.map +1 -0
  9. package/dist/gemini-image-model.cjs +169 -0
  10. package/dist/gemini-image-model.d.cts +37 -0
  11. package/dist/gemini-image-model.d.cts.map +1 -0
  12. package/dist/gemini-image-model.d.mts +37 -0
  13. package/dist/gemini-image-model.d.mts.map +1 -0
  14. package/dist/gemini-image-model.mjs +170 -0
  15. package/dist/gemini-image-model.mjs.map +1 -0
  16. package/dist/gemini-video-model.cjs +148 -0
  17. package/dist/gemini-video-model.d.cts +117 -0
  18. package/dist/gemini-video-model.d.cts.map +1 -0
  19. package/dist/gemini-video-model.d.mts +117 -0
  20. package/dist/gemini-video-model.d.mts.map +1 -0
  21. package/dist/gemini-video-model.mjs +149 -0
  22. package/dist/gemini-video-model.mjs.map +1 -0
  23. package/dist/index.cjs +7 -0
  24. package/dist/index.d.cts +4 -0
  25. package/dist/index.d.mts +4 -0
  26. package/dist/index.mjs +5 -0
  27. package/dist/utils.cjs +34 -0
  28. package/dist/utils.mjs +35 -0
  29. package/dist/utils.mjs.map +1 -0
  30. package/package.json +29 -30
  31. package/CHANGELOG.md +0 -2672
  32. package/lib/cjs/gemini-chat-model.d.ts +0 -117
  33. package/lib/cjs/gemini-chat-model.js +0 -564
  34. package/lib/cjs/gemini-image-model.d.ts +0 -34
  35. package/lib/cjs/gemini-image-model.js +0 -171
  36. package/lib/cjs/gemini-video-model.d.ts +0 -114
  37. package/lib/cjs/gemini-video-model.js +0 -164
  38. package/lib/cjs/index.d.ts +0 -3
  39. package/lib/cjs/index.js +0 -19
  40. package/lib/cjs/package.json +0 -3
  41. package/lib/cjs/utils.d.ts +0 -15
  42. package/lib/cjs/utils.js +0 -37
  43. package/lib/dts/gemini-chat-model.d.ts +0 -117
  44. package/lib/dts/gemini-image-model.d.ts +0 -34
  45. package/lib/dts/gemini-video-model.d.ts +0 -114
  46. package/lib/dts/index.d.ts +0 -3
  47. package/lib/dts/utils.d.ts +0 -15
  48. package/lib/esm/gemini-chat-model.d.ts +0 -117
  49. package/lib/esm/gemini-chat-model.js +0 -560
  50. package/lib/esm/gemini-image-model.d.ts +0 -34
  51. package/lib/esm/gemini-image-model.js +0 -167
  52. package/lib/esm/gemini-video-model.d.ts +0 -114
  53. package/lib/esm/gemini-video-model.js +0 -160
  54. package/lib/esm/index.d.ts +0 -3
  55. package/lib/esm/index.js +0 -3
  56. package/lib/esm/package.json +0 -3
  57. package/lib/esm/utils.d.ts +0 -15
  58. package/lib/esm/utils.js +0 -34
@@ -0,0 +1,117 @@
1
+ import { AgentInvokeOptions, FileUnionContent, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/core";
2
+ import { GoogleGenAI } from "@google/genai";
3
+
4
+ //#region src/gemini-video-model.d.ts
5
+ /**
6
+ * Input options for Gemini Video Model
7
+ */
8
+ interface GeminiVideoModelInput extends VideoModelInput {
9
+ /**
10
+ * Text describing content that should not appear in the video
11
+ */
12
+ negativePrompt?: string;
13
+ /**
14
+ * Aspect ratio of the video
15
+ *
16
+ * Veo 3.1: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
17
+ * Veo 3: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
18
+ */
19
+ aspectRatio?: "16:9" | "9:16";
20
+ /**
21
+ * Resolution of the video
22
+ *
23
+ * Veo 3.1: "720p" (default), "1080p" (only supports 8 seconds duration)
24
+ * Veo 3: "720p" (default), "1080p" (16:9 only)
25
+ */
26
+ size?: "720p" | "1080p";
27
+ /**
28
+ * Duration of the generated video in seconds
29
+ *
30
+ * Veo 3.1: "4", "6", "8"
31
+ * Veo 3: "4", "6", "8"
32
+ */
33
+ seconds?: "4" | "6" | "8";
34
+ /**
35
+ * Control person generation
36
+ *
37
+ * For text-to-video and image-to-video:
38
+ * - Veo 3.1: "allow_all" for image-to-video, frame interpolation and reference images; only "allow_adult" for text-to-video
39
+ * - Veo 3: "allow_all" for image-to-video; only "allow_adult" for text-to-video
40
+ * - Veo 2: "allow_all", "allow_adult", "dont_allow"
41
+ */
42
+ personGeneration?: string;
43
+ /**
44
+ * Last frame for video generation (frame interpolation)
45
+ */
46
+ lastFrame?: FileUnionContent;
47
+ /**
48
+ * Reference images for video generation
49
+ * Only supported in Veo 3.1 models
50
+ */
51
+ referenceImages?: FileUnionContent[];
52
+ }
53
+ /**
54
+ * Output from Gemini Video Model
55
+ */
56
+ interface GeminiVideoModelOutput extends VideoModelOutput {}
57
+ /**
58
+ * Configuration options for Gemini Video Model
59
+ */
60
+ interface GeminiVideoModelOptions extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {
61
+ /**
62
+ * API key for Gemini API
63
+ *
64
+ * If not provided, will look for GEMINI_API_KEY in environment variables
65
+ */
66
+ apiKey?: string;
67
+ /**
68
+ * Base URL for Gemini API
69
+ *
70
+ * Useful for proxies or alternate endpoints
71
+ */
72
+ baseURL?: string;
73
+ /**
74
+ * Gemini model to use
75
+ *
76
+ * Defaults to 'veo-3.1-generate-preview'
77
+ */
78
+ model?: string;
79
+ /**
80
+ * Additional model options to control behavior
81
+ */
82
+ modelOptions?: Omit<Partial<GeminiVideoModelInput>, "model">;
83
+ /**
84
+ * Client options for Gemini API
85
+ */
86
+ clientOptions?: Record<string, any>;
87
+ /**
88
+ * Polling interval in milliseconds for checking video generation status
89
+ *
90
+ * Defaults to 10000ms (10 seconds)
91
+ */
92
+ pollingInterval?: number;
93
+ }
94
+ declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {
95
+ options?: GeminiVideoModelOptions | undefined;
96
+ constructor(options?: GeminiVideoModelOptions | undefined);
97
+ /**
98
+ * @hidden
99
+ */
100
+ protected _client?: GoogleGenAI;
101
+ protected apiKeyEnvName: string;
102
+ get client(): GoogleGenAI;
103
+ get credential(): {
104
+ url: string | undefined;
105
+ apiKey: string | undefined;
106
+ model: string;
107
+ };
108
+ get modelOptions(): Omit<Partial<GeminiVideoModelInput>, "model"> | undefined;
109
+ downloadToFile(dir: string, videoId: string, videoFile: {
110
+ uri?: string;
111
+ videoBytes?: any;
112
+ }): Promise<string>;
113
+ process(input: GeminiVideoModelInput, options: AgentInvokeOptions): Promise<GeminiVideoModelOutput>;
114
+ }
115
+ //#endregion
116
+ export { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
117
+ //# sourceMappingURL=gemini-video-model.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini-video-model.d.cts","names":[],"sources":["../src/gemini-video-model.ts"],"mappings":";;;;;AAqBA;;UAAiB,qBAAA,SAA8B,eAAA;EAAA;;AAuD/C;EAvD+C,cAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,WAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,IAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,OAAA;EAAA;;AAuD/C;AAKA;;;;;EA5D+C,gBAAA;EAAA;;AAuD/C;EAvD+C,SAAA,GA2CjC,gBAAA;EAAA;;;;EAAA,eAAA,GAMM,gBAAA;AAAA;AAAA;;;AAAA,UAMH,sBAAA,SAA+B,gBAAA;AAAA;AAKhD;;AALgD,UAK/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EAAA;;;;;EAAA,MAAA;EAAA;;;;;EAAA,OAAA;EAAA;;;;;EAAA,KAAA;EAAA;;;EAAA,YAAA,GAyBlC,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAAA;;;EAAA,aAAA,GAKZ,MAAA;EAAA;;;AA6BlB;;EA7BkB,eAAA;AAAA;AAAA,cA6BL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAAA,OAAA,GAChC,uBAAA;EAAA,YAAA,OAAA,GAAA,uBAAA;EAAA;;;EAAA,UAAA,OAAA,GAalB,WAAA;EAAA,UAAA,aAAA;EAAA,IAAA,OAAA,GAIV,WAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAmBM,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,eAAA,GAAA,UAAA,OAAA,UAAA,SAAA;IAAA,GAAA;IAAA,UAAA;EAAA,IAQb,OAAA;EAAA,QAAA,KAAA,EAaM,qBAAA,EAAA,OAAA,EACE,kBAAA,GACR,OAAA,CAAQ,sBAAA;AAAA"}
@@ -0,0 +1,117 @@
1
+ import { AgentInvokeOptions, FileUnionContent, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/core";
2
+ import { GoogleGenAI } from "@google/genai";
3
+
4
+ //#region src/gemini-video-model.d.ts
5
+ /**
6
+ * Input options for Gemini Video Model
7
+ */
8
+ interface GeminiVideoModelInput extends VideoModelInput {
9
+ /**
10
+ * Text describing content that should not appear in the video
11
+ */
12
+ negativePrompt?: string;
13
+ /**
14
+ * Aspect ratio of the video
15
+ *
16
+ * Veo 3.1: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
17
+ * Veo 3: "16:9" (default, 720p and 1080p), "9:16" (720p and 1080p)
18
+ */
19
+ aspectRatio?: "16:9" | "9:16";
20
+ /**
21
+ * Resolution of the video
22
+ *
23
+ * Veo 3.1: "720p" (default), "1080p" (only supports 8 seconds duration)
24
+ * Veo 3: "720p" (default), "1080p" (16:9 only)
25
+ */
26
+ size?: "720p" | "1080p";
27
+ /**
28
+ * Duration of the generated video in seconds
29
+ *
30
+ * Veo 3.1: "4", "6", "8"
31
+ * Veo 3: "4", "6", "8"
32
+ */
33
+ seconds?: "4" | "6" | "8";
34
+ /**
35
+ * Control person generation
36
+ *
37
+ * For text-to-video and image-to-video:
38
+ * - Veo 3.1: "allow_all" for image-to-video, frame interpolation and reference images; only "allow_adult" for text-to-video
39
+ * - Veo 3: "allow_all" for image-to-video; only "allow_adult" for text-to-video
40
+ * - Veo 2: "allow_all", "allow_adult", "dont_allow"
41
+ */
42
+ personGeneration?: string;
43
+ /**
44
+ * Last frame for video generation (frame interpolation)
45
+ */
46
+ lastFrame?: FileUnionContent;
47
+ /**
48
+ * Reference images for video generation
49
+ * Only supported in Veo 3.1 models
50
+ */
51
+ referenceImages?: FileUnionContent[];
52
+ }
53
+ /**
54
+ * Output from Gemini Video Model
55
+ */
56
+ interface GeminiVideoModelOutput extends VideoModelOutput {}
57
+ /**
58
+ * Configuration options for Gemini Video Model
59
+ */
60
+ interface GeminiVideoModelOptions extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {
61
+ /**
62
+ * API key for Gemini API
63
+ *
64
+ * If not provided, will look for GEMINI_API_KEY in environment variables
65
+ */
66
+ apiKey?: string;
67
+ /**
68
+ * Base URL for Gemini API
69
+ *
70
+ * Useful for proxies or alternate endpoints
71
+ */
72
+ baseURL?: string;
73
+ /**
74
+ * Gemini model to use
75
+ *
76
+ * Defaults to 'veo-3.1-generate-preview'
77
+ */
78
+ model?: string;
79
+ /**
80
+ * Additional model options to control behavior
81
+ */
82
+ modelOptions?: Omit<Partial<GeminiVideoModelInput>, "model">;
83
+ /**
84
+ * Client options for Gemini API
85
+ */
86
+ clientOptions?: Record<string, any>;
87
+ /**
88
+ * Polling interval in milliseconds for checking video generation status
89
+ *
90
+ * Defaults to 10000ms (10 seconds)
91
+ */
92
+ pollingInterval?: number;
93
+ }
94
+ declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {
95
+ options?: GeminiVideoModelOptions | undefined;
96
+ constructor(options?: GeminiVideoModelOptions | undefined);
97
+ /**
98
+ * @hidden
99
+ */
100
+ protected _client?: GoogleGenAI;
101
+ protected apiKeyEnvName: string;
102
+ get client(): GoogleGenAI;
103
+ get credential(): {
104
+ url: string | undefined;
105
+ apiKey: string | undefined;
106
+ model: string;
107
+ };
108
+ get modelOptions(): Omit<Partial<GeminiVideoModelInput>, "model"> | undefined;
109
+ downloadToFile(dir: string, videoId: string, videoFile: {
110
+ uri?: string;
111
+ videoBytes?: any;
112
+ }): Promise<string>;
113
+ process(input: GeminiVideoModelInput, options: AgentInvokeOptions): Promise<GeminiVideoModelOutput>;
114
+ }
115
+ //#endregion
116
+ export { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
117
+ //# sourceMappingURL=gemini-video-model.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini-video-model.d.mts","names":[],"sources":["../src/gemini-video-model.ts"],"mappings":";;;;;AAqBA;;UAAiB,qBAAA,SAA8B,eAAA;EAAA;;AAuD/C;EAvD+C,cAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,WAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,IAAA;EAAA;;AAuD/C;AAKA;;;EA5D+C,OAAA;EAAA;;AAuD/C;AAKA;;;;;EA5D+C,gBAAA;EAAA;;AAuD/C;EAvD+C,SAAA,GA2CjC,gBAAA;EAAA;;;;EAAA,eAAA,GAMM,gBAAA;AAAA;AAAA;;;AAAA,UAMH,sBAAA,SAA+B,gBAAA;AAAA;AAKhD;;AALgD,UAK/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EAAA;;;;;EAAA,MAAA;EAAA;;;;;EAAA,OAAA;EAAA;;;;;EAAA,KAAA;EAAA;;;EAAA,YAAA,GAyBlC,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAAA;;;EAAA,aAAA,GAKZ,MAAA;EAAA;;;AA6BlB;;EA7BkB,eAAA;AAAA;AAAA,cA6BL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAAA,OAAA,GAChC,uBAAA;EAAA,YAAA,OAAA,GAAA,uBAAA;EAAA;;;EAAA,UAAA,OAAA,GAalB,WAAA;EAAA,UAAA,aAAA;EAAA,IAAA,OAAA,GAIV,WAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAmBM,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,eAAA,GAAA,UAAA,OAAA,UAAA,SAAA;IAAA,GAAA;IAAA,UAAA;EAAA,IAQb,OAAA;EAAA,QAAA,KAAA,EAaM,qBAAA,EAAA,OAAA,EACE,kBAAA,GACR,OAAA,CAAQ,sBAAA;AAAA"}
@@ -0,0 +1,149 @@
1
+ import { waitFileSizeStable } from "./utils.mjs";
2
+ import { VideoModel, fileUnionContentSchema, videoModelInputSchema } from "@aigne/core";
3
+ import { logger } from "@aigne/core/utils/logger";
4
+ import { checkArguments } from "@aigne/core/utils/type-utils";
5
+ import { nodejs } from "@aigne/utils/nodejs";
6
+ import { GoogleGenAI } from "@google/genai";
7
+ import { z } from "zod";
8
+
9
+ //#region src/gemini-video-model.ts
10
+ const DEFAULT_MODEL = "veo-3.1-generate-preview";
11
+ const DEFAULT_SECONDS = 8;
12
+ const geminiVideoModelInputSchema = videoModelInputSchema.extend({
13
+ negativePrompt: z.string().optional(),
14
+ aspectRatio: z.enum(["16:9", "9:16"]).optional(),
15
+ size: z.enum(["720p", "1080p"]).optional(),
16
+ seconds: z.enum([
17
+ "4",
18
+ "6",
19
+ "8"
20
+ ]).optional(),
21
+ personGeneration: z.string().optional(),
22
+ lastFrame: fileUnionContentSchema.optional(),
23
+ referenceImages: fileUnionContentSchema.array().optional()
24
+ });
25
+ const geminiVideoModelOptionsSchema = z.object({
26
+ apiKey: z.string().optional(),
27
+ baseURL: z.string().optional(),
28
+ model: z.string().optional(),
29
+ modelOptions: z.object({}).optional(),
30
+ clientOptions: z.object({}).optional(),
31
+ pollingInterval: z.number().optional()
32
+ });
33
+ var GeminiVideoModel = class extends VideoModel {
34
+ constructor(options) {
35
+ super({
36
+ ...options,
37
+ description: options?.description ?? "Generate videos using Google Gemini Veo models",
38
+ inputSchema: geminiVideoModelInputSchema
39
+ });
40
+ this.options = options;
41
+ if (options) checkArguments(this.name, geminiVideoModelOptionsSchema, options);
42
+ }
43
+ /**
44
+ * @hidden
45
+ */
46
+ _client;
47
+ apiKeyEnvName = "GEMINI_API_KEY";
48
+ get client() {
49
+ const { apiKey } = this.credential;
50
+ if (!apiKey) throw new Error(`${this.name} requires an API key. Please provide it via \`options.apiKey\`, or set the \`${this.apiKeyEnvName}\` environment variable`);
51
+ this._client ??= new GoogleGenAI({
52
+ apiKey,
53
+ ...this.options?.clientOptions
54
+ });
55
+ return this._client;
56
+ }
57
+ get credential() {
58
+ return {
59
+ url: this.options?.baseURL || process.env.GEMINI_BASE_URL,
60
+ apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],
61
+ model: this.options?.model || DEFAULT_MODEL
62
+ };
63
+ }
64
+ get modelOptions() {
65
+ return this.options?.modelOptions;
66
+ }
67
+ async downloadToFile(dir, videoId, videoFile) {
68
+ logger.debug("Downloading video content...");
69
+ const localPath = nodejs.path.join(dir, `${videoId}.mp4`);
70
+ await this.client.files.download({
71
+ file: videoFile,
72
+ downloadPath: localPath
73
+ });
74
+ logger.debug(`Generated video saved to ${localPath}`);
75
+ await waitFileSizeStable(localPath);
76
+ return (await nodejs.fs.readFile(localPath)).toString("base64");
77
+ }
78
+ async process(input, options) {
79
+ const model = input.model ?? input.modelOptions?.model ?? this.credential.model;
80
+ const mergedInput = {
81
+ ...this.modelOptions,
82
+ ...input
83
+ };
84
+ if (mergedInput.referenceImages && !model.includes("veo-3.1")) throw new Error("referenceImages is only supported in Veo 3.1 models");
85
+ const config = {};
86
+ if (mergedInput.negativePrompt) config.negativePrompt = mergedInput.negativePrompt;
87
+ if (mergedInput.aspectRatio) config.aspectRatio = mergedInput.aspectRatio;
88
+ if (mergedInput.size) config.resolution = mergedInput.size;
89
+ if (mergedInput.seconds) config.durationSeconds = parseInt(mergedInput.seconds, 10);
90
+ if (mergedInput.personGeneration) config.personGeneration = mergedInput.personGeneration;
91
+ if (mergedInput.lastFrame) config.lastFrame = await this.transformFileType("file", mergedInput.lastFrame).then((file) => {
92
+ return {
93
+ imageBytes: file.data,
94
+ mimeType: file.mimeType
95
+ };
96
+ });
97
+ if (mergedInput.referenceImages) config.referenceImages = await Promise.all(mergedInput.referenceImages.map(async (image) => {
98
+ return await this.transformFileType("file", image).then((file) => {
99
+ return { image: {
100
+ imageBytes: file.data,
101
+ mimeType: file.mimeType
102
+ } };
103
+ });
104
+ }));
105
+ const params = {
106
+ model,
107
+ prompt: mergedInput.prompt,
108
+ config
109
+ };
110
+ if (mergedInput.image) params.image = await this.transformFileType("file", mergedInput.image).then((file) => {
111
+ return {
112
+ imageBytes: file.data,
113
+ mimeType: file.mimeType
114
+ };
115
+ });
116
+ let operation = await this.client.models.generateVideos(params);
117
+ logger.debug("Video generation started...");
118
+ const pollingInterval = this.options?.pollingInterval ?? 1e4;
119
+ while (!operation.done) {
120
+ logger.debug("Waiting for video generation to complete...");
121
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
122
+ operation = await this.client.operations.getVideosOperation({ operation });
123
+ }
124
+ if (!operation.response?.generatedVideos?.[0]?.video) throw new Error("Video generation failed: No video generated");
125
+ const videoFile = operation.response.generatedVideos[0].video;
126
+ if (!videoFile) throw new Error("Video generation failed: No video file returned");
127
+ const dir = nodejs.path.join(nodejs.os.tmpdir(), options?.context?.id || "");
128
+ await nodejs.fs.mkdir(dir, { recursive: true });
129
+ const videoId = Date.now().toString();
130
+ return {
131
+ videos: [{
132
+ type: "file",
133
+ data: await this.downloadToFile(dir, videoId, videoFile),
134
+ mimeType: "video/mp4",
135
+ filename: `${videoId}.mp4`
136
+ }],
137
+ usage: {
138
+ inputTokens: 0,
139
+ outputTokens: 0
140
+ },
141
+ model,
142
+ seconds: mergedInput.seconds ? parseInt(mergedInput.seconds, 10) : DEFAULT_SECONDS
143
+ };
144
+ }
145
+ };
146
+
147
+ //#endregion
148
+ export { GeminiVideoModel };
149
+ //# sourceMappingURL=gemini-video-model.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini-video-model.mjs","names":[],"sources":["../src/gemini-video-model.ts"],"sourcesContent":["import type {\n AgentInvokeOptions,\n FileUnionContent,\n VideoModelInput,\n VideoModelOptions,\n VideoModelOutput,\n} from \"@aigne/core\";\nimport { fileUnionContentSchema, VideoModel, videoModelInputSchema } from \"@aigne/core\";\nimport { logger } from \"@aigne/core/utils/logger\";\nimport { checkArguments } from \"@aigne/core/utils/type-utils\";\nimport { nodejs } from \"@aigne/utils/nodejs\";\nimport { type GenerateVideosParameters, GoogleGenAI } from \"@google/genai\";\nimport { type ZodType, z } from \"zod\";\nimport { waitFileSizeStable } from \"./utils.js\";\n\nconst DEFAULT_MODEL = \"veo-3.1-generate-preview\";\nconst DEFAULT_SECONDS = 8;\n\n/**\n * Input options for Gemini Video Model\n */\nexport interface GeminiVideoModelInput extends VideoModelInput {\n /**\n * Text describing content that should not appear in the video\n */\n negativePrompt?: string;\n\n /**\n * Aspect ratio of the video\n *\n * Veo 3.1: \"16:9\" (default, 720p and 1080p), \"9:16\" (720p and 1080p)\n * Veo 3: \"16:9\" (default, 720p and 1080p), \"9:16\" (720p and 1080p)\n */\n aspectRatio?: \"16:9\" | \"9:16\";\n\n /**\n * Resolution of the video\n *\n * Veo 3.1: \"720p\" (default), \"1080p\" (only supports 8 seconds duration)\n * Veo 3: \"720p\" (default), \"1080p\" (16:9 only)\n */\n size?: \"720p\" | \"1080p\";\n\n /**\n * Duration of the generated video in seconds\n *\n * Veo 3.1: \"4\", \"6\", \"8\"\n * Veo 3: \"4\", \"6\", \"8\"\n */\n seconds?: \"4\" | \"6\" | \"8\";\n\n /**\n * Control person generation\n *\n * For text-to-video and image-to-video:\n * - Veo 3.1: \"allow_all\" for image-to-video, frame interpolation and reference images; only \"allow_adult\" for text-to-video\n * - Veo 3: \"allow_all\" for image-to-video; only \"allow_adult\" for text-to-video\n * - Veo 2: \"allow_all\", \"allow_adult\", \"dont_allow\"\n */\n personGeneration?: string;\n\n /**\n * Last frame for video generation (frame interpolation)\n */\n lastFrame?: FileUnionContent;\n\n /**\n * Reference images for video generation\n * Only supported in Veo 3.1 models\n */\n referenceImages?: FileUnionContent[];\n}\n\n/**\n * Output from Gemini Video Model\n */\nexport interface GeminiVideoModelOutput extends VideoModelOutput {}\n\n/**\n * Configuration options for Gemini Video Model\n */\nexport interface GeminiVideoModelOptions\n extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {\n /**\n * API key for Gemini API\n *\n * If not provided, will look for GEMINI_API_KEY in environment variables\n */\n apiKey?: string;\n\n /**\n * Base URL for Gemini API\n *\n * Useful for proxies or alternate endpoints\n */\n baseURL?: string;\n\n /**\n * Gemini model to use\n *\n * Defaults to 'veo-3.1-generate-preview'\n */\n model?: string;\n\n /**\n * Additional model options to control behavior\n */\n modelOptions?: Omit<Partial<GeminiVideoModelInput>, \"model\">;\n\n /**\n * Client options for Gemini API\n */\n clientOptions?: Record<string, any>;\n\n /**\n * Polling interval in milliseconds for checking video generation status\n *\n * Defaults to 10000ms (10 seconds)\n */\n pollingInterval?: number;\n}\n\nconst geminiVideoModelInputSchema: ZodType<GeminiVideoModelInput> = videoModelInputSchema.extend({\n negativePrompt: z.string().optional(),\n aspectRatio: z.enum([\"16:9\", \"9:16\"]).optional(),\n size: z.enum([\"720p\", \"1080p\"]).optional(),\n seconds: z.enum([\"4\", \"6\", \"8\"]).optional(),\n personGeneration: z.string().optional(),\n lastFrame: fileUnionContentSchema.optional(),\n referenceImages: fileUnionContentSchema.array().optional(),\n});\n\nconst geminiVideoModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n pollingInterval: z.number().optional(),\n});\n\nexport class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {\n constructor(public override options?: GeminiVideoModelOptions) {\n super({\n ...options,\n description: options?.description ?? \"Generate videos using Google Gemini Veo models\",\n inputSchema: geminiVideoModelInputSchema,\n });\n\n if (options) checkArguments(this.name, geminiVideoModelOptionsSchema, options);\n }\n\n /**\n * @hidden\n */\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n const { apiKey } = this.credential;\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n this._client ??= new GoogleGenAI({ apiKey, ...this.options?.clientOptions });\n return this._client;\n }\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.GEMINI_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DEFAULT_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n async downloadToFile(\n dir: string,\n videoId: string,\n videoFile: { uri?: string; videoBytes?: any },\n ): Promise<string> {\n logger.debug(\"Downloading video content...\");\n const localPath = nodejs.path.join(dir, `${videoId}.mp4`);\n await this.client.files.download({ file: videoFile, downloadPath: localPath });\n logger.debug(`Generated video saved to ${localPath}`);\n\n await waitFileSizeStable(localPath);\n\n const buffer = await nodejs.fs.readFile(localPath);\n return buffer.toString(\"base64\");\n }\n\n override async process(\n input: GeminiVideoModelInput,\n options: AgentInvokeOptions,\n ): Promise<GeminiVideoModelOutput> {\n const model = input.model ?? input.modelOptions?.model ?? this.credential.model;\n const mergedInput = { ...this.modelOptions, ...input };\n\n if (mergedInput.referenceImages && !model.includes(\"veo-3.1\")) {\n throw new Error(\"referenceImages is only supported in Veo 3.1 models\");\n }\n\n const config: GenerateVideosParameters[\"config\"] = {};\n if (mergedInput.negativePrompt) config.negativePrompt = mergedInput.negativePrompt;\n if (mergedInput.aspectRatio) config.aspectRatio = mergedInput.aspectRatio;\n if (mergedInput.size) config.resolution = mergedInput.size;\n if (mergedInput.seconds) config.durationSeconds = parseInt(mergedInput.seconds, 10);\n if (mergedInput.personGeneration) config.personGeneration = mergedInput.personGeneration;\n if (mergedInput.lastFrame) {\n config.lastFrame = await this.transformFileType(\"file\", mergedInput.lastFrame).then(\n (file) => {\n return {\n imageBytes: file.data,\n mimeType: file.mimeType,\n };\n },\n );\n }\n\n if (mergedInput.referenceImages) {\n config.referenceImages = await Promise.all(\n mergedInput.referenceImages.map(async (image) => {\n return await this.transformFileType(\"file\", image).then((file) => {\n return {\n image: {\n imageBytes: file.data,\n mimeType: file.mimeType,\n },\n };\n });\n }),\n );\n }\n\n const params: GenerateVideosParameters = {\n model,\n prompt: mergedInput.prompt,\n config,\n };\n\n if (mergedInput.image) {\n params.image = await this.transformFileType(\"file\", mergedInput.image).then((file) => {\n return {\n imageBytes: file.data,\n mimeType: file.mimeType,\n };\n });\n }\n\n // Start video generation\n let operation = await this.client.models.generateVideos(params);\n logger.debug(\"Video generation started...\");\n\n // Poll operation status until complete\n const pollingInterval = this.options?.pollingInterval ?? 10000;\n while (!operation.done) {\n logger.debug(\"Waiting for video generation to complete...\");\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n operation = await this.client.operations.getVideosOperation({ operation });\n }\n\n if (!operation.response?.generatedVideos?.[0]?.video) {\n throw new Error(\"Video generation failed: No video generated\");\n }\n\n // Download the generated video\n const generatedVideo = operation.response.generatedVideos[0];\n const videoFile = generatedVideo.video;\n\n if (!videoFile) {\n throw new Error(\"Video generation failed: No video file returned\");\n }\n\n // Save to temporary directory\n const dir = nodejs.path.join(nodejs.os.tmpdir(), options?.context?.id || \"\");\n await nodejs.fs.mkdir(dir, { recursive: true });\n\n const videoId = Date.now().toString();\n\n return {\n videos: [\n {\n type: \"file\",\n data: await this.downloadToFile(dir, videoId, videoFile),\n mimeType: \"video/mp4\",\n filename: `${videoId}.mp4`,\n },\n ],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n seconds: mergedInput.seconds ? parseInt(mergedInput.seconds, 10) : DEFAULT_SECONDS,\n };\n }\n}\n"],"mappings":"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"}
package/dist/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ const require_gemini_chat_model = require('./gemini-chat-model.cjs');
2
+ const require_gemini_image_model = require('./gemini-image-model.cjs');
3
+ const require_gemini_video_model = require('./gemini-video-model.cjs');
4
+
5
+ exports.GeminiChatModel = require_gemini_chat_model.GeminiChatModel;
6
+ exports.GeminiImageModel = require_gemini_image_model.GeminiImageModel;
7
+ exports.GeminiVideoModel = require_gemini_video_model.GeminiVideoModel;
@@ -0,0 +1,4 @@
1
+ import { GeminiChatModel, GeminiChatModelOptions } from "./gemini-chat-model.cjs";
2
+ import { GeminiImageModel, GeminiImageModelInput, GeminiImageModelOptions, GeminiImageModelOutput } from "./gemini-image-model.cjs";
3
+ import { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput } from "./gemini-video-model.cjs";
4
+ export { GeminiChatModel, GeminiChatModelOptions, GeminiImageModel, GeminiImageModelInput, GeminiImageModelOptions, GeminiImageModelOutput, GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
@@ -0,0 +1,4 @@
1
+ import { GeminiChatModel, GeminiChatModelOptions } from "./gemini-chat-model.mjs";
2
+ import { GeminiImageModel, GeminiImageModelInput, GeminiImageModelOptions, GeminiImageModelOutput } from "./gemini-image-model.mjs";
3
+ import { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput } from "./gemini-video-model.mjs";
4
+ export { GeminiChatModel, GeminiChatModelOptions, GeminiImageModel, GeminiImageModelInput, GeminiImageModelOptions, GeminiImageModelOutput, GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { GeminiChatModel } from "./gemini-chat-model.mjs";
2
+ import { GeminiImageModel } from "./gemini-image-model.mjs";
3
+ import { GeminiVideoModel } from "./gemini-video-model.mjs";
4
+
5
+ export { GeminiChatModel, GeminiImageModel, GeminiVideoModel };
package/dist/utils.cjs ADDED
@@ -0,0 +1,34 @@
1
+ let _aigne_utils_nodejs = require("@aigne/utils/nodejs");
2
+
3
+ //#region src/utils.ts
4
+ /**
5
+ * Wait for file size to stabilize, ensuring the file download is complete.
6
+ *
7
+ * @param filePath - The path to the file to check
8
+ * @param options - Configuration options
9
+ * @param options.checkInterval - Check interval in milliseconds (default: 500ms)
10
+ * @param options.stableCount - Number of consecutive checks with same size to consider stable (default: 3)
11
+ * @param options.timeout - Timeout in milliseconds (default: 60000ms)
12
+ * @throws Error when timeout is reached
13
+ */
14
+ async function waitFileSizeStable(filePath, options) {
15
+ const checkInterval = options?.checkInterval ?? 500;
16
+ const requiredStableCount = options?.stableCount ?? 3;
17
+ const timeout = options?.timeout ?? 6e4;
18
+ const startTime = Date.now();
19
+ let previousSize = 0;
20
+ let stableCount = 0;
21
+ while (stableCount < requiredStableCount) {
22
+ if (Date.now() - startTime > timeout) throw new Error(`Timeout waiting for file to stabilize: ${filePath}`);
23
+ await new Promise((resolve) => setTimeout(resolve, checkInterval));
24
+ const currentSize = (await _aigne_utils_nodejs.nodejs.fs.stat(filePath)).size;
25
+ if (currentSize === previousSize && currentSize > 0) stableCount++;
26
+ else {
27
+ stableCount = 0;
28
+ previousSize = currentSize;
29
+ }
30
+ }
31
+ }
32
+
33
+ //#endregion
34
+ exports.waitFileSizeStable = waitFileSizeStable;
package/dist/utils.mjs ADDED
@@ -0,0 +1,35 @@
1
+ import { nodejs } from "@aigne/utils/nodejs";
2
+
3
+ //#region src/utils.ts
4
+ /**
5
+ * Wait for file size to stabilize, ensuring the file download is complete.
6
+ *
7
+ * @param filePath - The path to the file to check
8
+ * @param options - Configuration options
9
+ * @param options.checkInterval - Check interval in milliseconds (default: 500ms)
10
+ * @param options.stableCount - Number of consecutive checks with same size to consider stable (default: 3)
11
+ * @param options.timeout - Timeout in milliseconds (default: 60000ms)
12
+ * @throws Error when timeout is reached
13
+ */
14
+ async function waitFileSizeStable(filePath, options) {
15
+ const checkInterval = options?.checkInterval ?? 500;
16
+ const requiredStableCount = options?.stableCount ?? 3;
17
+ const timeout = options?.timeout ?? 6e4;
18
+ const startTime = Date.now();
19
+ let previousSize = 0;
20
+ let stableCount = 0;
21
+ while (stableCount < requiredStableCount) {
22
+ if (Date.now() - startTime > timeout) throw new Error(`Timeout waiting for file to stabilize: ${filePath}`);
23
+ await new Promise((resolve) => setTimeout(resolve, checkInterval));
24
+ const currentSize = (await nodejs.fs.stat(filePath)).size;
25
+ if (currentSize === previousSize && currentSize > 0) stableCount++;
26
+ else {
27
+ stableCount = 0;
28
+ previousSize = currentSize;
29
+ }
30
+ }
31
+ }
32
+
33
+ //#endregion
34
+ export { waitFileSizeStable };
35
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { nodejs } from \"@aigne/utils/nodejs\";\n\n/**\n * Wait for file size to stabilize, ensuring the file download is complete.\n *\n * @param filePath - The path to the file to check\n * @param options - Configuration options\n * @param options.checkInterval - Check interval in milliseconds (default: 500ms)\n * @param options.stableCount - Number of consecutive checks with same size to consider stable (default: 3)\n * @param options.timeout - Timeout in milliseconds (default: 60000ms)\n * @throws Error when timeout is reached\n */\nexport async function waitFileSizeStable(\n filePath: string,\n options?: {\n checkInterval?: number;\n stableCount?: number;\n timeout?: number;\n },\n): Promise<void> {\n const checkInterval = options?.checkInterval ?? 500;\n const requiredStableCount = options?.stableCount ?? 3;\n const timeout = options?.timeout ?? 60000;\n\n const startTime = Date.now();\n let previousSize = 0;\n let stableCount = 0;\n\n while (stableCount < requiredStableCount) {\n if (Date.now() - startTime > timeout) {\n throw new Error(`Timeout waiting for file to stabilize: ${filePath}`);\n }\n\n await new Promise((resolve) => setTimeout(resolve, checkInterval));\n\n const stats = await nodejs.fs.stat(filePath);\n const currentSize = stats.size;\n\n if (currentSize === previousSize && currentSize > 0) {\n stableCount++;\n } else {\n stableCount = 0;\n previousSize = currentSize;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,mBACpB,UACA,SAKe;CACf,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,sBAAsB,SAAS,eAAe;CACpD,MAAM,UAAU,SAAS,WAAW;CAEpC,MAAM,YAAY,KAAK,KAAK;CAC5B,IAAI,eAAe;CACnB,IAAI,cAAc;AAElB,QAAO,cAAc,qBAAqB;AACxC,MAAI,KAAK,KAAK,GAAG,YAAY,QAC3B,OAAM,IAAI,MAAM,0CAA0C,WAAW;AAGvE,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,cAAc,CAAC;EAGlE,MAAM,eADQ,MAAM,OAAO,GAAG,KAAK,SAAS,EAClB;AAE1B,MAAI,gBAAgB,gBAAgB,cAAc,EAChD;OACK;AACL,iBAAc;AACd,kBAAe"}
package/package.json CHANGED
@@ -1,62 +1,61 @@
1
1
  {
2
2
  "name": "@aigne/gemini",
3
- "version": "0.14.16",
3
+ "version": "1.74.0-beta",
4
4
  "description": "AIGNE Gemini SDK for integrating with Google's Gemini AI models",
5
+ "license": "Elastic-2.0",
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },
8
9
  "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
9
10
  "homepage": "https://www.aigne.io/framework",
10
- "license": "Elastic-2.0",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/AIGNE-io/aigne-framework"
13
+ "url": "git+https://github.com/ArcBlock/aigne-framework"
14
14
  },
15
15
  "bugs": {
16
- "url": "https://github.com/AIGNE-io/aigne-framework/issues"
16
+ "url": "https://github.com/ArcBlock/aigne-framework/issues"
17
+ },
18
+ "type": "module",
19
+ "main": "./dist/index.cjs",
20
+ "module": "./dist/index.mjs",
21
+ "types": "./dist/index.d.cts",
22
+ "exports": {
23
+ ".": {
24
+ "require": "./dist/index.cjs",
25
+ "import": "./dist/index.mjs"
26
+ },
27
+ "./*": "./*"
17
28
  },
18
29
  "files": [
19
- "lib/cjs",
20
- "lib/dts",
21
- "lib/esm",
30
+ "dist",
22
31
  "LICENSE",
23
32
  "README.md",
24
33
  "CHANGELOG.md"
25
34
  ],
26
- "type": "module",
27
- "main": "./lib/cjs/index.js",
28
- "module": "./lib/esm/index.js",
29
- "types": "./lib/dts/index.d.ts",
30
- "exports": {
31
- ".": {
32
- "import": "./lib/esm/index.js",
33
- "require": "./lib/cjs/index.js",
34
- "types": "./lib/dts/index.d.ts"
35
- }
36
- },
37
35
  "dependencies": {
38
36
  "@aigne/uuid": "^13.0.1",
39
37
  "@google/genai": "^1.30.0",
40
38
  "yaml": "^2.8.1",
41
39
  "zod": "^3.25.67",
42
40
  "zod-to-json-schema": "^3.24.6",
43
- "@aigne/core": "^1.72.0",
44
- "@aigne/platform-helpers": "^0.6.7"
41
+ "@aigne/core": "^1.74.0-beta",
42
+ "@aigne/utils": "^1.74.0-beta"
45
43
  },
46
44
  "devDependencies": {
47
- "@types/bun": "^1.2.22",
48
- "@types/node": "^24.5.1",
45
+ "@types/bun": "^1.3.6",
49
46
  "npm-run-all": "^4.1.5",
50
- "rimraf": "^6.0.1",
51
- "typescript": "^5.9.2",
52
- "@aigne/test-utils": "^0.5.69"
47
+ "rimraf": "^6.1.2",
48
+ "tsdown": "0.20.0-beta.3",
49
+ "typescript": "5.9.2",
50
+ "@aigne/scripts": "0.0.0",
51
+ "@aigne/typescript-config": "0.0.0",
52
+ "@aigne/utils": "1.74.0-beta"
53
53
  },
54
54
  "scripts": {
55
- "lint": "tsc --noEmit",
56
- "build": "tsc --build scripts/tsconfig.build.json",
57
- "clean": "rimraf lib test/coverage",
55
+ "build": "tsdown",
56
+ "check-types": "tsc --noEmit",
57
+ "clean": "rimraf dist coverage",
58
58
  "test": "bun test",
59
- "test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text",
60
- "postbuild": "node ../../scripts/post-build-lib.mjs"
59
+ "test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
61
60
  }
62
61
  }