@shop-os/modelkit 0.2.25 → 0.2.26
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 +8 -0
- package/README.md +5 -2
- package/dist/catalog.cjs +18 -2
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +18 -2
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +26 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -890,8 +890,9 @@ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
|
|
|
890
890
|
declare const CatalogSchema: z.ZodType<CatalogModel[]>;
|
|
891
891
|
|
|
892
892
|
declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
|
|
893
|
+
declare const IMAGE_INPUT_SPEC_KEYS: readonly ["prompt", "references", "aspectRatio", "size", "outputFormat", "seed"];
|
|
893
894
|
declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
|
|
894
|
-
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
895
|
+
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
895
896
|
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
896
897
|
declare const InputSpecSchema: z.ZodObject<{
|
|
897
898
|
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
@@ -1243,4 +1244,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1243
1244
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1244
1245
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1245
1246
|
|
|
1246
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 GeneratedImage, 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, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
|
1247
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 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, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -890,8 +890,9 @@ declare const CatalogModelSchema: z.ZodType<CatalogModel>;
|
|
|
890
890
|
declare const CatalogSchema: z.ZodType<CatalogModel[]>;
|
|
891
891
|
|
|
892
892
|
declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
|
|
893
|
+
declare const IMAGE_INPUT_SPEC_KEYS: readonly ["prompt", "references", "aspectRatio", "size", "outputFormat", "seed"];
|
|
893
894
|
declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
|
|
894
|
-
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
895
|
+
type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
|
|
895
896
|
declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
|
|
896
897
|
declare const InputSpecSchema: z.ZodObject<{
|
|
897
898
|
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
@@ -1243,4 +1244,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1243
1244
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1244
1245
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1245
1246
|
|
|
1246
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 GeneratedImage, 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, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
|
1247
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, 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 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, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
package/dist/index.js
CHANGED
|
@@ -2093,6 +2093,14 @@ var VIDEO_INPUT_SPEC_KEYS = [
|
|
|
2093
2093
|
"promptExpansion",
|
|
2094
2094
|
"referenceImages"
|
|
2095
2095
|
];
|
|
2096
|
+
var IMAGE_INPUT_SPEC_KEYS = [
|
|
2097
|
+
"prompt",
|
|
2098
|
+
"references",
|
|
2099
|
+
"aspectRatio",
|
|
2100
|
+
"size",
|
|
2101
|
+
"outputFormat",
|
|
2102
|
+
"seed"
|
|
2103
|
+
];
|
|
2096
2104
|
var AUDIO_INPUT_SPEC_KEYS = [
|
|
2097
2105
|
"prompt",
|
|
2098
2106
|
"durationSeconds",
|
|
@@ -2109,14 +2117,22 @@ var INPUT_SPEC_SUPPORTS_KEYS = [
|
|
|
2109
2117
|
"generateAudio",
|
|
2110
2118
|
"cfgScale",
|
|
2111
2119
|
"promptExpansion",
|
|
2120
|
+
"outputFormat",
|
|
2112
2121
|
"instrumental"
|
|
2113
2122
|
];
|
|
2114
2123
|
var VIDEO_KEY_SET = new Set(VIDEO_INPUT_SPEC_KEYS);
|
|
2124
|
+
var IMAGE_KEY_SET = new Set(IMAGE_INPUT_SPEC_KEYS);
|
|
2115
2125
|
var AUDIO_KEY_SET = new Set(AUDIO_INPUT_SPEC_KEYS);
|
|
2116
2126
|
var ALL_KEY_SET = /* @__PURE__ */ new Set([
|
|
2117
2127
|
...VIDEO_INPUT_SPEC_KEYS,
|
|
2128
|
+
...IMAGE_INPUT_SPEC_KEYS,
|
|
2118
2129
|
...AUDIO_INPUT_SPEC_KEYS
|
|
2119
2130
|
]);
|
|
2131
|
+
var ALLOWED_KEYS_BY_TYPE = /* @__PURE__ */ new Map([
|
|
2132
|
+
["video", VIDEO_KEY_SET],
|
|
2133
|
+
["image", IMAGE_KEY_SET],
|
|
2134
|
+
["audio", AUDIO_KEY_SET]
|
|
2135
|
+
]);
|
|
2120
2136
|
var ProviderScalarSchema = z2.union([z2.string(), z2.number(), z2.boolean()]);
|
|
2121
2137
|
var FieldsSchema = z2.record(z2.string(), z2.string().min(1)).superRefine((fields, ctx) => {
|
|
2122
2138
|
const keys = Object.keys(fields);
|
|
@@ -2185,13 +2201,13 @@ function validateInputSpec(raw, row) {
|
|
|
2185
2201
|
};
|
|
2186
2202
|
}
|
|
2187
2203
|
const issues = [];
|
|
2188
|
-
|
|
2204
|
+
const allowed = ALLOWED_KEYS_BY_TYPE.get(row.type);
|
|
2205
|
+
if (allowed === void 0) {
|
|
2189
2206
|
issues.push({
|
|
2190
2207
|
path: [],
|
|
2191
2208
|
message: `inputSpec is not supported for "${row.type}" rows`
|
|
2192
2209
|
});
|
|
2193
2210
|
} else {
|
|
2194
|
-
const allowed = row.type === "video" ? VIDEO_KEY_SET : AUDIO_KEY_SET;
|
|
2195
2211
|
for (const key of Object.keys(spec.fields)) {
|
|
2196
2212
|
if (!allowed.has(key)) {
|
|
2197
2213
|
issues.push({
|
|
@@ -6735,6 +6751,12 @@ async function generateReplicateImage(req, ctx, deps) {
|
|
|
6735
6751
|
break;
|
|
6736
6752
|
}
|
|
6737
6753
|
default: {
|
|
6754
|
+
const specResult = replicateInputSpec(req, ctx);
|
|
6755
|
+
if (specResult.kind === "invalid") throw replicateInvalidSpec(ctx, specResult.issues);
|
|
6756
|
+
if (specResult.kind === "ok") {
|
|
6757
|
+
input = specResult.input;
|
|
6758
|
+
break;
|
|
6759
|
+
}
|
|
6738
6760
|
const first = (req.references ?? [])[0];
|
|
6739
6761
|
const imageInput = { prompt: req.prompt };
|
|
6740
6762
|
if (first) imageInput.image = refToUrl(first);
|
|
@@ -8815,6 +8837,7 @@ export {
|
|
|
8815
8837
|
CatalogSchema,
|
|
8816
8838
|
DEFAULT_ADAPTERS,
|
|
8817
8839
|
ExposureSchema,
|
|
8840
|
+
IMAGE_INPUT_SPEC_KEYS,
|
|
8818
8841
|
INPUT_SPEC_SUPPORTS_KEYS,
|
|
8819
8842
|
InputSpecSchema,
|
|
8820
8843
|
JsonObjectSchema,
|