@picsart/ai-sdk 5.29.0 → 5.31.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 +22 -1
- package/index.js +16 -5
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2482,6 +2482,11 @@ interface ClientConfig {
|
|
|
2482
2482
|
apiUrl: string;
|
|
2483
2483
|
/** Enable Drive integration — auto-save generations to a Drive folder. */
|
|
2484
2484
|
drive?: DriveConfig;
|
|
2485
|
+
/**
|
|
2486
|
+
* Input-transformation defaults applied to every generation. A per-call
|
|
2487
|
+
* `options.inputsTransformation` overrides this field by field.
|
|
2488
|
+
*/
|
|
2489
|
+
inputsTransformation?: PayloadInputsTransformationOptions;
|
|
2485
2490
|
/**
|
|
2486
2491
|
* Voice/avatar catalog behavior. `{ preload: true }` loads the first page
|
|
2487
2492
|
* of every catalog-bound param in the background at client creation.
|
|
@@ -2521,6 +2526,18 @@ interface GenerateTextResult {
|
|
|
2521
2526
|
/** Credit usage reported by the platform — same structure as the pluggable APIs' GenAITaskResponse. */
|
|
2522
2527
|
usage?: CreditUsage;
|
|
2523
2528
|
}
|
|
2529
|
+
/** Input-transformation settings injected into the workflow payload as
|
|
2530
|
+
* `options.inputs_transformation` (GenAIOptions, alongside `drive`). */
|
|
2531
|
+
interface PayloadInputsTransformationOptions {
|
|
2532
|
+
/**
|
|
2533
|
+
* Downscale input images that exceed the vendor's download size cap
|
|
2534
|
+
* (e.g. ByteDance's 30 MiB) and retry the generation once, instead of
|
|
2535
|
+
* failing with an input-limit error. Opt-in — defaults to false, so an
|
|
2536
|
+
* oversized input fails fast unless you set this; workers without input
|
|
2537
|
+
* transformation ignore it.
|
|
2538
|
+
*/
|
|
2539
|
+
downscaleOversizedImages?: boolean;
|
|
2540
|
+
}
|
|
2524
2541
|
/** Options for individual generate() / submit() calls. */
|
|
2525
2542
|
interface GenerateOptions {
|
|
2526
2543
|
signal?: AbortSignal;
|
|
@@ -2539,6 +2556,10 @@ interface GenerateOptions {
|
|
|
2539
2556
|
folder?: DriveFolder;
|
|
2540
2557
|
/** Save result to Picsart Drive via backend. Injected into the workflow payload. */
|
|
2541
2558
|
drive?: PayloadDriveOptions;
|
|
2559
|
+
/** Input-transformation settings for this call — overrides the client-level
|
|
2560
|
+
* `inputsTransformation`. When neither is set, oversized-image downscaling
|
|
2561
|
+
* stays off (opt-in). */
|
|
2562
|
+
inputsTransformation?: PayloadInputsTransformationOptions;
|
|
2542
2563
|
/**
|
|
2543
2564
|
* App identity stamped onto the saved generation (appId/appType).
|
|
2544
2565
|
* TODO(backend-autosave): temporary — remove once the backend stamps these.
|
|
@@ -3043,4 +3064,4 @@ declare const findModel: (ref: string) => ModelDefinition | undefined;
|
|
|
3043
3064
|
*/
|
|
3044
3065
|
declare const KLING_DUAL_IMAGE_EFFECTS: ReadonlySet<string>;
|
|
3045
3066
|
|
|
3046
|
-
export { ALL_MODELS, type AiClient, ApiError, type ApiErrorCode, type ApiErrorInit, type ApiResponse, type ApiRunOptions, type ApiSchemas, type ApisClient, type AppIdentity, type AppType, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type CatalogDescriptor, type CatalogEntry, type CatalogItem, type CatalogKind, type CatalogPage, type CatalogPageOptions, type CatalogPreview, type CatalogQuery, type CatalogResult, type CatalogSource, type CatalogsClient, type CatalogsOptions, type ClientConfig, type CreditRange, type CreditRangeContext, type CreditTier, type CreditUsage, DEFAULT_VISIBLE_RELEASES, type DeepLinkResult, type DriveAttributes, type DriveClient, type DriveConfig, type DriveFile, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type EnumOption, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerateTextResult, type GenerationContext, type GenerationFile, type GenerationMode, KLING_DUAL_IMAGE_EFFECTS, type ListOptions, type MediaModelId, type MediaTypeFilter, Model, type ModelDefinition, type ModelDescriptor, type ModelFilter$1 as ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ObjectDescriptor, type ObjectEntry, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type PricingOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type ReleaseTag, type SaveParams, type SdkPayload, type SdkTransport, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TypedModelId, type UserReaction, type ValidationResult$1 as ValidationResult, type VoiceOption, type WorkflowJobHandle, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, toAvatarOption, toVoiceOption };
|
|
3067
|
+
export { ALL_MODELS, type AiClient, ApiError, type ApiErrorCode, type ApiErrorInit, type ApiResponse, type ApiRunOptions, type ApiSchemas, type ApisClient, type AppIdentity, type AppType, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type CatalogDescriptor, type CatalogEntry, type CatalogItem, type CatalogKind, type CatalogPage, type CatalogPageOptions, type CatalogPreview, type CatalogQuery, type CatalogResult, type CatalogSource, type CatalogsClient, type CatalogsOptions, type ClientConfig, type CreditRange, type CreditRangeContext, type CreditTier, type CreditUsage, DEFAULT_VISIBLE_RELEASES, type DeepLinkResult, type DriveAttributes, type DriveClient, type DriveConfig, type DriveFile, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type EnumOption, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerateTextResult, type GenerationContext, type GenerationFile, type GenerationMode, KLING_DUAL_IMAGE_EFFECTS, type ListOptions, type MediaModelId, type MediaTypeFilter, Model, type ModelDefinition, type ModelDescriptor, type ModelFilter$1 as ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ObjectDescriptor, type ObjectEntry, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type PayloadInputsTransformationOptions, type PricingOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type ReleaseTag, type SaveParams, type SdkPayload, type SdkTransport, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TypedModelId, type UserReaction, type ValidationResult$1 as ValidationResult, type VoiceOption, type WorkflowJobHandle, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, toAvatarOption, toVoiceOption };
|
package/index.js
CHANGED
|
@@ -10712,6 +10712,7 @@ function createClient(config) {
|
|
|
10712
10712
|
const supportsSubmit = typeof transport.submit === "function";
|
|
10713
10713
|
const apis = createApis(isConfig ? config : null);
|
|
10714
10714
|
const catalogs = createCatalogs(transport, isConfig ? config.catalogs : void 0);
|
|
10715
|
+
const inputsTransformationConfig = isConfig ? config.inputsTransformation : void 0;
|
|
10715
10716
|
const driveConfig = isConfig ? config.drive : void 0;
|
|
10716
10717
|
const driveClient = isConfig && driveConfig ? createDriveClient(resolveFetch(config), config.apiUrl, driveConfig.folder) : null;
|
|
10717
10718
|
async function executeModel(model, workflow, payload, options) {
|
|
@@ -10746,9 +10747,19 @@ function createClient(config) {
|
|
|
10746
10747
|
folder: explicit?.folder ?? (folderPath ? { path: folderPath } : void 0)
|
|
10747
10748
|
};
|
|
10748
10749
|
}
|
|
10749
|
-
function
|
|
10750
|
-
|
|
10751
|
-
|
|
10750
|
+
function injectPayloadOptions(payload, drive, inputsTransformation) {
|
|
10751
|
+
const record = payload;
|
|
10752
|
+
const existing = record.options ?? {};
|
|
10753
|
+
return {
|
|
10754
|
+
...record,
|
|
10755
|
+
options: {
|
|
10756
|
+
...existing,
|
|
10757
|
+
inputs_transformation: {
|
|
10758
|
+
downscale_oversized_images: inputsTransformation?.downscaleOversizedImages ?? inputsTransformationConfig?.downscaleOversizedImages ?? false
|
|
10759
|
+
},
|
|
10760
|
+
...drive ? { drive } : {}
|
|
10761
|
+
}
|
|
10762
|
+
};
|
|
10752
10763
|
}
|
|
10753
10764
|
return {
|
|
10754
10765
|
// ── Simple path ──────────────────────────────────────────────────
|
|
@@ -10770,7 +10781,7 @@ function createClient(config) {
|
|
|
10770
10781
|
}
|
|
10771
10782
|
const { workflow, payload, contract } = prepareRequest(resolved, params2);
|
|
10772
10783
|
const drive = buildDrivePayloadOptions(resolved, params2, options);
|
|
10773
|
-
const finalPayload =
|
|
10784
|
+
const finalPayload = injectPayloadOptions(payload, drive, options?.inputsTransformation);
|
|
10774
10785
|
const completed = await executeModel(resolved, workflow, finalPayload, options);
|
|
10775
10786
|
return parseResult(completed, resolved, contract);
|
|
10776
10787
|
},
|
|
@@ -10824,7 +10835,7 @@ function createClient(config) {
|
|
|
10824
10835
|
const resolved = resolveModel(model);
|
|
10825
10836
|
const { workflow, payload } = prepareRequest(resolved, params2);
|
|
10826
10837
|
const drive = buildDrivePayloadOptions(resolved, params2, options);
|
|
10827
|
-
const finalPayload =
|
|
10838
|
+
const finalPayload = injectPayloadOptions(payload, drive, options?.inputsTransformation);
|
|
10828
10839
|
return client.submit({ workflow, payload: finalPayload, signal: options?.signal });
|
|
10829
10840
|
},
|
|
10830
10841
|
/** Check the current status of a submitted job. */
|