ai-world-sdk 1.0.11 → 1.0.12
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
CHANGED
|
@@ -219,7 +219,6 @@ const result = await client.generate({
|
|
|
219
219
|
prompt: 'A beautiful landscape', // 必需
|
|
220
220
|
model: 'gemini-2.5-flash-image', // 推荐:快速、高效
|
|
221
221
|
aspect_ratio: '16:9', // 可选: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
|
|
222
|
-
number_of_images: 1, // 可选: 1-4
|
|
223
222
|
});
|
|
224
223
|
|
|
225
224
|
// 高级用法(使用 Gemini 3 Pro - 专业模型,支持高分辨率)
|
|
@@ -228,7 +227,6 @@ const result2 = await client.generate({
|
|
|
228
227
|
model: 'gemini-3-pro-image-preview', // 专业级模型
|
|
229
228
|
aspect_ratio: '16:9',
|
|
230
229
|
image_size: '2K', // 可选: 1K, 2K, 4K(仅适用于 gemini-3-pro-image-preview)
|
|
231
|
-
number_of_images: 1,
|
|
232
230
|
response_modalities: ['IMAGE'], // 仅返回图片,不返回文本
|
|
233
231
|
temperature: 0.7, // 可选: 0.0-2.0
|
|
234
232
|
max_output_tokens: 1000, // 可选
|
|
@@ -244,7 +242,6 @@ const result3 = await aihubmixClient.generate({
|
|
|
244
242
|
model: 'gemini-3-pro-image-preview',
|
|
245
243
|
aspect_ratio: '16:9',
|
|
246
244
|
image_size: '1K',
|
|
247
|
-
number_of_images: 1,
|
|
248
245
|
response_modalities: ['IMAGE'],
|
|
249
246
|
});
|
|
250
247
|
|
|
@@ -286,7 +283,6 @@ const secondResponse = await client.chat({
|
|
|
286
283
|
| `image` | `string \| string[]` | 输入图片(base64 或 data URL)。可以是单个图片或图片数组(多图输入) | - |
|
|
287
284
|
| `aspect_ratio` | `string` | 宽高比 | - |
|
|
288
285
|
| `image_size` | `string` | 图片大小(仅 gemini-3-pro-image-preview) | - |
|
|
289
|
-
| `number_of_images` | `number` | 生成图片数量 | `1` |
|
|
290
286
|
| `response_modalities` | `array` | 响应模态 | `['TEXT', 'IMAGE']` |
|
|
291
287
|
| `temperature` | `number` | 温度参数 | `0.7` |
|
|
292
288
|
| `max_output_tokens` | `number` | 最大输出 token 数 | `1000` |
|
|
@@ -670,7 +666,6 @@ const result = await client.generate({
|
|
|
670
666
|
prompt: 'A beautiful sunset over the ocean',
|
|
671
667
|
model: 'gemini-2.5-flash-image',
|
|
672
668
|
aspect_ratio: '16:9',
|
|
673
|
-
number_of_images: 1,
|
|
674
669
|
});
|
|
675
670
|
|
|
676
671
|
console.log('图像 URL:', result.data[0]?.url || 'Base64 编码');
|
|
@@ -564,7 +564,6 @@ describe("Langchain SDK Tests", () => {
|
|
|
564
564
|
model: 'gemini-3-pro-image-preview',
|
|
565
565
|
aspect_ratio: '16:9',
|
|
566
566
|
image_size: '1K', // 仅适用于 gemini-3-pro-image-preview
|
|
567
|
-
number_of_images: 1,
|
|
568
567
|
response_modalities: ['IMAGE'], // 仅返回图片
|
|
569
568
|
});
|
|
570
569
|
expect(result).toBeDefined();
|
|
@@ -652,7 +651,6 @@ describe("Langchain SDK Tests", () => {
|
|
|
652
651
|
model: 'gemini-3-pro-image-preview',
|
|
653
652
|
aspect_ratio: '16:9',
|
|
654
653
|
image_size: '1K',
|
|
655
|
-
number_of_images: 1,
|
|
656
654
|
response_modalities: ['IMAGE'], // 仅返回图片
|
|
657
655
|
});
|
|
658
656
|
expect(result).toBeDefined();
|
|
@@ -11,7 +11,6 @@ export interface GeminiImageGenerationRequest {
|
|
|
11
11
|
prompt: string;
|
|
12
12
|
model?: string;
|
|
13
13
|
image?: string | string[];
|
|
14
|
-
number_of_images?: number;
|
|
15
14
|
aspect_ratio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9";
|
|
16
15
|
image_size?: "1K" | "2K" | "4K";
|
|
17
16
|
temperature?: number;
|
|
@@ -57,7 +56,6 @@ export declare class GeminiImageGenerationClient {
|
|
|
57
56
|
* - aspect_ratio: 宽高比,支持 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
|
|
58
57
|
* - image_size: 图片大小(仅 gemini-3-pro-image-preview),支持 1K, 2K, 4K
|
|
59
58
|
* - response_modalities: 响应模态,["TEXT", "IMAGE"] 或 ["IMAGE"]
|
|
60
|
-
* - number_of_images: 生成图片数量(1-4)
|
|
61
59
|
*/
|
|
62
60
|
generate(request: GeminiImageGenerationRequest): Promise<GeminiImageGenerationResponse>;
|
|
63
61
|
/**
|
|
@@ -33,13 +33,11 @@ class GeminiImageGenerationClient {
|
|
|
33
33
|
* - aspect_ratio: 宽高比,支持 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
|
|
34
34
|
* - image_size: 图片大小(仅 gemini-3-pro-image-preview),支持 1K, 2K, 4K
|
|
35
35
|
* - response_modalities: 响应模态,["TEXT", "IMAGE"] 或 ["IMAGE"]
|
|
36
|
-
* - number_of_images: 生成图片数量(1-4)
|
|
37
36
|
*/
|
|
38
37
|
async generate(request) {
|
|
39
38
|
const requestBody = {
|
|
40
39
|
prompt: request.prompt,
|
|
41
40
|
model: request.model || "gemini-2.0-flash-exp-image-generation",
|
|
42
|
-
number_of_images: request.number_of_images || 1,
|
|
43
41
|
};
|
|
44
42
|
// 添加图片输入参数(单图或多图)
|
|
45
43
|
if (request.image) {
|
package/package.json
CHANGED