@coreviz/sdk 1.0.13 → 1.0.14
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 +25 -1
- package/dist/coreviz.d.ts +7 -0
- package/dist/coreviz.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -133,6 +133,30 @@ const editedImage = await coreviz.edit('https://example.com/photo.jpg', {
|
|
|
133
133
|
});
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
### `coreviz.batchGenerate(prompt, options)`
|
|
137
|
+
|
|
138
|
+
Generates multiple images based on a text prompt, optionally using reference images for style/structure guidance.
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
- `prompt` (string): The text description of the image(s) to generate.
|
|
142
|
+
- `options` (object, optional):
|
|
143
|
+
- `referenceImages` (string[], optional): Array of reference images (URL/base64) to guide generation.
|
|
144
|
+
- `count` (number, optional): Number of images to generate (default: 1).
|
|
145
|
+
- `aspectRatio` (string, optional): Target aspect ratio (e.g., `'1:1'`, `'16:9'`, `'4:3'`).
|
|
146
|
+
- `model` (string, optional): The model to use (default: `'google/nano-banana-pro'`).
|
|
147
|
+
|
|
148
|
+
**Returns:**
|
|
149
|
+
- `Promise<string[]>`: An array of generated images as URLs.
|
|
150
|
+
|
|
151
|
+
**Example:**
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const images = await coreviz.batchGenerate("A futuristic city skyline", {
|
|
155
|
+
count: 4,
|
|
156
|
+
aspectRatio: "16:9"
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
136
160
|
### `coreviz.embed(input, options?)`
|
|
137
161
|
|
|
138
162
|
Generates embeddings for image or text inputs, enabling semantic search and similarity comparison. Use with `coreviz.similarity(embeddingA, embeddingB)` to compare two images or an image and a text.
|
|
@@ -187,4 +211,4 @@ Utility function to resize images client-side or server-side before processing.
|
|
|
187
211
|
```typescript
|
|
188
212
|
const resized = await coreviz.resize(myFileObject, 800, 600);
|
|
189
213
|
// or import { resize } from '@coreviz/sdk';
|
|
190
|
-
```
|
|
214
|
+
```
|
package/dist/coreviz.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export interface EmbedOptions {
|
|
|
27
27
|
export interface EmbedResponse {
|
|
28
28
|
embedding: number[];
|
|
29
29
|
}
|
|
30
|
+
export interface BatchGenerateOptions {
|
|
31
|
+
referenceImages?: string[];
|
|
32
|
+
count?: number;
|
|
33
|
+
aspectRatio?: '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9';
|
|
34
|
+
model?: 'google/nano-banana' | 'google/nano-banana-pro';
|
|
35
|
+
}
|
|
30
36
|
export declare class CoreViz {
|
|
31
37
|
private apiKey?;
|
|
32
38
|
private token?;
|
|
@@ -35,6 +41,7 @@ export declare class CoreViz {
|
|
|
35
41
|
private handleResponse;
|
|
36
42
|
describe(image: string, options?: DescribeOptions): Promise<string>;
|
|
37
43
|
edit(image: string, options: EditOptions): Promise<string>;
|
|
44
|
+
batchGenerate(prompt: string, options?: BatchGenerateOptions): Promise<string[]>;
|
|
38
45
|
tag(image: string, options: TagOptions): Promise<TagResponse>;
|
|
39
46
|
private tagLocal;
|
|
40
47
|
embed(input: string, options?: EmbedOptions): Promise<EmbedResponse>;
|
package/dist/coreviz.js
CHANGED
|
@@ -103,6 +103,31 @@ class CoreViz {
|
|
|
103
103
|
throw err instanceof Error ? err : new Error("An unexpected error occurred.");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
async batchGenerate(prompt, options = {}) {
|
|
107
|
+
try {
|
|
108
|
+
const headers = this.getHeaders();
|
|
109
|
+
let resizedImages = [];
|
|
110
|
+
if (options.referenceImages && options.referenceImages.length > 0) {
|
|
111
|
+
resizedImages = await Promise.all(options.referenceImages.map(img => (0, resize_1.resize)(img, 1024, 1024)));
|
|
112
|
+
}
|
|
113
|
+
const response = await fetch(`https://lab.coreviz.io/api/ai/batch-generate`, {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers,
|
|
116
|
+
body: JSON.stringify({
|
|
117
|
+
prompt,
|
|
118
|
+
image: resizedImages.length > 0 ? resizedImages : undefined,
|
|
119
|
+
count: options.count || 1,
|
|
120
|
+
aspectRatio: options.aspectRatio,
|
|
121
|
+
model: options.model || 'google/nano-banana-pro',
|
|
122
|
+
}),
|
|
123
|
+
});
|
|
124
|
+
const data = await this.handleResponse(response);
|
|
125
|
+
return data.results || [];
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
throw err instanceof Error ? err : new Error("An unexpected error occurred.");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
106
131
|
async tag(image, options) {
|
|
107
132
|
const mode = options?.mode || 'api';
|
|
108
133
|
if (mode === 'local') {
|