@shop-os/modelkit 0.2.13 → 0.2.15
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/CHANGELOG.md +16 -0
- package/README.md +31 -2
- package/dist/catalog.cjs +124 -13
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +59 -1
- package/dist/catalog.d.ts +59 -1
- package/dist/catalog.js +124 -13
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +497 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -1
- package/dist/index.d.ts +59 -1
- package/dist/index.js +496 -176
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/catalog.d.cts
CHANGED
|
@@ -22,10 +22,14 @@ type OutputFormat = "png" | "jpeg" | "webp";
|
|
|
22
22
|
type MediaRef = {
|
|
23
23
|
url: string;
|
|
24
24
|
label?: string;
|
|
25
|
+
/** Measured length of a video/audio; the kit never measures it. */
|
|
26
|
+
durationSeconds?: number;
|
|
25
27
|
} | {
|
|
26
28
|
bytes: Uint8Array;
|
|
27
29
|
mime: string;
|
|
28
30
|
label?: string;
|
|
31
|
+
/** Measured length of a video/audio; the kit never measures it. */
|
|
32
|
+
durationSeconds?: number;
|
|
29
33
|
};
|
|
30
34
|
/** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
|
|
31
35
|
interface UpscaleOptions {
|
|
@@ -157,6 +161,16 @@ interface MediaPart {
|
|
|
157
161
|
}
|
|
158
162
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
159
163
|
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
|
|
164
|
+
interface VideoSecondsLimits {
|
|
165
|
+
/** Minimum length of each reference video, in seconds. */
|
|
166
|
+
min?: number;
|
|
167
|
+
/** Maximum length of each reference video, in seconds. */
|
|
168
|
+
max?: number;
|
|
169
|
+
/** Maximum combined length of the reference videos, in seconds. */
|
|
170
|
+
total?: number;
|
|
171
|
+
/** Higher per-video minimum when `taskType` is `edit` (Seedance 2.5: 4 s). */
|
|
172
|
+
editMin?: number;
|
|
173
|
+
}
|
|
160
174
|
interface ReferenceLimits {
|
|
161
175
|
images?: number;
|
|
162
176
|
/** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
|
|
@@ -166,6 +180,8 @@ interface ReferenceLimits {
|
|
|
166
180
|
total?: number;
|
|
167
181
|
/** Provider rejects a request whose only references are audio. */
|
|
168
182
|
audioOnly?: boolean;
|
|
183
|
+
/** Per-video length caps (min/max each) and combined total for reference videos. */
|
|
184
|
+
videoSeconds?: VideoSecondsLimits;
|
|
169
185
|
}
|
|
170
186
|
interface ModelConstraints {
|
|
171
187
|
aspectRatios?: AspectRatio[];
|
|
@@ -189,6 +205,11 @@ interface ModelConstraints {
|
|
|
189
205
|
supports?: SupportedOption[];
|
|
190
206
|
/** Ratio is dropped, with a warning, when one of these inputs is present. */
|
|
191
207
|
ratioIgnoredWith?: ("firstFrame" | "sourceVideo")[];
|
|
208
|
+
/** Length limits for the source video the row edits or extends. */
|
|
209
|
+
sourceVideoSeconds?: Omit<VideoSecondsLimits, "total"> & {
|
|
210
|
+
/** The provider sends the source as a reference video, so it counts toward `references.videoSeconds.total` (Seedance). */
|
|
211
|
+
inReferenceTotal?: boolean;
|
|
212
|
+
};
|
|
192
213
|
}
|
|
193
214
|
/** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
|
|
194
215
|
type JsonPrimitive = string | number | boolean | null;
|
|
@@ -429,6 +450,11 @@ interface CallContext {
|
|
|
429
450
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
430
451
|
tier?: "pro" | "enterprise";
|
|
431
452
|
signal?: AbortSignal;
|
|
453
|
+
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
454
|
+
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
455
|
+
* Text methods use the AI SDK options.maxRetries instead.
|
|
456
|
+
*/
|
|
457
|
+
maxRetries?: number;
|
|
432
458
|
onUnsupported?: "error" | "coerce";
|
|
433
459
|
}
|
|
434
460
|
|
|
@@ -557,6 +583,12 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
557
583
|
audios: z.ZodOptional<z.ZodNumber>;
|
|
558
584
|
total: z.ZodOptional<z.ZodNumber>;
|
|
559
585
|
audioOnly: z.ZodOptional<z.ZodBoolean>;
|
|
586
|
+
videoSeconds: z.ZodOptional<z.ZodObject<{
|
|
587
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
588
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
589
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
590
|
+
editMin: z.ZodOptional<z.ZodNumber>;
|
|
591
|
+
}, z.core.$loose>>;
|
|
560
592
|
}, z.core.$loose>>;
|
|
561
593
|
requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
562
594
|
references: "references";
|
|
@@ -586,15 +618,23 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
586
618
|
firstFrame: "firstFrame";
|
|
587
619
|
sourceVideo: "sourceVideo";
|
|
588
620
|
}>>>;
|
|
621
|
+
sourceVideoSeconds: z.ZodOptional<z.ZodObject<{
|
|
622
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
623
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
624
|
+
editMin: z.ZodOptional<z.ZodNumber>;
|
|
625
|
+
inReferenceTotal: z.ZodOptional<z.ZodBoolean>;
|
|
626
|
+
}, z.core.$loose>>;
|
|
589
627
|
}, z.core.$loose>;
|
|
590
628
|
defaults: z.ZodObject<{
|
|
591
629
|
references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
592
630
|
url: z.ZodString;
|
|
593
631
|
label: z.ZodOptional<z.ZodString>;
|
|
632
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
594
633
|
}, z.core.$loose>, z.ZodObject<{
|
|
595
634
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
596
635
|
mime: z.ZodString;
|
|
597
636
|
label: z.ZodOptional<z.ZodString>;
|
|
637
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
598
638
|
}, z.core.$loose>]>>>;
|
|
599
639
|
aspectRatio: z.ZodOptional<z.ZodEnum<{
|
|
600
640
|
"1:1": "1:1";
|
|
@@ -649,50 +689,62 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
649
689
|
firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
650
690
|
url: z.ZodString;
|
|
651
691
|
label: z.ZodOptional<z.ZodString>;
|
|
692
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
652
693
|
}, z.core.$loose>, z.ZodObject<{
|
|
653
694
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
654
695
|
mime: z.ZodString;
|
|
655
696
|
label: z.ZodOptional<z.ZodString>;
|
|
697
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
656
698
|
}, z.core.$loose>]>>;
|
|
657
699
|
lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
658
700
|
url: z.ZodString;
|
|
659
701
|
label: z.ZodOptional<z.ZodString>;
|
|
702
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
660
703
|
}, z.core.$loose>, z.ZodObject<{
|
|
661
704
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
662
705
|
mime: z.ZodString;
|
|
663
706
|
label: z.ZodOptional<z.ZodString>;
|
|
707
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
664
708
|
}, z.core.$loose>]>>;
|
|
665
709
|
sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
666
710
|
url: z.ZodString;
|
|
667
711
|
label: z.ZodOptional<z.ZodString>;
|
|
712
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
668
713
|
}, z.core.$loose>, z.ZodObject<{
|
|
669
714
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
670
715
|
mime: z.ZodString;
|
|
671
716
|
label: z.ZodOptional<z.ZodString>;
|
|
717
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
672
718
|
}, z.core.$loose>]>>;
|
|
673
719
|
referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
674
720
|
url: z.ZodString;
|
|
675
721
|
label: z.ZodOptional<z.ZodString>;
|
|
722
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
676
723
|
}, z.core.$loose>, z.ZodObject<{
|
|
677
724
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
678
725
|
mime: z.ZodString;
|
|
679
726
|
label: z.ZodOptional<z.ZodString>;
|
|
727
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
680
728
|
}, z.core.$loose>]>>>;
|
|
681
729
|
referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
682
730
|
url: z.ZodString;
|
|
683
731
|
label: z.ZodOptional<z.ZodString>;
|
|
732
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
684
733
|
}, z.core.$loose>, z.ZodObject<{
|
|
685
734
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
686
735
|
mime: z.ZodString;
|
|
687
736
|
label: z.ZodOptional<z.ZodString>;
|
|
737
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
688
738
|
}, z.core.$loose>]>>>;
|
|
689
739
|
referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
690
740
|
url: z.ZodString;
|
|
691
741
|
label: z.ZodOptional<z.ZodString>;
|
|
742
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
692
743
|
}, z.core.$loose>, z.ZodObject<{
|
|
693
744
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
694
745
|
mime: z.ZodString;
|
|
695
746
|
label: z.ZodOptional<z.ZodString>;
|
|
747
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
696
748
|
}, z.core.$loose>]>>>;
|
|
697
749
|
resolution: z.ZodOptional<z.ZodEnum<{
|
|
698
750
|
"360p": "360p";
|
|
@@ -834,6 +886,12 @@ interface ResolveResult<T> {
|
|
|
834
886
|
}
|
|
835
887
|
/** Nearest supported ratio in the same orientation bucket, else nearest overall, by log distance. */
|
|
836
888
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
889
|
+
/** First length violation for the videos a request sends, as a user-facing message. */
|
|
890
|
+
declare function videoLengthViolation(model: CatalogModel, input: {
|
|
891
|
+
referenceVideos?: (number | undefined)[];
|
|
892
|
+
sourceVideo?: number;
|
|
893
|
+
taskType?: VideoRequest["taskType"];
|
|
894
|
+
}): string | undefined;
|
|
837
895
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
838
896
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
839
897
|
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
@@ -873,4 +931,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
873
931
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
874
932
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
875
933
|
|
|
876
|
-
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
|
934
|
+
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
|
package/dist/catalog.d.ts
CHANGED
|
@@ -22,10 +22,14 @@ type OutputFormat = "png" | "jpeg" | "webp";
|
|
|
22
22
|
type MediaRef = {
|
|
23
23
|
url: string;
|
|
24
24
|
label?: string;
|
|
25
|
+
/** Measured length of a video/audio; the kit never measures it. */
|
|
26
|
+
durationSeconds?: number;
|
|
25
27
|
} | {
|
|
26
28
|
bytes: Uint8Array;
|
|
27
29
|
mime: string;
|
|
28
30
|
label?: string;
|
|
31
|
+
/** Measured length of a video/audio; the kit never measures it. */
|
|
32
|
+
durationSeconds?: number;
|
|
29
33
|
};
|
|
30
34
|
/** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
|
|
31
35
|
interface UpscaleOptions {
|
|
@@ -157,6 +161,16 @@ interface MediaPart {
|
|
|
157
161
|
}
|
|
158
162
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
159
163
|
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
|
|
164
|
+
interface VideoSecondsLimits {
|
|
165
|
+
/** Minimum length of each reference video, in seconds. */
|
|
166
|
+
min?: number;
|
|
167
|
+
/** Maximum length of each reference video, in seconds. */
|
|
168
|
+
max?: number;
|
|
169
|
+
/** Maximum combined length of the reference videos, in seconds. */
|
|
170
|
+
total?: number;
|
|
171
|
+
/** Higher per-video minimum when `taskType` is `edit` (Seedance 2.5: 4 s). */
|
|
172
|
+
editMin?: number;
|
|
173
|
+
}
|
|
160
174
|
interface ReferenceLimits {
|
|
161
175
|
images?: number;
|
|
162
176
|
/** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
|
|
@@ -166,6 +180,8 @@ interface ReferenceLimits {
|
|
|
166
180
|
total?: number;
|
|
167
181
|
/** Provider rejects a request whose only references are audio. */
|
|
168
182
|
audioOnly?: boolean;
|
|
183
|
+
/** Per-video length caps (min/max each) and combined total for reference videos. */
|
|
184
|
+
videoSeconds?: VideoSecondsLimits;
|
|
169
185
|
}
|
|
170
186
|
interface ModelConstraints {
|
|
171
187
|
aspectRatios?: AspectRatio[];
|
|
@@ -189,6 +205,11 @@ interface ModelConstraints {
|
|
|
189
205
|
supports?: SupportedOption[];
|
|
190
206
|
/** Ratio is dropped, with a warning, when one of these inputs is present. */
|
|
191
207
|
ratioIgnoredWith?: ("firstFrame" | "sourceVideo")[];
|
|
208
|
+
/** Length limits for the source video the row edits or extends. */
|
|
209
|
+
sourceVideoSeconds?: Omit<VideoSecondsLimits, "total"> & {
|
|
210
|
+
/** The provider sends the source as a reference video, so it counts toward `references.videoSeconds.total` (Seedance). */
|
|
211
|
+
inReferenceTotal?: boolean;
|
|
212
|
+
};
|
|
192
213
|
}
|
|
193
214
|
/** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
|
|
194
215
|
type JsonPrimitive = string | number | boolean | null;
|
|
@@ -429,6 +450,11 @@ interface CallContext {
|
|
|
429
450
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
430
451
|
tier?: "pro" | "enterprise";
|
|
431
452
|
signal?: AbortSignal;
|
|
453
|
+
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
454
|
+
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
455
|
+
* Text methods use the AI SDK options.maxRetries instead.
|
|
456
|
+
*/
|
|
457
|
+
maxRetries?: number;
|
|
432
458
|
onUnsupported?: "error" | "coerce";
|
|
433
459
|
}
|
|
434
460
|
|
|
@@ -557,6 +583,12 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
557
583
|
audios: z.ZodOptional<z.ZodNumber>;
|
|
558
584
|
total: z.ZodOptional<z.ZodNumber>;
|
|
559
585
|
audioOnly: z.ZodOptional<z.ZodBoolean>;
|
|
586
|
+
videoSeconds: z.ZodOptional<z.ZodObject<{
|
|
587
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
588
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
589
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
590
|
+
editMin: z.ZodOptional<z.ZodNumber>;
|
|
591
|
+
}, z.core.$loose>>;
|
|
560
592
|
}, z.core.$loose>>;
|
|
561
593
|
requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
562
594
|
references: "references";
|
|
@@ -586,15 +618,23 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
586
618
|
firstFrame: "firstFrame";
|
|
587
619
|
sourceVideo: "sourceVideo";
|
|
588
620
|
}>>>;
|
|
621
|
+
sourceVideoSeconds: z.ZodOptional<z.ZodObject<{
|
|
622
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
623
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
624
|
+
editMin: z.ZodOptional<z.ZodNumber>;
|
|
625
|
+
inReferenceTotal: z.ZodOptional<z.ZodBoolean>;
|
|
626
|
+
}, z.core.$loose>>;
|
|
589
627
|
}, z.core.$loose>;
|
|
590
628
|
defaults: z.ZodObject<{
|
|
591
629
|
references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
592
630
|
url: z.ZodString;
|
|
593
631
|
label: z.ZodOptional<z.ZodString>;
|
|
632
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
594
633
|
}, z.core.$loose>, z.ZodObject<{
|
|
595
634
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
596
635
|
mime: z.ZodString;
|
|
597
636
|
label: z.ZodOptional<z.ZodString>;
|
|
637
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
598
638
|
}, z.core.$loose>]>>>;
|
|
599
639
|
aspectRatio: z.ZodOptional<z.ZodEnum<{
|
|
600
640
|
"1:1": "1:1";
|
|
@@ -649,50 +689,62 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
649
689
|
firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
650
690
|
url: z.ZodString;
|
|
651
691
|
label: z.ZodOptional<z.ZodString>;
|
|
692
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
652
693
|
}, z.core.$loose>, z.ZodObject<{
|
|
653
694
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
654
695
|
mime: z.ZodString;
|
|
655
696
|
label: z.ZodOptional<z.ZodString>;
|
|
697
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
656
698
|
}, z.core.$loose>]>>;
|
|
657
699
|
lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
658
700
|
url: z.ZodString;
|
|
659
701
|
label: z.ZodOptional<z.ZodString>;
|
|
702
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
660
703
|
}, z.core.$loose>, z.ZodObject<{
|
|
661
704
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
662
705
|
mime: z.ZodString;
|
|
663
706
|
label: z.ZodOptional<z.ZodString>;
|
|
707
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
664
708
|
}, z.core.$loose>]>>;
|
|
665
709
|
sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
666
710
|
url: z.ZodString;
|
|
667
711
|
label: z.ZodOptional<z.ZodString>;
|
|
712
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
668
713
|
}, z.core.$loose>, z.ZodObject<{
|
|
669
714
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
670
715
|
mime: z.ZodString;
|
|
671
716
|
label: z.ZodOptional<z.ZodString>;
|
|
717
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
672
718
|
}, z.core.$loose>]>>;
|
|
673
719
|
referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
674
720
|
url: z.ZodString;
|
|
675
721
|
label: z.ZodOptional<z.ZodString>;
|
|
722
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
676
723
|
}, z.core.$loose>, z.ZodObject<{
|
|
677
724
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
678
725
|
mime: z.ZodString;
|
|
679
726
|
label: z.ZodOptional<z.ZodString>;
|
|
727
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
680
728
|
}, z.core.$loose>]>>>;
|
|
681
729
|
referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
682
730
|
url: z.ZodString;
|
|
683
731
|
label: z.ZodOptional<z.ZodString>;
|
|
732
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
684
733
|
}, z.core.$loose>, z.ZodObject<{
|
|
685
734
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
686
735
|
mime: z.ZodString;
|
|
687
736
|
label: z.ZodOptional<z.ZodString>;
|
|
737
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
688
738
|
}, z.core.$loose>]>>>;
|
|
689
739
|
referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
690
740
|
url: z.ZodString;
|
|
691
741
|
label: z.ZodOptional<z.ZodString>;
|
|
742
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
692
743
|
}, z.core.$loose>, z.ZodObject<{
|
|
693
744
|
bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
694
745
|
mime: z.ZodString;
|
|
695
746
|
label: z.ZodOptional<z.ZodString>;
|
|
747
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
696
748
|
}, z.core.$loose>]>>>;
|
|
697
749
|
resolution: z.ZodOptional<z.ZodEnum<{
|
|
698
750
|
"360p": "360p";
|
|
@@ -834,6 +886,12 @@ interface ResolveResult<T> {
|
|
|
834
886
|
}
|
|
835
887
|
/** Nearest supported ratio in the same orientation bucket, else nearest overall, by log distance. */
|
|
836
888
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
889
|
+
/** First length violation for the videos a request sends, as a user-facing message. */
|
|
890
|
+
declare function videoLengthViolation(model: CatalogModel, input: {
|
|
891
|
+
referenceVideos?: (number | undefined)[];
|
|
892
|
+
sourceVideo?: number;
|
|
893
|
+
taskType?: VideoRequest["taskType"];
|
|
894
|
+
}): string | undefined;
|
|
837
895
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
838
896
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
839
897
|
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
@@ -873,4 +931,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
873
931
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
874
932
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
875
933
|
|
|
876
|
-
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
|
934
|
+
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
|
package/dist/catalog.js
CHANGED
|
@@ -126,7 +126,9 @@ function normalizeExposure(value) {
|
|
|
126
126
|
if (value === "catalog") return ["cowork", "space_builder"];
|
|
127
127
|
if (value === "internal") return [];
|
|
128
128
|
if (Array.isArray(value)) {
|
|
129
|
-
if (value.every(
|
|
129
|
+
if (value.every(
|
|
130
|
+
(entry) => SURFACES.includes(entry)
|
|
131
|
+
)) {
|
|
130
132
|
const present = new Set(value);
|
|
131
133
|
return SURFACES.filter((surface) => present.has(surface));
|
|
132
134
|
}
|
|
@@ -1360,7 +1362,8 @@ var VIDEO_MODELS = [
|
|
|
1360
1362
|
// reference clip keeps its own framing.
|
|
1361
1363
|
aspectRatios: [...OMNI_RATIOS],
|
|
1362
1364
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1363
|
-
references: { images: 6, videos: 1 },
|
|
1365
|
+
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
1366
|
+
sourceVideoSeconds: { max: 10 },
|
|
1364
1367
|
supports: []
|
|
1365
1368
|
},
|
|
1366
1369
|
defaults: {},
|
|
@@ -1386,7 +1389,8 @@ var VIDEO_MODELS = [
|
|
|
1386
1389
|
aspectRatios: [...OMNI_RATIOS],
|
|
1387
1390
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
1388
1391
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1389
|
-
references: { images: 6, videos: 1 },
|
|
1392
|
+
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
1393
|
+
sourceVideoSeconds: { max: 10 },
|
|
1390
1394
|
supports: []
|
|
1391
1395
|
},
|
|
1392
1396
|
defaults: {},
|
|
@@ -1414,7 +1418,14 @@ var VIDEO_MODELS = [
|
|
|
1414
1418
|
resolutions: ["480p", "720p", "1080p", "4k"],
|
|
1415
1419
|
durations: { min: 4, max: 15 },
|
|
1416
1420
|
durationPresets: [4, 6, 8, 10, 12, 15],
|
|
1417
|
-
references: {
|
|
1421
|
+
references: {
|
|
1422
|
+
images: 9,
|
|
1423
|
+
videos: 3,
|
|
1424
|
+
audios: 3,
|
|
1425
|
+
audioOnly: false,
|
|
1426
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1427
|
+
},
|
|
1428
|
+
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
1418
1429
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1419
1430
|
supports: ["generateAudio", "seed", "lastFrame", "watermark"]
|
|
1420
1431
|
},
|
|
@@ -1446,7 +1457,14 @@ var VIDEO_MODELS = [
|
|
|
1446
1457
|
aspectRatios: [...SEEDANCE_RATIOS],
|
|
1447
1458
|
resolutions: ["480p", "720p"],
|
|
1448
1459
|
durations: { min: 4, max: 15 },
|
|
1449
|
-
references: {
|
|
1460
|
+
references: {
|
|
1461
|
+
images: 9,
|
|
1462
|
+
videos: 3,
|
|
1463
|
+
audios: 3,
|
|
1464
|
+
audioOnly: false,
|
|
1465
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1466
|
+
},
|
|
1467
|
+
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
1450
1468
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1451
1469
|
supports: ["generateAudio", "seed", "lastFrame", "watermark"]
|
|
1452
1470
|
},
|
|
@@ -1480,7 +1498,13 @@ var VIDEO_MODELS = [
|
|
|
1480
1498
|
aspectRatios: [...SEEDANCE_RATIOS],
|
|
1481
1499
|
resolutions: ["480p", "720p", "1080p"],
|
|
1482
1500
|
durations: { min: 4, max: 30 },
|
|
1483
|
-
references: {
|
|
1501
|
+
references: {
|
|
1502
|
+
images: 30,
|
|
1503
|
+
videos: 10,
|
|
1504
|
+
audios: 10,
|
|
1505
|
+
videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 }
|
|
1506
|
+
},
|
|
1507
|
+
sourceVideoSeconds: { min: 2, max: 30, editMin: 4, inReferenceTotal: true },
|
|
1484
1508
|
ratioIgnoredWith: ["firstFrame", "sourceVideo"],
|
|
1485
1509
|
supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"]
|
|
1486
1510
|
},
|
|
@@ -1692,7 +1716,14 @@ var VIDEO_MODELS = [
|
|
|
1692
1716
|
aspectRatios: [...H3_REFERENCE_RATIOS],
|
|
1693
1717
|
resolutions: ["480p", "768p", "2k", "4k"],
|
|
1694
1718
|
durations: { min: 5, max: 15 },
|
|
1695
|
-
references: {
|
|
1719
|
+
references: {
|
|
1720
|
+
images: 9,
|
|
1721
|
+
videos: 3,
|
|
1722
|
+
audios: 3,
|
|
1723
|
+
total: 12,
|
|
1724
|
+
audioOnly: false,
|
|
1725
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1726
|
+
},
|
|
1696
1727
|
supports: ["seed", "promptExpansion", "safetyChecker"]
|
|
1697
1728
|
},
|
|
1698
1729
|
defaults: {
|
|
@@ -1723,7 +1754,14 @@ var VIDEO_MODELS = [
|
|
|
1723
1754
|
aspectRatios: [...H3_REFERENCE_RATIOS],
|
|
1724
1755
|
resolutions: ["480p", "768p"],
|
|
1725
1756
|
durations: { min: 5, max: 15 },
|
|
1726
|
-
references: {
|
|
1757
|
+
references: {
|
|
1758
|
+
images: 9,
|
|
1759
|
+
videos: 3,
|
|
1760
|
+
audios: 3,
|
|
1761
|
+
total: 12,
|
|
1762
|
+
audioOnly: false,
|
|
1763
|
+
videoSeconds: { min: 2, max: 15, total: 15 }
|
|
1764
|
+
},
|
|
1727
1765
|
supports: ["seed", "promptExpansion", "safetyChecker"]
|
|
1728
1766
|
},
|
|
1729
1767
|
defaults: {
|
|
@@ -1755,6 +1793,7 @@ var VIDEO_MODELS = [
|
|
|
1755
1793
|
aspectRatios: [...KLING_RATIOS],
|
|
1756
1794
|
durations: { min: 3, max: 10 },
|
|
1757
1795
|
requires: ["sourceVideo"],
|
|
1796
|
+
sourceVideoSeconds: { min: 3, max: 10.05 },
|
|
1758
1797
|
supports: []
|
|
1759
1798
|
},
|
|
1760
1799
|
defaults: { durationSeconds: 5, aspectRatio: "16:9" },
|
|
@@ -2111,13 +2150,20 @@ var ProviderOptionValueSchema = z2.lazy(
|
|
|
2111
2150
|
])
|
|
2112
2151
|
);
|
|
2113
2152
|
var ProviderOptionsSchema = z2.record(z2.string(), z2.record(z2.string(), ProviderOptionValueSchema));
|
|
2153
|
+
var VideoSecondsLimitsSchema = z2.looseObject({
|
|
2154
|
+
min: z2.number().optional(),
|
|
2155
|
+
max: z2.number().optional(),
|
|
2156
|
+
total: z2.number().optional(),
|
|
2157
|
+
editMin: z2.number().optional()
|
|
2158
|
+
});
|
|
2114
2159
|
var ReferenceLimitsSchema = z2.looseObject({
|
|
2115
2160
|
images: z2.number().optional(),
|
|
2116
2161
|
imagesWithVideo: z2.number().optional(),
|
|
2117
2162
|
videos: z2.number().optional(),
|
|
2118
2163
|
audios: z2.number().optional(),
|
|
2119
2164
|
total: z2.number().optional(),
|
|
2120
|
-
audioOnly: z2.boolean().optional()
|
|
2165
|
+
audioOnly: z2.boolean().optional(),
|
|
2166
|
+
videoSeconds: VideoSecondsLimitsSchema.optional()
|
|
2121
2167
|
});
|
|
2122
2168
|
var ModelConstraintsSchema = z2.looseObject({
|
|
2123
2169
|
aspectRatios: z2.array(AspectRatioSchema).optional(),
|
|
@@ -2130,14 +2176,20 @@ var ModelConstraintsSchema = z2.looseObject({
|
|
|
2130
2176
|
references: ReferenceLimitsSchema.optional(),
|
|
2131
2177
|
requires: z2.array(RequiredInputSchema).optional(),
|
|
2132
2178
|
supports: z2.array(SupportedOptionSchema).optional(),
|
|
2133
|
-
ratioIgnoredWith: z2.array(z2.enum(["firstFrame", "sourceVideo"])).optional()
|
|
2179
|
+
ratioIgnoredWith: z2.array(z2.enum(["firstFrame", "sourceVideo"])).optional(),
|
|
2180
|
+
sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: z2.boolean().optional() }).optional()
|
|
2134
2181
|
});
|
|
2135
2182
|
var MediaRefSchema = z2.union([
|
|
2136
|
-
z2.looseObject({
|
|
2183
|
+
z2.looseObject({
|
|
2184
|
+
url: z2.string(),
|
|
2185
|
+
label: z2.string().optional(),
|
|
2186
|
+
durationSeconds: z2.number().optional()
|
|
2187
|
+
}),
|
|
2137
2188
|
z2.looseObject({
|
|
2138
2189
|
bytes: z2.instanceof(Uint8Array),
|
|
2139
2190
|
mime: z2.string(),
|
|
2140
|
-
label: z2.string().optional()
|
|
2191
|
+
label: z2.string().optional(),
|
|
2192
|
+
durationSeconds: z2.number().optional()
|
|
2141
2193
|
})
|
|
2142
2194
|
]);
|
|
2143
2195
|
var ImageSafetySettingSchema = z2.looseObject({ category: z2.string(), threshold: z2.string() });
|
|
@@ -2626,6 +2678,49 @@ function trim(field, refs, limit, model, warnings) {
|
|
|
2626
2678
|
});
|
|
2627
2679
|
return refs.slice(0, limit);
|
|
2628
2680
|
}
|
|
2681
|
+
function knownLength(value) {
|
|
2682
|
+
return value !== void 0 && Number.isFinite(value) ? value : void 0;
|
|
2683
|
+
}
|
|
2684
|
+
function seconds(len, limit) {
|
|
2685
|
+
let digits = 1;
|
|
2686
|
+
while (digits < 3 && Number(len.toFixed(digits)) === limit) digits++;
|
|
2687
|
+
return len.toFixed(digits);
|
|
2688
|
+
}
|
|
2689
|
+
function effectiveMin(limits, taskType) {
|
|
2690
|
+
if (taskType !== "edit" || limits?.editMin === void 0) return limits?.min;
|
|
2691
|
+
return Math.max(limits.min ?? 0, limits.editMin);
|
|
2692
|
+
}
|
|
2693
|
+
function videoLengthViolation(model, input) {
|
|
2694
|
+
const limits = model.constraints.references?.videoSeconds;
|
|
2695
|
+
const refMin = effectiveMin(limits, input.taskType);
|
|
2696
|
+
const lengths = (input.referenceVideos ?? []).map(knownLength);
|
|
2697
|
+
if (limits?.max !== void 0) {
|
|
2698
|
+
const max = limits.max;
|
|
2699
|
+
const i = lengths.findIndex((len) => len !== void 0 && len > max);
|
|
2700
|
+
if (i >= 0)
|
|
2701
|
+
return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
|
|
2702
|
+
}
|
|
2703
|
+
if (refMin !== void 0) {
|
|
2704
|
+
const i = lengths.findIndex((len) => len !== void 0 && len < refMin);
|
|
2705
|
+
if (i >= 0)
|
|
2706
|
+
return `${model.label} takes reference videos of at least ${String(refMin)} s each; video ${i + 1} is ${seconds(lengths[i], refMin)} s.`;
|
|
2707
|
+
}
|
|
2708
|
+
const source = knownLength(input.sourceVideo);
|
|
2709
|
+
const sourceLimits = model.constraints.sourceVideoSeconds;
|
|
2710
|
+
if (limits?.total !== void 0) {
|
|
2711
|
+
const refSum = lengths.reduce((acc, len) => acc + (len ?? 0), 0);
|
|
2712
|
+
const sum = refSum + (sourceLimits?.inReferenceTotal ? source ?? 0 : 0);
|
|
2713
|
+
if (sum > limits.total)
|
|
2714
|
+
return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
|
|
2715
|
+
}
|
|
2716
|
+
if (source === void 0) return void 0;
|
|
2717
|
+
const sourceMin = effectiveMin(sourceLimits, input.taskType);
|
|
2718
|
+
if (sourceLimits?.max !== void 0 && source > sourceLimits.max)
|
|
2719
|
+
return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
|
|
2720
|
+
if (sourceMin !== void 0 && source < sourceMin)
|
|
2721
|
+
return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;
|
|
2722
|
+
return void 0;
|
|
2723
|
+
}
|
|
2629
2724
|
function resolveImageOptions(model, request, onUnsupported = "error") {
|
|
2630
2725
|
const warnings = [];
|
|
2631
2726
|
const c = model.constraints;
|
|
@@ -2811,6 +2906,21 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
2811
2906
|
model: model.id
|
|
2812
2907
|
});
|
|
2813
2908
|
}
|
|
2909
|
+
const lengthViolation = videoLengthViolation(model, {
|
|
2910
|
+
referenceVideos: videos.map((v) => v.durationSeconds),
|
|
2911
|
+
taskType: merged.taskType,
|
|
2912
|
+
...merged.sourceVideo?.durationSeconds !== void 0 && {
|
|
2913
|
+
sourceVideo: merged.sourceVideo.durationSeconds
|
|
2914
|
+
}
|
|
2915
|
+
});
|
|
2916
|
+
if (lengthViolation !== void 0) {
|
|
2917
|
+
throw new ModelKitError({
|
|
2918
|
+
code: "unsupported_option",
|
|
2919
|
+
message: lengthViolation,
|
|
2920
|
+
model: model.id,
|
|
2921
|
+
retryable: false
|
|
2922
|
+
});
|
|
2923
|
+
}
|
|
2814
2924
|
setOrDelete(merged, "referenceImages", images);
|
|
2815
2925
|
setOrDelete(merged, "referenceVideos", videos);
|
|
2816
2926
|
setOrDelete(merged, "referenceAudios", audios);
|
|
@@ -2926,6 +3036,7 @@ export {
|
|
|
2926
3036
|
resolveImageOptions,
|
|
2927
3037
|
resolveOptions,
|
|
2928
3038
|
resolveVideoOptions,
|
|
2929
|
-
sortCatalogRows
|
|
3039
|
+
sortCatalogRows,
|
|
3040
|
+
videoLengthViolation
|
|
2930
3041
|
};
|
|
2931
3042
|
//# sourceMappingURL=catalog.js.map
|