@aigne/gemini 1.74.0-beta → 1.74.0-beta.10
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 +4 -4
- package/dist/gemini-chat-model.cjs +19 -19
- package/dist/gemini-chat-model.d.cts +10 -43
- package/dist/gemini-chat-model.d.cts.map +1 -1
- package/dist/gemini-chat-model.d.mts +10 -43
- package/dist/gemini-chat-model.d.mts.map +1 -1
- package/dist/gemini-chat-model.mjs +6 -6
- package/dist/gemini-chat-model.mjs.map +1 -1
- package/dist/gemini-embedding-model.cjs +65 -0
- package/dist/gemini-embedding-model.d.cts +28 -0
- package/dist/gemini-embedding-model.d.cts.map +1 -0
- package/dist/gemini-embedding-model.d.mts +28 -0
- package/dist/gemini-embedding-model.d.mts.map +1 -0
- package/dist/gemini-embedding-model.mjs +66 -0
- package/dist/gemini-embedding-model.mjs.map +1 -0
- package/dist/gemini-image-model.cjs +10 -10
- package/dist/gemini-image-model.d.cts +6 -6
- package/dist/gemini-image-model.d.cts.map +1 -1
- package/dist/gemini-image-model.d.mts +6 -6
- package/dist/gemini-image-model.d.mts.map +1 -1
- package/dist/gemini-image-model.mjs +2 -2
- package/dist/gemini-image-model.mjs.map +1 -1
- package/dist/gemini-video-model.cjs +18 -18
- package/dist/gemini-video-model.d.cts +53 -53
- package/dist/gemini-video-model.d.cts.map +1 -1
- package/dist/gemini-video-model.d.mts +53 -53
- package/dist/gemini-video-model.d.mts.map +1 -1
- package/dist/gemini-video-model.mjs +6 -6
- package/dist/gemini-video-model.mjs.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/dist/utils.cjs +2 -2
- package/dist/utils.mjs +1 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +3 -6
- package/LICENSE.md +0 -93
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { EmbeddingModel, embeddingModelInputSchema } from "@aigne/model-base";
|
|
2
|
+
import { checkArguments } from "@aigne/model-base/utils/type-utils";
|
|
3
|
+
import { GoogleGenAI } from "@google/genai";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/gemini-embedding-model.ts
|
|
7
|
+
const DEFAULT_MODEL = "text-embedding-004";
|
|
8
|
+
const geminiEmbeddingModelInputSchema = embeddingModelInputSchema.extend({});
|
|
9
|
+
const geminiEmbeddingModelOptionsSchema = z.object({
|
|
10
|
+
apiKey: z.string().optional(),
|
|
11
|
+
baseURL: z.string().optional(),
|
|
12
|
+
model: z.string().optional(),
|
|
13
|
+
modelOptions: z.object({}).optional(),
|
|
14
|
+
clientOptions: z.object({}).optional()
|
|
15
|
+
});
|
|
16
|
+
var GeminiEmbeddingModel = class extends EmbeddingModel {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super({
|
|
19
|
+
...options,
|
|
20
|
+
inputSchema: geminiEmbeddingModelInputSchema,
|
|
21
|
+
description: options?.description ?? "Generate embeddings by Gemini embedding models"
|
|
22
|
+
});
|
|
23
|
+
this.options = options;
|
|
24
|
+
if (options) checkArguments(this.name, geminiEmbeddingModelOptionsSchema, options);
|
|
25
|
+
}
|
|
26
|
+
_client;
|
|
27
|
+
apiKeyEnvName = "GEMINI_API_KEY";
|
|
28
|
+
get client() {
|
|
29
|
+
if (this._client) return this._client;
|
|
30
|
+
const { apiKey } = this.credential;
|
|
31
|
+
if (!apiKey) throw new Error(`${this.name} requires an API key. Please provide it via \`options.apiKey\`, or set the \`${this.apiKeyEnvName}\` environment variable`);
|
|
32
|
+
this._client ??= new GoogleGenAI({ apiKey });
|
|
33
|
+
return this._client;
|
|
34
|
+
}
|
|
35
|
+
get credential() {
|
|
36
|
+
return {
|
|
37
|
+
url: this.options?.baseURL || process.env.GEMINI_BASE_URL,
|
|
38
|
+
apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],
|
|
39
|
+
model: this.options?.model || DEFAULT_MODEL
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async process(input, _options) {
|
|
43
|
+
const model = input.modelOptions?.model || this.credential.model;
|
|
44
|
+
const contents = Array.isArray(input.input) ? input.input : [input.input];
|
|
45
|
+
const config = {
|
|
46
|
+
...input.dimensions ? { outputDimensionality: input.dimensions } : {},
|
|
47
|
+
...input.modelOptions?.taskType ? { taskType: input.modelOptions.taskType } : {}
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
embeddings: (await this.client.models.embedContent({
|
|
51
|
+
model,
|
|
52
|
+
contents,
|
|
53
|
+
config
|
|
54
|
+
})).embeddings?.map((e) => e.values ?? []) ?? [],
|
|
55
|
+
usage: {
|
|
56
|
+
inputTokens: 0,
|
|
57
|
+
outputTokens: 0
|
|
58
|
+
},
|
|
59
|
+
model
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { GeminiEmbeddingModel };
|
|
66
|
+
//# sourceMappingURL=gemini-embedding-model.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-embedding-model.mjs","names":[],"sources":["../src/gemini-embedding-model.ts"],"sourcesContent":["import {\n EmbeddingModel,\n type EmbeddingModelInput,\n type EmbeddingModelOptions,\n type EmbeddingModelOutput,\n embeddingModelInputSchema,\n type ModelInvokeOptions,\n} from \"@aigne/model-base\";\nimport { checkArguments } from \"@aigne/model-base/utils/type-utils\";\nimport { type EmbedContentConfig, GoogleGenAI } from \"@google/genai\";\nimport { z } from \"zod\";\n\nconst DEFAULT_MODEL = \"text-embedding-004\";\n\nexport interface GeminiEmbeddingModelInput extends EmbeddingModelInput {}\nexport interface GeminiEmbeddingModelOutput extends EmbeddingModelOutput {}\n\nexport interface GeminiEmbeddingModelOptions\n extends EmbeddingModelOptions<GeminiEmbeddingModelInput, GeminiEmbeddingModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n clientOptions?: Record<string, any>;\n}\n\nconst geminiEmbeddingModelInputSchema = embeddingModelInputSchema.extend({});\n\nconst geminiEmbeddingModelOptionsSchema = 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});\n\nexport class GeminiEmbeddingModel extends EmbeddingModel<\n GeminiEmbeddingModelInput,\n GeminiEmbeddingModelOutput\n> {\n constructor(public override options?: GeminiEmbeddingModelOptions) {\n super({\n ...options,\n inputSchema: geminiEmbeddingModelInputSchema,\n description: options?.description ?? \"Generate embeddings by Gemini embedding models\",\n });\n if (options) checkArguments(this.name, geminiEmbeddingModelOptionsSchema, options);\n }\n\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n if (this._client) return this._client;\n\n const { apiKey } = this.credential;\n\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 });\n\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 override async process(\n input: GeminiEmbeddingModelInput,\n _options: ModelInvokeOptions,\n ): Promise<GeminiEmbeddingModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const contents = Array.isArray(input.input) ? input.input : [input.input];\n\n const config: EmbedContentConfig = {\n ...(input.dimensions ? { outputDimensionality: input.dimensions } : {}),\n ...(input.modelOptions?.taskType\n ? { taskType: input.modelOptions.taskType as string }\n : {}),\n };\n\n const response = await this.client.models.embedContent({\n model,\n contents,\n config,\n });\n\n return {\n embeddings: response.embeddings?.map((e) => e.values ?? []) ?? [],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n };\n }\n}\n"],"mappings":";;;;;;AAYA,MAAM,gBAAgB;AAatB,MAAM,kCAAkC,0BAA0B,OAAO,EAAE,CAAC;AAE5E,MAAM,oCAAoC,EAAE,OAAO;CACjD,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACrC,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACvC,CAAC;AAEF,IAAa,uBAAb,cAA0C,eAGxC;CACA,YAAY,AAAgB,SAAuC;AACjE,QAAM;GACJ,GAAG;GACH,aAAa;GACb,aAAa,SAAS,eAAe;GACtC,CAAC;EALwB;AAM1B,MAAI,QAAS,gBAAe,KAAK,MAAM,mCAAmC,QAAQ;;CAGpF,AAAU;CAEV,AAAU,gBAAgB;CAE1B,IAAI,SAAS;AACX,MAAI,KAAK,QAAS,QAAO,KAAK;EAE9B,MAAM,EAAE,WAAW,KAAK;AAExB,MAAI,CAAC,OACH,OAAM,IAAI,MACR,GAAG,KAAK,KAAK,+EAA+E,KAAK,cAAc,yBAChH;AAEH,OAAK,YAAY,IAAI,YAAY,EAAE,QAAQ,CAAC;AAE5C,SAAO,KAAK;;CAGd,IAAa,aAAa;AACxB,SAAO;GACL,KAAK,KAAK,SAAS,WAAW,QAAQ,IAAI;GAC1C,QAAQ,KAAK,SAAS,UAAU,QAAQ,IAAI,KAAK;GACjD,OAAO,KAAK,SAAS,SAAS;GAC/B;;CAGH,MAAe,QACb,OACA,UACqC;EACrC,MAAM,QAAQ,MAAM,cAAc,SAAS,KAAK,WAAW;EAE3D,MAAM,WAAW,MAAM,QAAQ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,MAAM;EAEzE,MAAM,SAA6B;GACjC,GAAI,MAAM,aAAa,EAAE,sBAAsB,MAAM,YAAY,GAAG,EAAE;GACtE,GAAI,MAAM,cAAc,WACpB,EAAE,UAAU,MAAM,aAAa,UAAoB,GACnD,EAAE;GACP;AAQD,SAAO;GACL,aAPe,MAAM,KAAK,OAAO,OAAO,aAAa;IACrD;IACA;IACA;IACD,CAAC,EAGqB,YAAY,KAAK,MAAM,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE;GACjE,OAAO;IACL,aAAa;IACb,cAAc;IACf;GACD;GACD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
let
|
|
2
|
-
let
|
|
1
|
+
let _aigne_model_base = require("@aigne/model-base");
|
|
2
|
+
let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
|
|
3
3
|
let _google_genai = require("@google/genai");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
|
|
6
6
|
//#region src/gemini-image-model.ts
|
|
7
7
|
const DEFAULT_MODEL = "imagen-4.0-generate-001";
|
|
8
|
-
const geminiImageModelInputSchema =
|
|
8
|
+
const geminiImageModelInputSchema = _aigne_model_base.imageModelInputSchema.extend({});
|
|
9
9
|
const geminiImageModelOptionsSchema = zod.z.object({
|
|
10
10
|
apiKey: zod.z.string().optional(),
|
|
11
11
|
baseURL: zod.z.string().optional(),
|
|
@@ -13,7 +13,7 @@ const geminiImageModelOptionsSchema = zod.z.object({
|
|
|
13
13
|
modelOptions: zod.z.object({}).optional(),
|
|
14
14
|
clientOptions: zod.z.object({}).optional()
|
|
15
15
|
});
|
|
16
|
-
var GeminiImageModel = class extends
|
|
16
|
+
var GeminiImageModel = class extends _aigne_model_base.ImageModel {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
super({
|
|
19
19
|
...options,
|
|
@@ -21,7 +21,7 @@ var GeminiImageModel = class extends _aigne_core.ImageModel {
|
|
|
21
21
|
description: options?.description ?? "Draw or edit image by Gemini image models"
|
|
22
22
|
});
|
|
23
23
|
this.options = options;
|
|
24
|
-
if (options) (0,
|
|
24
|
+
if (options) (0, _aigne_model_base_utils_type_utils.checkArguments)(this.name, geminiImageModelOptionsSchema, options);
|
|
25
25
|
}
|
|
26
26
|
_client;
|
|
27
27
|
apiKeyEnvName = "GEMINI_API_KEY";
|
|
@@ -66,7 +66,7 @@ var GeminiImageModel = class extends _aigne_core.ImageModel {
|
|
|
66
66
|
prompt: mergedInput.prompt,
|
|
67
67
|
config: {
|
|
68
68
|
numberOfImages: mergedInput.n || 1,
|
|
69
|
-
...(0,
|
|
69
|
+
...(0, _aigne_model_base_utils_type_utils.pick)(mergedInput, [
|
|
70
70
|
"seed",
|
|
71
71
|
"safetyFilterLevel",
|
|
72
72
|
"personGeneration",
|
|
@@ -87,7 +87,7 @@ var GeminiImageModel = class extends _aigne_core.ImageModel {
|
|
|
87
87
|
type: "file",
|
|
88
88
|
data: image.imageBytes,
|
|
89
89
|
mimeType: image.mimeType
|
|
90
|
-
} : void 0).filter(
|
|
90
|
+
} : void 0).filter(_aigne_model_base_utils_type_utils.isNonNullable) || [],
|
|
91
91
|
usage: {
|
|
92
92
|
inputTokens: 0,
|
|
93
93
|
outputTokens: 0
|
|
@@ -133,7 +133,7 @@ var GeminiImageModel = class extends _aigne_core.ImageModel {
|
|
|
133
133
|
"topP",
|
|
134
134
|
"imageConfig"
|
|
135
135
|
];
|
|
136
|
-
const images = await Promise.all((0,
|
|
136
|
+
const images = await Promise.all((0, _aigne_model_base_utils_type_utils.flat)(input.image).map(async (image) => {
|
|
137
137
|
const { data, mimeType } = await this.transformFileType("file", image);
|
|
138
138
|
return { inlineData: {
|
|
139
139
|
data,
|
|
@@ -146,7 +146,7 @@ var GeminiImageModel = class extends _aigne_core.ImageModel {
|
|
|
146
146
|
config: {
|
|
147
147
|
responseModalities: [_google_genai.Modality.TEXT, _google_genai.Modality.IMAGE],
|
|
148
148
|
candidateCount: input.n || 1,
|
|
149
|
-
...(0,
|
|
149
|
+
...(0, _aigne_model_base_utils_type_utils.pick)(mergedInput, inputKeys)
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
return {
|
|
@@ -155,7 +155,7 @@ var GeminiImageModel = class extends _aigne_core.ImageModel {
|
|
|
155
155
|
data: part.inlineData.data,
|
|
156
156
|
filename: part.inlineData.displayName,
|
|
157
157
|
mimeType: part.inlineData.mimeType
|
|
158
|
-
} : null).filter(
|
|
158
|
+
} : null).filter(_aigne_model_base_utils_type_utils.isNonNullable),
|
|
159
159
|
usage: {
|
|
160
160
|
inputTokens: response.usageMetadata?.promptTokenCount || 0,
|
|
161
161
|
outputTokens: response.usageMetadata?.candidatesTokenCount || 0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageModel, ImageModelInput, ImageModelOptions, ImageModelOutput, ModelInvokeOptions } from "@aigne/model-base";
|
|
2
2
|
import { GenerateContentConfig, GenerateImagesConfig, GoogleGenAI } from "@google/genai";
|
|
3
3
|
|
|
4
4
|
//#region src/gemini-image-model.d.ts
|
|
@@ -24,11 +24,11 @@ declare class GeminiImageModel extends ImageModel<GeminiImageModelInput, GeminiI
|
|
|
24
24
|
};
|
|
25
25
|
get modelOptions(): Omit<Partial<GeminiImageModelInput>, "model"> | undefined;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
process(input: GeminiImageModelInput, _options:
|
|
27
|
+
* Process the input and generate a response
|
|
28
|
+
* @param input The input to process
|
|
29
|
+
* @returns The generated response
|
|
30
|
+
*/
|
|
31
|
+
process(input: GeminiImageModelInput, _options: ModelInvokeOptions): Promise<ImageModelOutput>;
|
|
32
32
|
private generateImageByImagenModel;
|
|
33
33
|
private generateImageByGeminiModel;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-image-model.d.cts","names":[],"sources":["../src/gemini-image-model.ts"],"mappings":";;;;UAqBiB,qBAAA,SACP,eAAA,EACN,oBAAA,EACA,qBAAA;AAAA,UACa,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;
|
|
1
|
+
{"version":3,"file":"gemini-image-model.d.cts","names":[],"sources":["../src/gemini-image-model.ts"],"mappings":";;;;UAqBiB,qBAAA,SACP,eAAA,EACN,oBAAA,EACA,qBAAA;AAAA,UACa,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EACjD,MAAA;EACA,OAAA;EACA,KAAA;EACA,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAC5B,aAAA,GAAgB,MAAA;AAAA;AAAA,cAaL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAC1C,OAAA,GAAU,uBAAA;cAAV,OAAA,GAAU,uBAAA;EAAA,UAS5B,OAAA,GAAU,WAAA;EAAA,UAEV,aAAA;EAAA,IAEN,MAAA,CAAA,GAAM,WAAA;EAAA,IAeG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,qBAAA;EAvDU;;;;;EAgEX,OAAA,CACb,KAAA,EAAO,qBAAA,EACP,QAAA,EAAU,kBAAA,GACT,OAAA,CAAQ,gBAAA;EAAA,QAcG,0BAAA;EAAA,QA+CA,0BAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageModel, ImageModelInput, ImageModelOptions, ImageModelOutput, ModelInvokeOptions } from "@aigne/model-base";
|
|
2
2
|
import { GenerateContentConfig, GenerateImagesConfig, GoogleGenAI } from "@google/genai";
|
|
3
3
|
|
|
4
4
|
//#region src/gemini-image-model.d.ts
|
|
@@ -24,11 +24,11 @@ declare class GeminiImageModel extends ImageModel<GeminiImageModelInput, GeminiI
|
|
|
24
24
|
};
|
|
25
25
|
get modelOptions(): Omit<Partial<GeminiImageModelInput>, "model"> | undefined;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
process(input: GeminiImageModelInput, _options:
|
|
27
|
+
* Process the input and generate a response
|
|
28
|
+
* @param input The input to process
|
|
29
|
+
* @returns The generated response
|
|
30
|
+
*/
|
|
31
|
+
process(input: GeminiImageModelInput, _options: ModelInvokeOptions): Promise<ImageModelOutput>;
|
|
32
32
|
private generateImageByImagenModel;
|
|
33
33
|
private generateImageByGeminiModel;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-image-model.d.mts","names":[],"sources":["../src/gemini-image-model.ts"],"mappings":";;;;UAqBiB,qBAAA,SACP,eAAA,EACN,oBAAA,EACA,qBAAA;AAAA,UACa,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;
|
|
1
|
+
{"version":3,"file":"gemini-image-model.d.mts","names":[],"sources":["../src/gemini-image-model.ts"],"mappings":";;;;UAqBiB,qBAAA,SACP,eAAA,EACN,oBAAA,EACA,qBAAA;AAAA,UACa,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EACjD,MAAA;EACA,OAAA;EACA,KAAA;EACA,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAC5B,aAAA,GAAgB,MAAA;AAAA;AAAA,cAaL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAC1C,OAAA,GAAU,uBAAA;cAAV,OAAA,GAAU,uBAAA;EAAA,UAS5B,OAAA,GAAU,WAAA;EAAA,UAEV,aAAA;EAAA,IAEN,MAAA,CAAA,GAAM,WAAA;EAAA,IAeG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,qBAAA;EAvDU;;;;;EAgEX,OAAA,CACb,KAAA,EAAO,qBAAA,EACP,QAAA,EAAU,kBAAA,GACT,OAAA,CAAQ,gBAAA;EAAA,QAcG,0BAAA;EAAA,QA+CA,0BAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageModel, imageModelInputSchema } from "@aigne/
|
|
2
|
-
import { checkArguments, flat, isNonNullable, pick } from "@aigne/
|
|
1
|
+
import { ImageModel, imageModelInputSchema } from "@aigne/model-base";
|
|
2
|
+
import { checkArguments, flat, isNonNullable, pick } from "@aigne/model-base/utils/type-utils";
|
|
3
3
|
import { GoogleGenAI, Modality } from "@google/genai";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-image-model.mjs","names":[],"sources":["../src/gemini-image-model.ts"],"sourcesContent":["import {\n type
|
|
1
|
+
{"version":3,"file":"gemini-image-model.mjs","names":[],"sources":["../src/gemini-image-model.ts"],"sourcesContent":["import {\n type FileUnionContent,\n ImageModel,\n type ImageModelInput,\n type ImageModelOptions,\n type ImageModelOutput,\n imageModelInputSchema,\n type ModelInvokeOptions,\n} from \"@aigne/model-base\";\nimport { checkArguments, flat, isNonNullable, pick } from \"@aigne/model-base/utils/type-utils\";\nimport {\n type GenerateContentConfig,\n type GenerateImagesConfig,\n GoogleGenAI,\n Modality,\n type PartUnion,\n} from \"@google/genai\";\nimport { z } from \"zod\";\n\nconst DEFAULT_MODEL = \"imagen-4.0-generate-001\";\n\nexport interface GeminiImageModelInput\n extends ImageModelInput,\n GenerateImagesConfig,\n GenerateContentConfig {}\nexport interface GeminiImageModelOutput extends ImageModelOutput {}\n\nexport interface GeminiImageModelOptions\n extends ImageModelOptions<GeminiImageModelInput, GeminiImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<GeminiImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst geminiImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst geminiImageModelOptionsSchema = 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});\n\nexport class GeminiImageModel extends ImageModel<GeminiImageModelInput, GeminiImageModelOutput> {\n constructor(public override options?: GeminiImageModelOptions) {\n super({\n ...options,\n inputSchema: geminiImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Gemini image models\",\n });\n if (options) checkArguments(this.name, geminiImageModelOptionsSchema, options);\n }\n\n protected _client?: GoogleGenAI;\n\n protected apiKeyEnvName = \"GEMINI_API_KEY\";\n\n get client() {\n if (this._client) return this._client;\n\n const { apiKey } = this.credential;\n\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 });\n\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 /**\n * Process the input and generate a response\n * @param input The input to process\n * @returns The generated response\n */\n override async process(\n input: GeminiImageModelInput,\n _options: ModelInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n const responseFormat = input.responseFormat || \"base64\";\n if (responseFormat === \"url\") {\n throw new Error(\"Gemini image models currently only support base64 format\");\n }\n\n if (model.includes(\"imagen\")) {\n return this.generateImageByImagenModel(input);\n }\n\n return this.generateImageByGeminiModel(input);\n }\n\n private async generateImageByImagenModel(\n input: GeminiImageModelInput,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const mergedInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const inputKeys = [\n \"seed\",\n \"safetyFilterLevel\",\n \"personGeneration\",\n \"outputMimeType\",\n \"outputGcsUri\",\n \"outputCompressionQuality\",\n \"negativePrompt\",\n \"language\",\n \"includeSafetyAttributes\",\n \"includeRaiReason\",\n \"imageSize\",\n \"guidanceScale\",\n \"aspectRatio\",\n \"addWatermark\",\n ];\n\n const response = await this.client.models.generateImages({\n model,\n prompt: mergedInput.prompt,\n config: { numberOfImages: mergedInput.n || 1, ...pick(mergedInput, inputKeys) },\n });\n\n return {\n images:\n response.generatedImages\n ?.map<FileUnionContent | undefined>(({ image }) =>\n image?.imageBytes\n ? { type: \"file\", data: image.imageBytes, mimeType: image.mimeType }\n : undefined,\n )\n .filter(isNonNullable) || [],\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n };\n }\n\n private async generateImageByGeminiModel(\n input: GeminiImageModelInput,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\n\n const mergedInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const inputKeys = [\n \"abortSignal\",\n \"audioTimestamp\",\n \"automaticFunctionCalling\",\n \"cachedContent\",\n \"frequencyPenalty\",\n \"httpOptions\",\n \"labels\",\n \"logprobs\",\n \"maxOutputTokens\",\n \"mediaResolution\",\n \"modelSelectionConfig\",\n \"presencePenalty\",\n \"responseJsonSchema\",\n \"responseLogprobs\",\n \"responseMimeType\",\n \"responseSchema\",\n \"routingConfig\",\n \"safetySettings\",\n \"seed\",\n \"speechConfig\",\n \"stopSequences\",\n \"systemInstruction\",\n \"temperature\",\n \"thinkingConfig\",\n \"toolConfig\",\n \"tools\",\n \"topK\",\n \"topP\",\n \"imageConfig\",\n ];\n\n const images = await Promise.all(\n flat(input.image).map<Promise<PartUnion>>(async (image) => {\n const { data, mimeType } = await this.transformFileType(\"file\", image);\n return { inlineData: { data, mimeType } };\n }),\n );\n\n const response = await this.client.models.generateContent({\n model,\n contents: [{ text: input.prompt }, ...images],\n config: {\n responseModalities: [Modality.TEXT, Modality.IMAGE],\n candidateCount: input.n || 1,\n ...pick(mergedInput, inputKeys),\n },\n });\n\n const allImages = (response.candidates ?? [])\n .flatMap((candidate) => candidate.content?.parts ?? [])\n .map<FileUnionContent | null>((part) =>\n part.inlineData?.data\n ? {\n type: \"file\",\n data: part.inlineData.data,\n filename: part.inlineData.displayName,\n mimeType: part.inlineData.mimeType,\n }\n : null,\n )\n .filter(isNonNullable);\n\n return {\n images: allImages,\n usage: {\n inputTokens: response.usageMetadata?.promptTokenCount || 0,\n outputTokens: response.usageMetadata?.candidatesTokenCount || 0,\n },\n model,\n };\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const require_utils = require('./utils.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let
|
|
2
|
+
let _aigne_model_base = require("@aigne/model-base");
|
|
3
|
+
let _aigne_model_base_utils_logger = require("@aigne/model-base/utils/logger");
|
|
4
|
+
let _aigne_model_base_utils_nodejs = require("@aigne/model-base/utils/nodejs");
|
|
5
|
+
let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
|
|
6
6
|
let _google_genai = require("@google/genai");
|
|
7
7
|
let zod = require("zod");
|
|
8
8
|
|
|
9
9
|
//#region src/gemini-video-model.ts
|
|
10
10
|
const DEFAULT_MODEL = "veo-3.1-generate-preview";
|
|
11
11
|
const DEFAULT_SECONDS = 8;
|
|
12
|
-
const geminiVideoModelInputSchema =
|
|
12
|
+
const geminiVideoModelInputSchema = _aigne_model_base.videoModelInputSchema.extend({
|
|
13
13
|
negativePrompt: zod.z.string().optional(),
|
|
14
14
|
aspectRatio: zod.z.enum(["16:9", "9:16"]).optional(),
|
|
15
15
|
size: zod.z.enum(["720p", "1080p"]).optional(),
|
|
@@ -19,8 +19,8 @@ const geminiVideoModelInputSchema = _aigne_core.videoModelInputSchema.extend({
|
|
|
19
19
|
"8"
|
|
20
20
|
]).optional(),
|
|
21
21
|
personGeneration: zod.z.string().optional(),
|
|
22
|
-
lastFrame:
|
|
23
|
-
referenceImages:
|
|
22
|
+
lastFrame: _aigne_model_base.fileUnionContentSchema.optional(),
|
|
23
|
+
referenceImages: _aigne_model_base.fileUnionContentSchema.array().optional()
|
|
24
24
|
});
|
|
25
25
|
const geminiVideoModelOptionsSchema = zod.z.object({
|
|
26
26
|
apiKey: zod.z.string().optional(),
|
|
@@ -30,7 +30,7 @@ const geminiVideoModelOptionsSchema = zod.z.object({
|
|
|
30
30
|
clientOptions: zod.z.object({}).optional(),
|
|
31
31
|
pollingInterval: zod.z.number().optional()
|
|
32
32
|
});
|
|
33
|
-
var GeminiVideoModel = class extends
|
|
33
|
+
var GeminiVideoModel = class extends _aigne_model_base.VideoModel {
|
|
34
34
|
constructor(options) {
|
|
35
35
|
super({
|
|
36
36
|
...options,
|
|
@@ -38,7 +38,7 @@ var GeminiVideoModel = class extends _aigne_core.VideoModel {
|
|
|
38
38
|
inputSchema: geminiVideoModelInputSchema
|
|
39
39
|
});
|
|
40
40
|
this.options = options;
|
|
41
|
-
if (options) (0,
|
|
41
|
+
if (options) (0, _aigne_model_base_utils_type_utils.checkArguments)(this.name, geminiVideoModelOptionsSchema, options);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* @hidden
|
|
@@ -65,17 +65,17 @@ var GeminiVideoModel = class extends _aigne_core.VideoModel {
|
|
|
65
65
|
return this.options?.modelOptions;
|
|
66
66
|
}
|
|
67
67
|
async downloadToFile(dir, videoId, videoFile) {
|
|
68
|
-
|
|
69
|
-
const localPath =
|
|
68
|
+
_aigne_model_base_utils_logger.logger.debug("Downloading video content...");
|
|
69
|
+
const localPath = _aigne_model_base_utils_nodejs.nodejs.path.join(dir, `${videoId}.mp4`);
|
|
70
70
|
await this.client.files.download({
|
|
71
71
|
file: videoFile,
|
|
72
72
|
downloadPath: localPath
|
|
73
73
|
});
|
|
74
|
-
|
|
74
|
+
_aigne_model_base_utils_logger.logger.debug(`Generated video saved to ${localPath}`);
|
|
75
75
|
await require_utils.waitFileSizeStable(localPath);
|
|
76
|
-
return (await
|
|
76
|
+
return (await _aigne_model_base_utils_nodejs.nodejs.fs.readFile(localPath)).toString("base64");
|
|
77
77
|
}
|
|
78
|
-
async process(input,
|
|
78
|
+
async process(input, _options) {
|
|
79
79
|
const model = input.model ?? input.modelOptions?.model ?? this.credential.model;
|
|
80
80
|
const mergedInput = {
|
|
81
81
|
...this.modelOptions,
|
|
@@ -114,18 +114,18 @@ var GeminiVideoModel = class extends _aigne_core.VideoModel {
|
|
|
114
114
|
};
|
|
115
115
|
});
|
|
116
116
|
let operation = await this.client.models.generateVideos(params);
|
|
117
|
-
|
|
117
|
+
_aigne_model_base_utils_logger.logger.debug("Video generation started...");
|
|
118
118
|
const pollingInterval = this.options?.pollingInterval ?? 1e4;
|
|
119
119
|
while (!operation.done) {
|
|
120
|
-
|
|
120
|
+
_aigne_model_base_utils_logger.logger.debug("Waiting for video generation to complete...");
|
|
121
121
|
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
122
122
|
operation = await this.client.operations.getVideosOperation({ operation });
|
|
123
123
|
}
|
|
124
124
|
if (!operation.response?.generatedVideos?.[0]?.video) throw new Error("Video generation failed: No video generated");
|
|
125
125
|
const videoFile = operation.response.generatedVideos[0].video;
|
|
126
126
|
if (!videoFile) throw new Error("Video generation failed: No video file returned");
|
|
127
|
-
const dir =
|
|
128
|
-
await
|
|
127
|
+
const dir = _aigne_model_base_utils_nodejs.nodejs.path.join(_aigne_model_base_utils_nodejs.nodejs.os.tmpdir(), `gemini-video-${Date.now()}`);
|
|
128
|
+
await _aigne_model_base_utils_nodejs.nodejs.fs.mkdir(dir, { recursive: true });
|
|
129
129
|
const videoId = Date.now().toString();
|
|
130
130
|
return {
|
|
131
131
|
videos: [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileUnionContent, ModelInvokeOptions, VideoModel, VideoModelInput, VideoModelOptions, VideoModelOutput } from "@aigne/model-base";
|
|
2
2
|
import { GoogleGenAI } from "@google/genai";
|
|
3
3
|
|
|
4
4
|
//#region src/gemini-video-model.d.ts
|
|
@@ -7,47 +7,47 @@ import { GoogleGenAI } from "@google/genai";
|
|
|
7
7
|
*/
|
|
8
8
|
interface GeminiVideoModelInput extends VideoModelInput {
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Text describing content that should not appear in the video
|
|
11
|
+
*/
|
|
12
12
|
negativePrompt?: string;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
19
|
aspectRatio?: "16:9" | "9:16";
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
26
|
size?: "720p" | "1080p";
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
* Duration of the generated video in seconds
|
|
29
|
+
*
|
|
30
|
+
* Veo 3.1: "4", "6", "8"
|
|
31
|
+
* Veo 3: "4", "6", "8"
|
|
32
|
+
*/
|
|
33
33
|
seconds?: "4" | "6" | "8";
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
42
|
personGeneration?: string;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* Last frame for video generation (frame interpolation)
|
|
45
|
+
*/
|
|
46
46
|
lastFrame?: FileUnionContent;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
* Reference images for video generation
|
|
49
|
+
* Only supported in Veo 3.1 models
|
|
50
|
+
*/
|
|
51
51
|
referenceImages?: FileUnionContent[];
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -59,44 +59,44 @@ interface GeminiVideoModelOutput extends VideoModelOutput {}
|
|
|
59
59
|
*/
|
|
60
60
|
interface GeminiVideoModelOptions extends VideoModelOptions<GeminiVideoModelInput, GeminiVideoModelOutput> {
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
* API key for Gemini API
|
|
63
|
+
*
|
|
64
|
+
* If not provided, will look for GEMINI_API_KEY in environment variables
|
|
65
|
+
*/
|
|
66
66
|
apiKey?: string;
|
|
67
67
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
* Base URL for Gemini API
|
|
69
|
+
*
|
|
70
|
+
* Useful for proxies or alternate endpoints
|
|
71
|
+
*/
|
|
72
72
|
baseURL?: string;
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
* Gemini model to use
|
|
75
|
+
*
|
|
76
|
+
* Defaults to 'veo-3.1-generate-preview'
|
|
77
|
+
*/
|
|
78
78
|
model?: string;
|
|
79
79
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
* Additional model options to control behavior
|
|
81
|
+
*/
|
|
82
82
|
modelOptions?: Omit<Partial<GeminiVideoModelInput>, "model">;
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
* Client options for Gemini API
|
|
85
|
+
*/
|
|
86
86
|
clientOptions?: Record<string, any>;
|
|
87
87
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
* Polling interval in milliseconds for checking video generation status
|
|
89
|
+
*
|
|
90
|
+
* Defaults to 10000ms (10 seconds)
|
|
91
|
+
*/
|
|
92
92
|
pollingInterval?: number;
|
|
93
93
|
}
|
|
94
94
|
declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiVideoModelOutput> {
|
|
95
95
|
options?: GeminiVideoModelOptions | undefined;
|
|
96
96
|
constructor(options?: GeminiVideoModelOptions | undefined);
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
* @hidden
|
|
99
|
+
*/
|
|
100
100
|
protected _client?: GoogleGenAI;
|
|
101
101
|
protected apiKeyEnvName: string;
|
|
102
102
|
get client(): GoogleGenAI;
|
|
@@ -110,7 +110,7 @@ declare class GeminiVideoModel extends VideoModel<GeminiVideoModelInput, GeminiV
|
|
|
110
110
|
uri?: string;
|
|
111
111
|
videoBytes?: any;
|
|
112
112
|
}): Promise<string>;
|
|
113
|
-
process(input: GeminiVideoModelInput,
|
|
113
|
+
process(input: GeminiVideoModelInput, _options: ModelInvokeOptions): Promise<GeminiVideoModelOutput>;
|
|
114
114
|
}
|
|
115
115
|
//#endregion
|
|
116
116
|
export { GeminiVideoModel, GeminiVideoModelInput, GeminiVideoModelOptions, GeminiVideoModelOutput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-video-model.d.cts","names":[],"sources":["../src/gemini-video-model.ts"],"mappings":";;;;;AAqBA;;UAAiB,qBAAA,SAA8B,eAAA;
|
|
1
|
+
{"version":3,"file":"gemini-video-model.d.cts","names":[],"sources":["../src/gemini-video-model.ts"],"mappings":";;;;;AAqBA;;UAAiB,qBAAA,SAA8B,eAAA;EA2CjC;;;EAvCZ,cAAA;EAJ4D;;;;;;EAY5D,WAAA;EA+BA;;;;;;EAvBA,IAAA;EAmCsC;;;;AAKxC;;EAhCE,OAAA;EAiC0B;;;;;;;;EAvB1B,gBAAA;EAuBQ;;;EAlBR,SAAA,GAAY,gBAAA;EA+BZ;;;;EAzBA,eAAA,GAAkB,gBAAA;AAAA;;;;UAMH,sBAAA,SAA+B,gBAAA;AAiEhD;;;AAAA,UA5DiB,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EA2DqB;;;;;EArDtE,MAAA;EA0FgB;;;;;EAnFhB,OAAA;EA0GG;;;;;EAnGH,KAAA;EAuCsE;;;EAlCtE,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAmCU;;;EA9BtC,aAAA,GAAgB,MAAA;EA6CN;;;;;EAtCV,eAAA;AAAA;AAAA,cAsBW,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAC1C,OAAA,GAAU,uBAAA;cAAV,OAAA,GAAU,uBAAA;EAoCtB;;;EAAA,UAvBN,OAAA,GAAU,WAAA;EAAA,UAEV,aAAA;EAAA,IAEN,MAAA,CAAA,GAAM,WAAA;EAAA,IAWG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,qBAAA;EAIV,cAAA,CACJ,GAAA,UACA,OAAA,UACA,SAAA;IAAa,GAAA;IAAc,UAAA;EAAA,IAC1B,OAAA;EAYY,OAAA,CACb,KAAA,EAAO,qBAAA,EACP,QAAA,EAAU,kBAAA,GACT,OAAA,CAAQ,sBAAA;AAAA"}
|