@picsart/ai-sdk 5.20.0 → 5.21.0
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/index.d.ts +15 -3
- package/index.js +23 -17
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2187,9 +2187,10 @@ interface ModelDefinition {
|
|
|
2187
2187
|
editEstimatedTime?: number | Record<string, number>;
|
|
2188
2188
|
testTimeout?: number;
|
|
2189
2189
|
/**
|
|
2190
|
-
* Per-model polling overrides for async jobs.
|
|
2191
|
-
* 2s ×
|
|
2192
|
-
*
|
|
2190
|
+
* Per-model polling overrides for async jobs. Narrows or widens the mode
|
|
2191
|
+
* default (video 2s × 1800 ≈ 1 h; image/audio/text 1s × 1200 ≈ 20 min) for
|
|
2192
|
+
* models whose generations don't fit it. Explicit per-call poll options
|
|
2193
|
+
* still win.
|
|
2193
2194
|
*/
|
|
2194
2195
|
pollOptions?: {
|
|
2195
2196
|
intervalMs?: number;
|
|
@@ -2396,6 +2397,17 @@ interface GenerateTextResult {
|
|
|
2396
2397
|
/** Options for individual generate() / submit() calls. */
|
|
2397
2398
|
interface GenerateOptions {
|
|
2398
2399
|
signal?: AbortSignal;
|
|
2400
|
+
/**
|
|
2401
|
+
* Poll interval for the async status loop, in ms. Overrides the model's
|
|
2402
|
+
* `pollOptions` and the mode default (video 2s; image/audio/text 1s).
|
|
2403
|
+
*/
|
|
2404
|
+
intervalMs?: number;
|
|
2405
|
+
/**
|
|
2406
|
+
* Max poll attempts before the call throws a timeout. Overrides the model's
|
|
2407
|
+
* `pollOptions` and the mode default (video 1800 ≈ 1 hour;
|
|
2408
|
+
* image/audio/text 1200 ≈ 20 min).
|
|
2409
|
+
*/
|
|
2410
|
+
maxAttempts?: number;
|
|
2399
2411
|
/** Save to a specific subfolder instead of the root (legacy — used by SDK DriveConfig). */
|
|
2400
2412
|
folder?: DriveFolder;
|
|
2401
2413
|
/** Save result to Picsart Drive via backend. Injected into the workflow payload. */
|
package/index.js
CHANGED
|
@@ -3129,9 +3129,6 @@ var { MODELS: MODELS10 } = defineModels("wan", [
|
|
|
3129
3129
|
description: "Wan 3.0 all-in-one \u2014 text, image/video/audio references, and start/end frames with adaptive ratio, intelligent duration, and audio.",
|
|
3130
3130
|
features: [...wanV3Features],
|
|
3131
3131
|
constraints: wanV3Constraints,
|
|
3132
|
-
// Generations at 1080P / long durations can outlast the global 10-min
|
|
3133
|
-
// polling default — widen to 5s × 360 attempts (30 min).
|
|
3134
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3135
3132
|
paramConfig: { ...wanV3ParamConfig }
|
|
3136
3133
|
},
|
|
3137
3134
|
{
|
|
@@ -3146,7 +3143,6 @@ var { MODELS: MODELS10 } = defineModels("wan", [
|
|
|
3146
3143
|
description: "Wan 3.0 Prime \u2014 the same all-in-one model as Wan 3.0, up to 7x faster.",
|
|
3147
3144
|
features: [...wanV3Features],
|
|
3148
3145
|
constraints: wanV3Constraints,
|
|
3149
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3150
3146
|
paramConfig: { ...wanV3ParamConfig }
|
|
3151
3147
|
}
|
|
3152
3148
|
]);
|
|
@@ -3786,12 +3782,6 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
|
|
|
3786
3782
|
badge: ["new", "premium", "hot"],
|
|
3787
3783
|
description: "Latest cinematic video with audio, multi-reference input, and mp4/mov output. Up to 30s.",
|
|
3788
3784
|
features: [feat("Reference Image", "frame"), feat("Start/End Frame", "frame"), feat("Audio", "audio"), feat("1080p", "resolution"), feat("4-30 sec", "duration")],
|
|
3789
|
-
// 1080p / 30s runs, and the whole extend path, outlast the global 10-min
|
|
3790
|
-
// polling default: measured p90 for seedance-2.5-video-extend sits above
|
|
3791
|
-
// the 600s ceiling. Widened to 5s × 360 attempts (30 min), same request
|
|
3792
|
-
// count, 3x the wall clock. Deliberately NOT derived from estimatedTime,
|
|
3793
|
-
// which understates seedance latency by ~10x.
|
|
3794
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3795
3785
|
paramConfig: {
|
|
3796
3786
|
...params.prompt(),
|
|
3797
3787
|
...params.aspectRatio(SEEDANCE_AR),
|
|
@@ -3821,7 +3811,6 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
|
|
|
3821
3811
|
badge: ["new", "premium", "hot"],
|
|
3822
3812
|
description: "Edit video \u2014 replace subjects, add or remove objects, restyle scenes with reference images.",
|
|
3823
3813
|
features: [feat("Video Input", "input"), feat("Multi-Image Input", "input"), feat("Audio", "audio"), feat("1080p", "resolution"), feat("Source length", "duration")],
|
|
3824
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3825
3814
|
paramConfig: {
|
|
3826
3815
|
...params.prompt(),
|
|
3827
3816
|
// Editing mode: aspect ratio is fixed to 'adaptive' and duration is
|
|
@@ -3848,7 +3837,6 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
|
|
|
3848
3837
|
badge: ["new", "premium", "hot"],
|
|
3849
3838
|
description: "Stitch up to 10 clips into one continuous, extended video.",
|
|
3850
3839
|
features: [feat("Multi-Video Input", "input"), feat("Audio", "audio"), feat("1080p", "resolution"), feat("4-30 sec", "duration")],
|
|
3851
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3852
3840
|
paramConfig: {
|
|
3853
3841
|
...params.prompt(),
|
|
3854
3842
|
// Extension mode: aspect ratio is locked to 'adaptive' (vendor rule);
|
|
@@ -9904,6 +9892,23 @@ function createCatalogs(transport, options) {
|
|
|
9904
9892
|
}
|
|
9905
9893
|
|
|
9906
9894
|
// src/client/index.ts
|
|
9895
|
+
var MODE_POLL_DEFAULTS = {
|
|
9896
|
+
video: { intervalMs: 2e3, maxAttempts: 1800 },
|
|
9897
|
+
// 2s × 1800 = 1 hour
|
|
9898
|
+
image: { intervalMs: 1e3, maxAttempts: 1200 },
|
|
9899
|
+
// 1s × 1200 = 20 min
|
|
9900
|
+
audio: { intervalMs: 1e3, maxAttempts: 1200 },
|
|
9901
|
+
// 1s × 1200 = 20 min
|
|
9902
|
+
text: { intervalMs: 1e3, maxAttempts: 1200 }
|
|
9903
|
+
// 1s × 1200 = 20 min
|
|
9904
|
+
};
|
|
9905
|
+
function resolvePollOptions(model, overrides) {
|
|
9906
|
+
const resolved = { ...MODE_POLL_DEFAULTS[model.mode], ...model.pollOptions };
|
|
9907
|
+
if (overrides?.intervalMs !== void 0) resolved.intervalMs = overrides.intervalMs;
|
|
9908
|
+
if (overrides?.maxAttempts !== void 0) resolved.maxAttempts = overrides.maxAttempts;
|
|
9909
|
+
if (overrides?.signal !== void 0) resolved.signal = overrides.signal;
|
|
9910
|
+
return resolved;
|
|
9911
|
+
}
|
|
9907
9912
|
function createClient(config) {
|
|
9908
9913
|
const isConfig = isClientConfig(config);
|
|
9909
9914
|
const transport = isConfig ? buildTransport(config) : config;
|
|
@@ -9913,7 +9918,8 @@ function createClient(config) {
|
|
|
9913
9918
|
const catalogs = createCatalogs(transport, isConfig ? config.catalogs : void 0);
|
|
9914
9919
|
const driveConfig = isConfig ? config.drive : void 0;
|
|
9915
9920
|
const driveClient = isConfig && driveConfig ? createDriveClient(resolveFetch(config), config.apiUrl, driveConfig.folder) : null;
|
|
9916
|
-
async function executeModel(model, workflow, payload,
|
|
9921
|
+
async function executeModel(model, workflow, payload, options) {
|
|
9922
|
+
const signal = options?.signal;
|
|
9917
9923
|
if (model.syncExecute || !supportsSubmit) {
|
|
9918
9924
|
const syncResponse = await client.run(
|
|
9919
9925
|
{ workflow, payload, signal },
|
|
@@ -9926,7 +9932,7 @@ function createClient(config) {
|
|
|
9926
9932
|
syncResponse.usage
|
|
9927
9933
|
);
|
|
9928
9934
|
}
|
|
9929
|
-
return client.run({ workflow, payload, signal }, model
|
|
9935
|
+
return client.run({ workflow, payload, signal }, resolvePollOptions(model, options));
|
|
9930
9936
|
}
|
|
9931
9937
|
function buildDrivePayloadOptions(model, params2, options) {
|
|
9932
9938
|
const explicit = options?.drive;
|
|
@@ -9966,7 +9972,7 @@ function createClient(config) {
|
|
|
9966
9972
|
const { workflow, payload, contract } = prepareRequest(resolved, params2);
|
|
9967
9973
|
const drive = buildDrivePayloadOptions(resolved, params2, options);
|
|
9968
9974
|
const finalPayload = injectDriveOptions(payload, drive);
|
|
9969
|
-
const completed = await executeModel(resolved, workflow, finalPayload, options
|
|
9975
|
+
const completed = await executeModel(resolved, workflow, finalPayload, options);
|
|
9970
9976
|
return parseResult(completed, resolved, contract);
|
|
9971
9977
|
},
|
|
9972
9978
|
/**
|
|
@@ -9983,7 +9989,7 @@ function createClient(config) {
|
|
|
9983
9989
|
throw new Error(`${resolved.name} is not a text model \u2014 use generate() instead.`);
|
|
9984
9990
|
}
|
|
9985
9991
|
const { workflow, payload } = prepareRequest(resolved, params2);
|
|
9986
|
-
const completed = await executeModel(resolved, workflow, payload, options
|
|
9992
|
+
const completed = await executeModel(resolved, workflow, payload, options);
|
|
9987
9993
|
return parseTextResult(completed, resolved);
|
|
9988
9994
|
},
|
|
9989
9995
|
/** @deprecated Use `getCredits()` instead. */
|
|
@@ -10027,7 +10033,7 @@ function createClient(config) {
|
|
|
10027
10033
|
async result(handle, model, options) {
|
|
10028
10034
|
const resolved = resolveModel(model);
|
|
10029
10035
|
const contract = getModelContract(resolved.id);
|
|
10030
|
-
const completed = await client.result(handle,
|
|
10036
|
+
const completed = await client.result(handle, resolvePollOptions(resolved, options));
|
|
10031
10037
|
return parseResult(completed, resolved, contract);
|
|
10032
10038
|
},
|
|
10033
10039
|
/**
|