@shop-os/modelkit 0.4.2 → 0.4.4
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 +12 -0
- package/README.md +1 -0
- package/dist/catalog.cjs +39 -3
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +39 -3
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +68 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +68 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1057,12 +1057,30 @@ declare const ARRAY_INPUT_SPEC_KEYS: readonly ["firstFrame", "referenceImages",
|
|
|
1057
1057
|
type ArrayInputSpecKey = (typeof ARRAY_INPUT_SPEC_KEYS)[number];
|
|
1058
1058
|
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
1059
1059
|
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
1060
|
+
/**
|
|
1061
|
+
* Sends `{ width, height }` in one provider field, computed from the request's
|
|
1062
|
+
* aspect ratio and size. `areas` is the target pixel count per size tier; the
|
|
1063
|
+
* long side is capped at `maxSide` and both sides round down to `multipleOf`.
|
|
1064
|
+
*/
|
|
1065
|
+
declare const DimensionsSchema: z.ZodObject<{
|
|
1066
|
+
field: z.ZodString;
|
|
1067
|
+
areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
1068
|
+
maxSide: z.ZodOptional<z.ZodNumber>;
|
|
1069
|
+
multipleOf: z.ZodOptional<z.ZodNumber>;
|
|
1070
|
+
}, z.core.$strict>;
|
|
1071
|
+
type InputSpecDimensions = z.infer<typeof DimensionsSchema>;
|
|
1060
1072
|
declare const InputSpecSchema: z.ZodObject<{
|
|
1061
1073
|
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1062
1074
|
values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
|
|
1063
1075
|
static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
1064
1076
|
arrays: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
1065
1077
|
editEndpoint: z.ZodOptional<z.ZodString>;
|
|
1078
|
+
dimensions: z.ZodOptional<z.ZodObject<{
|
|
1079
|
+
field: z.ZodString;
|
|
1080
|
+
areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
1081
|
+
maxSide: z.ZodOptional<z.ZodNumber>;
|
|
1082
|
+
multipleOf: z.ZodOptional<z.ZodNumber>;
|
|
1083
|
+
}, z.core.$strict>>;
|
|
1066
1084
|
}, z.core.$strict>;
|
|
1067
1085
|
type InputSpec = z.infer<typeof InputSpecSchema>;
|
|
1068
1086
|
interface InputSpecIssue {
|
|
@@ -1473,4 +1491,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1473
1491
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1474
1492
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1475
1493
|
|
|
1476
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
|
1494
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1057,12 +1057,30 @@ declare const ARRAY_INPUT_SPEC_KEYS: readonly ["firstFrame", "referenceImages",
|
|
|
1057
1057
|
type ArrayInputSpecKey = (typeof ARRAY_INPUT_SPEC_KEYS)[number];
|
|
1058
1058
|
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
1059
1059
|
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
1060
|
+
/**
|
|
1061
|
+
* Sends `{ width, height }` in one provider field, computed from the request's
|
|
1062
|
+
* aspect ratio and size. `areas` is the target pixel count per size tier; the
|
|
1063
|
+
* long side is capped at `maxSide` and both sides round down to `multipleOf`.
|
|
1064
|
+
*/
|
|
1065
|
+
declare const DimensionsSchema: z.ZodObject<{
|
|
1066
|
+
field: z.ZodString;
|
|
1067
|
+
areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
1068
|
+
maxSide: z.ZodOptional<z.ZodNumber>;
|
|
1069
|
+
multipleOf: z.ZodOptional<z.ZodNumber>;
|
|
1070
|
+
}, z.core.$strict>;
|
|
1071
|
+
type InputSpecDimensions = z.infer<typeof DimensionsSchema>;
|
|
1060
1072
|
declare const InputSpecSchema: z.ZodObject<{
|
|
1061
1073
|
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1062
1074
|
values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
|
|
1063
1075
|
static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
1064
1076
|
arrays: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
1065
1077
|
editEndpoint: z.ZodOptional<z.ZodString>;
|
|
1078
|
+
dimensions: z.ZodOptional<z.ZodObject<{
|
|
1079
|
+
field: z.ZodString;
|
|
1080
|
+
areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
1081
|
+
maxSide: z.ZodOptional<z.ZodNumber>;
|
|
1082
|
+
multipleOf: z.ZodOptional<z.ZodNumber>;
|
|
1083
|
+
}, z.core.$strict>>;
|
|
1066
1084
|
}, z.core.$strict>;
|
|
1067
1085
|
type InputSpec = z.infer<typeof InputSpecSchema>;
|
|
1068
1086
|
interface InputSpecIssue {
|
|
@@ -1473,4 +1491,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1473
1491
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1474
1492
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1475
1493
|
|
|
1476
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
|
1494
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
package/dist/index.js
CHANGED
|
@@ -2498,16 +2498,26 @@ var ArraysSchema = z2.record(z2.string().min(1), z2.array(z2.string()).min(1)).s
|
|
|
2498
2498
|
}
|
|
2499
2499
|
}
|
|
2500
2500
|
});
|
|
2501
|
+
var DimensionsSchema = z2.strictObject({
|
|
2502
|
+
field: z2.string().min(1),
|
|
2503
|
+
areas: z2.record(z2.string(), z2.number().int().positive()).refine((a) => Object.keys(a).length > 0, {
|
|
2504
|
+
message: "inputSpec.dimensions.areas must name at least one size"
|
|
2505
|
+
}),
|
|
2506
|
+
maxSide: z2.number().int().positive().optional(),
|
|
2507
|
+
multipleOf: z2.number().int().positive().optional()
|
|
2508
|
+
});
|
|
2501
2509
|
var InputSpecSchema = z2.strictObject({
|
|
2502
2510
|
fields: FieldsSchema,
|
|
2503
2511
|
values: ValuesSchema.optional(),
|
|
2504
2512
|
static: StaticSchema.optional(),
|
|
2505
2513
|
arrays: ArraysSchema.optional(),
|
|
2506
|
-
editEndpoint: z2.string().min(1).optional()
|
|
2514
|
+
editEndpoint: z2.string().min(1).optional(),
|
|
2515
|
+
dimensions: DimensionsSchema.optional()
|
|
2507
2516
|
}).superRefine((spec, ctx) => {
|
|
2508
2517
|
const mappedNames = /* @__PURE__ */ new Set([
|
|
2509
2518
|
...Object.values(spec.fields),
|
|
2510
|
-
...Object.keys(spec.arrays ?? {})
|
|
2519
|
+
...Object.keys(spec.arrays ?? {}),
|
|
2520
|
+
...spec.dimensions ? [spec.dimensions.field] : []
|
|
2511
2521
|
]);
|
|
2512
2522
|
for (const key of Object.keys(spec.static ?? {})) {
|
|
2513
2523
|
if (mappedNames.has(key)) {
|
|
@@ -2542,7 +2552,10 @@ function validateInputSpec(raw, row) {
|
|
|
2542
2552
|
return {
|
|
2543
2553
|
ok: false,
|
|
2544
2554
|
issues: [
|
|
2545
|
-
{
|
|
2555
|
+
{
|
|
2556
|
+
path: [],
|
|
2557
|
+
message: "inputSpec is only supported on replicate and fal rows"
|
|
2558
|
+
}
|
|
2546
2559
|
]
|
|
2547
2560
|
};
|
|
2548
2561
|
}
|
|
@@ -2635,6 +2648,29 @@ function validateInputSpec(raw, row) {
|
|
|
2635
2648
|
}
|
|
2636
2649
|
}
|
|
2637
2650
|
}
|
|
2651
|
+
if (spec.dimensions !== void 0) {
|
|
2652
|
+
if (row.type !== "image") {
|
|
2653
|
+
issues.push({
|
|
2654
|
+
path: ["dimensions"],
|
|
2655
|
+
message: "inputSpec.dimensions is only supported on image rows"
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
for (const key of ["aspectRatio", "size"]) {
|
|
2659
|
+
if (key in spec.fields) {
|
|
2660
|
+
issues.push({
|
|
2661
|
+
path: ["fields", key],
|
|
2662
|
+
message: `inputSpec.fields "${key}" cannot be set with inputSpec.dimensions, which sends it`
|
|
2663
|
+
});
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
const owner = seenNames.get(spec.dimensions.field);
|
|
2667
|
+
if (owner !== void 0 || spec.dimensions.field in (spec.arrays ?? {})) {
|
|
2668
|
+
issues.push({
|
|
2669
|
+
path: ["dimensions", "field"],
|
|
2670
|
+
message: `inputSpec.dimensions.field "${spec.dimensions.field}" is already a mapped provider field`
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2638
2674
|
const supports = row.constraints.supports ?? [];
|
|
2639
2675
|
for (const key of INPUT_SPEC_SUPPORTS_KEYS) {
|
|
2640
2676
|
if (supports.includes(key)) continue;
|
|
@@ -4451,11 +4487,37 @@ function applyInputSpec(spec, req, refToUrl2, opts) {
|
|
|
4451
4487
|
}
|
|
4452
4488
|
if (urls.length > 0) out[providerField] = urls;
|
|
4453
4489
|
}
|
|
4490
|
+
if (spec.dimensions !== void 0) {
|
|
4491
|
+
const dims = dimensionsFor(spec.dimensions, req);
|
|
4492
|
+
if (dims !== void 0) out[spec.dimensions.field] = dims;
|
|
4493
|
+
}
|
|
4454
4494
|
for (const [key, value] of Object.entries(spec.static ?? {})) {
|
|
4455
4495
|
out[key] = value;
|
|
4456
4496
|
}
|
|
4457
4497
|
return out;
|
|
4458
4498
|
}
|
|
4499
|
+
function dimensionsFor(dims, req) {
|
|
4500
|
+
const ratio = req.aspectRatio;
|
|
4501
|
+
const size = req.size;
|
|
4502
|
+
if (ratio === void 0 || ratio === "adaptive" || size === void 0) return void 0;
|
|
4503
|
+
const area = dims.areas[size];
|
|
4504
|
+
const match = /^(\d+):(\d+)$/.exec(ratio);
|
|
4505
|
+
if (area === void 0 || match === null) return void 0;
|
|
4506
|
+
const r = Number(match[1]) / Number(match[2]);
|
|
4507
|
+
let width = Math.sqrt(area * r);
|
|
4508
|
+
let height = width / r;
|
|
4509
|
+
const longest = Math.max(width, height);
|
|
4510
|
+
if (dims.maxSide !== void 0 && longest > dims.maxSide) {
|
|
4511
|
+
const scale = dims.maxSide / longest;
|
|
4512
|
+
width *= scale;
|
|
4513
|
+
height *= scale;
|
|
4514
|
+
}
|
|
4515
|
+
const step = dims.multipleOf ?? 1;
|
|
4516
|
+
return {
|
|
4517
|
+
width: Math.max(step, Math.floor(width / step) * step),
|
|
4518
|
+
height: Math.max(step, Math.floor(height / step) * step)
|
|
4519
|
+
};
|
|
4520
|
+
}
|
|
4459
4521
|
function resolveRowInputSpec(req, ctx) {
|
|
4460
4522
|
const raw = ctx.model.providerOptions?.["modelkit"]?.["inputSpec"];
|
|
4461
4523
|
if (raw === void 0) return { kind: "absent" };
|
|
@@ -5640,8 +5702,10 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
5640
5702
|
const apiKey = googleKey(ctx);
|
|
5641
5703
|
const modelId = ctx.model.id;
|
|
5642
5704
|
const providerModelId = ctx.model.providerModelId;
|
|
5643
|
-
const duration = req.durationSeconds ?? 10;
|
|
5644
5705
|
const extend = req.taskType === "extend";
|
|
5706
|
+
const sourceSeconds = extend ? void 0 : req.sourceVideo?.durationSeconds;
|
|
5707
|
+
const editSeconds = sourceSeconds !== void 0 && Number.isFinite(sourceSeconds) && sourceSeconds > 0 ? sourceSeconds : void 0;
|
|
5708
|
+
const duration = req.durationSeconds ?? editSeconds ?? 10;
|
|
5645
5709
|
const previousId = extend ? req.previousInteractionId : void 0;
|
|
5646
5710
|
const chained = previousId !== void 0;
|
|
5647
5711
|
for (const field of [
|