@devvibex/aiflow 1.15.1 → 1.15.2
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 +22 -2
- package/package.json +1 -1
- package/src/index.d.ts +12 -9
- package/src/index.js +65 -5
package/README.md
CHANGED
|
@@ -167,7 +167,8 @@ const clip = await aiflow.generateVideo({
|
|
|
167
167
|
|
|
168
168
|
**Seedance reference mode.** Instead of a first frame, Seedance can take
|
|
169
169
|
reference assets and keep them consistent in a new shot — cite them in the
|
|
170
|
-
prompt as
|
|
170
|
+
prompt as `@Image 1`, `@Video 1`, `@Audio 1` (or `[Image 1]`) in the order you
|
|
171
|
+
pass them; the gateway converts to the form the running Seedance release uses.
|
|
171
172
|
It is a separate mode: it cannot be combined with `image` / `lastFrame`.
|
|
172
173
|
|
|
173
174
|
| | Seedance 2.0 | Seedance 2.5 |
|
|
@@ -183,12 +184,31 @@ default; `generateAudio: false` makes them silent.
|
|
|
183
184
|
```js
|
|
184
185
|
const ad = await aiflow.generateVideo({
|
|
185
186
|
model: 'seedance',
|
|
186
|
-
prompt: 'The girl from
|
|
187
|
+
prompt: 'The girl from @Image 1 unboxes the sneaker from @Image 2, dancing to @Audio 1',
|
|
187
188
|
referenceImages: [characterUrl, productUrl],
|
|
188
189
|
referenceAudios: [musicUrl],
|
|
189
190
|
});
|
|
190
191
|
```
|
|
191
192
|
|
|
193
|
+
**Sending audio (Seedance).** `referenceAudios` takes wav or mp3 clips — an
|
|
194
|
+
`https://` URL, a `data:` URL, an `asset://` id, or (≥ 1.15.2) the uploaded
|
|
195
|
+
`File` itself, which the SDK sends as a data URL. Each clip runs at least 2s and
|
|
196
|
+
is under 15 MB; together they stay within 15s on Seedance 2.0 and 30s on 2.5.
|
|
197
|
+
Browser microphone recordings (webm / ogg) are refused with an `AIFlowError`
|
|
198
|
+
before any request. Pair a voice or song with a picture of the performer for a
|
|
199
|
+
lip-synced clip:
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
const clip = await aiflow.generateVideo({
|
|
203
|
+
model: 'seedance',
|
|
204
|
+
prompt: 'The woman in @Image 1 sings @Audio 1 with precise lip sync',
|
|
205
|
+
referenceImages: [portraitFile], // File / Blob from <input type="file">
|
|
206
|
+
referenceAudios: [songFile], // wav or mp3 File
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
Reference audio is its own mode: it cannot be combined with `image` /
|
|
210
|
+
`lastFrame` (start and end frames).
|
|
211
|
+
|
|
192
212
|
The default model is **Gemini Omni**: one clip of ~10s, **with sound**, 16:9 or
|
|
193
213
|
9:16 only, and no length parameter. For a longer or extendable video use
|
|
194
214
|
`generateLongVideo` / `createVideoSession` below — same model, so a single clip
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvibex/aiflow",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"description": "First-party LLM gateway SDK for apps generated on the VibeX platform — chat, streaming, image, video (including stateful multi-turn video extension with Gemini Omni), music (Lyria), sound effects (ElevenLabs), embeddings and real-time speech translation (Gemini Live) without shipping any third-party API key.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
package/src/index.d.ts
CHANGED
|
@@ -231,37 +231,40 @@ export interface VideoRequest {
|
|
|
231
231
|
watermark?: boolean;
|
|
232
232
|
/**
|
|
233
233
|
* Still image to animate (image-to-video) — the clip's FIRST frame. An
|
|
234
|
-
* `https://` URL
|
|
234
|
+
* `https://` URL, a `data:` URL, or a `File` / `Blob` (≥ 1.15.2).
|
|
235
235
|
*/
|
|
236
|
-
image?: string;
|
|
236
|
+
image?: string | Blob;
|
|
237
237
|
/**
|
|
238
238
|
* Image the clip must END on (first + last frame). Same formats as `image`
|
|
239
239
|
* and requires it. Seedance and Kling — Gemini Omni and Veo ignore it, so
|
|
240
240
|
* the module must be pinned to one of them. Kling takes JPG / PNG only.
|
|
241
241
|
* Needs `@devvibex/aiflow` ≥ 1.15.0.
|
|
242
242
|
*/
|
|
243
|
-
lastFrame?: string;
|
|
244
|
-
video?: string;
|
|
243
|
+
lastFrame?: string | Blob;
|
|
244
|
+
video?: string | Blob;
|
|
245
245
|
/**
|
|
246
246
|
* Seedance only — reference images that keep a character, product or style
|
|
247
247
|
* (omni reference mode). Up to 9 on Seedance 2.0, 30 on 2.5. Cited in the
|
|
248
|
-
* prompt as
|
|
248
|
+
* prompt as @Image 1, @Image 2, … (or [Image 1]) in this order. `https://`, `data:` or
|
|
249
249
|
* `asset://`. Cannot be combined with `image` / `lastFrame`.
|
|
250
250
|
*/
|
|
251
|
-
referenceImages?: string
|
|
251
|
+
referenceImages?: Array<string | Blob>;
|
|
252
252
|
/**
|
|
253
253
|
* Seedance only — reference videos for motion/camera, or the clip to edit
|
|
254
254
|
* or extend. Up to 3 on Seedance 2.0 (2–15s each, ≤15s total), 10 on 2.5
|
|
255
|
-
* (≤30s total). `https://` or `asset://` only. Cited as
|
|
255
|
+
* (≤30s total). `https://` or `asset://` only. Cited as @Video 1, ….
|
|
256
256
|
*/
|
|
257
257
|
referenceVideos?: string[];
|
|
258
258
|
/**
|
|
259
259
|
* Seedance only — reference audio (voice, music, rhythm), wav or mp3. Up to
|
|
260
260
|
* 3 on Seedance 2.0 (2–15s each, ≤15s total), and there it needs at least
|
|
261
261
|
* one reference image or video; 10 on 2.5 (≤30s total), audio alone allowed.
|
|
262
|
-
* Cited as
|
|
262
|
+
* Cited as @Audio 1, …. A voice or song with a character picture gives a
|
|
263
|
+
* lip-synced performance ("the woman in @Image 1 sings @Audio 1"). Pass the
|
|
264
|
+
* uploaded `File`s directly (sent as data URLs, ≥ 1.15.2) or https:// URLs;
|
|
265
|
+
* each clip under 15 MB. Browser recordings (webm / ogg) are refused.
|
|
263
266
|
*/
|
|
264
|
-
referenceAudios?: string
|
|
267
|
+
referenceAudios?: Array<string | Blob>;
|
|
265
268
|
/**
|
|
266
269
|
* Seedance and Kling — whether the clip gets synchronized sound (voice,
|
|
267
270
|
* effects, music). Omitted: on for Seedance, off for Kling (where sound
|
package/src/index.js
CHANGED
|
@@ -562,6 +562,31 @@ export class AIFlowClient {
|
|
|
562
562
|
'referenceImages / referenceVideos / referenceAudios cannot be combined with image / lastFrame',
|
|
563
563
|
);
|
|
564
564
|
}
|
|
565
|
+
if (referenceVideos?.some(isBlob)) {
|
|
566
|
+
throw new AIFlowError(
|
|
567
|
+
'referenceVideos take https:// or asset:// URLs — upload the video file first',
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
// A File / Blob is sent as a data URL, so an upload can be passed as-is.
|
|
571
|
+
const [imageIn, lastFrameIn, videoIn, referenceImagesIn, referenceAudiosIn] =
|
|
572
|
+
await Promise.all([
|
|
573
|
+
toMediaInput(image),
|
|
574
|
+
toMediaInput(lastFrame),
|
|
575
|
+
toMediaInput(video),
|
|
576
|
+
referenceImages && Promise.all(referenceImages.map(toMediaInput)),
|
|
577
|
+
referenceAudios && Promise.all(referenceAudios.map(toMediaInput)),
|
|
578
|
+
]);
|
|
579
|
+
const badAudio = referenceAudiosIn?.find(
|
|
580
|
+
(a) =>
|
|
581
|
+
typeof a === 'string' &&
|
|
582
|
+
a.startsWith('data:') &&
|
|
583
|
+
!REFERENCE_AUDIO_DATA_URL.test(a),
|
|
584
|
+
);
|
|
585
|
+
if (badAudio) {
|
|
586
|
+
throw new AIFlowError(
|
|
587
|
+
`referenceAudios must be wav or mp3 files (got ${badAudio.slice(5, badAudio.search(/[;,]/))}); browser recordings such as webm are not accepted`,
|
|
588
|
+
);
|
|
589
|
+
}
|
|
565
590
|
const resolvedModel =
|
|
566
591
|
model || (await this._resolveDefaultModel('video'));
|
|
567
592
|
const res = await this._request(
|
|
@@ -573,12 +598,12 @@ export class AIFlowClient {
|
|
|
573
598
|
resolution,
|
|
574
599
|
duration,
|
|
575
600
|
watermark,
|
|
576
|
-
image,
|
|
577
|
-
lastFrame,
|
|
578
|
-
video,
|
|
579
|
-
referenceImages,
|
|
601
|
+
image: imageIn,
|
|
602
|
+
lastFrame: lastFrameIn,
|
|
603
|
+
video: videoIn,
|
|
604
|
+
referenceImages: referenceImagesIn,
|
|
580
605
|
referenceVideos,
|
|
581
|
-
referenceAudios,
|
|
606
|
+
referenceAudios: referenceAudiosIn,
|
|
582
607
|
generateAudio,
|
|
583
608
|
},
|
|
584
609
|
// Submit returns fast; the default client timeout is plenty even
|
|
@@ -1683,6 +1708,41 @@ async function loadSocketIoClient() {
|
|
|
1683
1708
|
}
|
|
1684
1709
|
}
|
|
1685
1710
|
|
|
1711
|
+
// Media types for a File / Blob whose `type` the browser left empty.
|
|
1712
|
+
const MEDIA_TYPE_BY_EXTENSION = {
|
|
1713
|
+
mp3: 'audio/mpeg',
|
|
1714
|
+
wav: 'audio/wav',
|
|
1715
|
+
png: 'image/png',
|
|
1716
|
+
jpg: 'image/jpeg',
|
|
1717
|
+
jpeg: 'image/jpeg',
|
|
1718
|
+
webp: 'image/webp',
|
|
1719
|
+
gif: 'image/gif',
|
|
1720
|
+
mp4: 'video/mp4',
|
|
1721
|
+
mov: 'video/quicktime',
|
|
1722
|
+
};
|
|
1723
|
+
|
|
1724
|
+
// The audio types Seedance takes as reference audio (wav / mp3, any of the
|
|
1725
|
+
// names browsers give them); the gateway relabels them for Ark.
|
|
1726
|
+
const REFERENCE_AUDIO_DATA_URL =
|
|
1727
|
+
/^data:audio\/(mpeg|mp3|mpeg3|x-mp3|x-mpeg|mpg|wav|x-wav|wave|vnd\.wave)[;,]/i;
|
|
1728
|
+
|
|
1729
|
+
function isBlob(value) {
|
|
1730
|
+
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
/** A File / Blob as a `data:` URL; strings and empty values pass through. */
|
|
1734
|
+
async function toMediaInput(value) {
|
|
1735
|
+
if (!isBlob(value)) return value;
|
|
1736
|
+
const ext = String(value.name || '')
|
|
1737
|
+
.split('.')
|
|
1738
|
+
.pop()
|
|
1739
|
+
.toLowerCase();
|
|
1740
|
+
const type =
|
|
1741
|
+
value.type || MEDIA_TYPE_BY_EXTENSION[ext] || 'application/octet-stream';
|
|
1742
|
+
const bytes = new Uint8Array(await value.arrayBuffer());
|
|
1743
|
+
return `data:${type};base64,${toBase64(bytes)}`;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1686
1746
|
function toBase64(chunk) {
|
|
1687
1747
|
if (typeof chunk === 'string') return chunk; // assume already base64
|
|
1688
1748
|
let bytes;
|