@shop-os/modelkit 0.2.5 → 0.2.7
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 +7 -0
- package/dist/catalog.cjs +4 -4
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +4 -4
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +50 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -1435,7 +1435,7 @@ var VIDEO_MODELS = [
|
|
|
1435
1435
|
// reference clip keeps its own framing.
|
|
1436
1436
|
aspectRatios: [...OMNI_RATIOS],
|
|
1437
1437
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1438
|
-
references: { images: 6, videos:
|
|
1438
|
+
references: { images: 6, videos: 1 },
|
|
1439
1439
|
supports: []
|
|
1440
1440
|
},
|
|
1441
1441
|
defaults: {},
|
|
@@ -1461,7 +1461,7 @@ var VIDEO_MODELS = [
|
|
|
1461
1461
|
aspectRatios: [...OMNI_RATIOS],
|
|
1462
1462
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
1463
1463
|
durations: [3, 4, 5, 6, 7, 8, 9, 10],
|
|
1464
|
-
references: { images: 6, videos:
|
|
1464
|
+
references: { images: 6, videos: 1 },
|
|
1465
1465
|
supports: []
|
|
1466
1466
|
},
|
|
1467
1467
|
defaults: {},
|
|
@@ -1588,7 +1588,7 @@ var VIDEO_MODELS = [
|
|
|
1588
1588
|
resolutions: ["480p", "720p"],
|
|
1589
1589
|
durations: { min: 1, max: 15 },
|
|
1590
1590
|
durationPresets: [4, 6, 8, 10],
|
|
1591
|
-
references: { images:
|
|
1591
|
+
references: { images: 5 },
|
|
1592
1592
|
supports: []
|
|
1593
1593
|
},
|
|
1594
1594
|
// No resolution default: xAI picks its own unless the caller asks.
|
|
@@ -1597,7 +1597,7 @@ var VIDEO_MODELS = [
|
|
|
1597
1597
|
pricingKind: "video_per_second",
|
|
1598
1598
|
display: {
|
|
1599
1599
|
provider: "xai",
|
|
1600
|
-
description: "xAI's reference-to-video model. Generates short clips conditioned on up to
|
|
1600
|
+
description: "xAI's reference-to-video model. Generates short clips conditioned on up to 5 reference images with flexible aspect ratios.",
|
|
1601
1601
|
logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png"
|
|
1602
1602
|
},
|
|
1603
1603
|
capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
|
|
@@ -2985,7 +2985,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
|
|
|
2985
2985
|
}
|
|
2986
2986
|
|
|
2987
2987
|
// src/client.ts
|
|
2988
|
-
var
|
|
2988
|
+
var import_ai3 = require("ai");
|
|
2989
2989
|
var import_zod6 = require("zod");
|
|
2990
2990
|
|
|
2991
2991
|
// src/adapters/media-ref.ts
|
|
@@ -3067,10 +3067,12 @@ function toGeneratedImage(image) {
|
|
|
3067
3067
|
var import_anthropic = require("@ai-sdk/anthropic");
|
|
3068
3068
|
var import_google = require("@ai-sdk/google");
|
|
3069
3069
|
var import_openai = require("@ai-sdk/openai");
|
|
3070
|
+
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
3070
3071
|
var import_perplexity = require("@ai-sdk/perplexity");
|
|
3071
3072
|
var import_xai = require("@ai-sdk/xai");
|
|
3072
3073
|
var import_deepseek = require("@ai-sdk/deepseek");
|
|
3073
3074
|
var import_moonshotai = require("@ai-sdk/moonshotai");
|
|
3075
|
+
var import_ai2 = require("ai");
|
|
3074
3076
|
var import_zod5 = require("zod");
|
|
3075
3077
|
var TEXT_PROVIDERS = [
|
|
3076
3078
|
"openai",
|
|
@@ -3198,6 +3200,22 @@ function missingKey(ctx, name) {
|
|
|
3198
3200
|
retryable: false
|
|
3199
3201
|
});
|
|
3200
3202
|
}
|
|
3203
|
+
function reasoningSplitMiddleware(providerName) {
|
|
3204
|
+
return {
|
|
3205
|
+
specificationVersion: "v3",
|
|
3206
|
+
transformParams: async ({ params }) => {
|
|
3207
|
+
if (providerName !== "minimax") return params;
|
|
3208
|
+
const existing = params.providerOptions?.[providerName] ?? {};
|
|
3209
|
+
return {
|
|
3210
|
+
...params,
|
|
3211
|
+
providerOptions: {
|
|
3212
|
+
...params.providerOptions,
|
|
3213
|
+
[providerName]: { reasoning_split: true, ...existing }
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3201
3219
|
var aiSdkTextAdapter = {
|
|
3202
3220
|
id: "ai-sdk-text",
|
|
3203
3221
|
languageModel(ctx) {
|
|
@@ -3220,11 +3238,22 @@ var aiSdkTextAdapter = {
|
|
|
3220
3238
|
return (0, import_deepseek.createDeepSeek)(settings)(route2.modelId);
|
|
3221
3239
|
case "moonshot":
|
|
3222
3240
|
return (0, import_moonshotai.createMoonshotAI)(settings)(route2.modelId);
|
|
3223
|
-
case "openai-compatible":
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3241
|
+
case "openai-compatible": {
|
|
3242
|
+
const model = (0, import_openai_compatible.createOpenAICompatible)({
|
|
3243
|
+
name: route2.provider,
|
|
3244
|
+
apiKey,
|
|
3245
|
+
baseURL: route2.baseURL,
|
|
3246
|
+
fetch: ctx.fetch,
|
|
3247
|
+
...route2.headers ? { headers: route2.headers } : {}
|
|
3248
|
+
})(route2.modelId);
|
|
3249
|
+
return (0, import_ai2.wrapLanguageModel)({
|
|
3250
|
+
model,
|
|
3251
|
+
middleware: [
|
|
3252
|
+
reasoningSplitMiddleware(route2.provider),
|
|
3253
|
+
(0, import_ai2.extractReasoningMiddleware)({ tagName: "think" })
|
|
3254
|
+
]
|
|
3255
|
+
});
|
|
3256
|
+
}
|
|
3228
3257
|
case "openai":
|
|
3229
3258
|
return (0, import_openai.createOpenAI)(settings)(route2.modelId);
|
|
3230
3259
|
}
|
|
@@ -3438,7 +3467,7 @@ function createModelKit(config, adapters) {
|
|
|
3438
3467
|
logCoercions(logger, model.modelId, warnings);
|
|
3439
3468
|
const abortSignal = combineSignals(req.abortSignal, call.signal);
|
|
3440
3469
|
if (abortSignal) options.abortSignal = abortSignal;
|
|
3441
|
-
const result = await (0,
|
|
3470
|
+
const result = await (0, import_ai3.generateImage)(options);
|
|
3442
3471
|
const images = result.images.map(
|
|
3443
3472
|
(file) => toGeneratedImage({ bytes: file.uint8Array, mime: file.mediaType })
|
|
3444
3473
|
);
|
|
@@ -3520,7 +3549,7 @@ function createModelKit(config, adapters) {
|
|
|
3520
3549
|
if (providerOptions) options.providerOptions = providerOptions;
|
|
3521
3550
|
if (abortSignal) options.abortSignal = abortSignal;
|
|
3522
3551
|
logCoercions(logger, model.modelId, warnings);
|
|
3523
|
-
const pending = (0,
|
|
3552
|
+
const pending = (0, import_ai3.experimental_generateVideo)(options);
|
|
3524
3553
|
let settled;
|
|
3525
3554
|
let failed = false;
|
|
3526
3555
|
const done = pending.then(async (result) => {
|
|
@@ -3711,7 +3740,7 @@ function createModelKit(config, adapters) {
|
|
|
3711
3740
|
(model) => textTarget(model, call),
|
|
3712
3741
|
options.providerOptions
|
|
3713
3742
|
);
|
|
3714
|
-
const result = await (0,
|
|
3743
|
+
const result = await (0, import_ai3.generateText)({
|
|
3715
3744
|
...options,
|
|
3716
3745
|
...textAbortOptions(options.abortSignal, call.signal),
|
|
3717
3746
|
model: target.languageModel,
|
|
@@ -3731,7 +3760,7 @@ function createModelKit(config, adapters) {
|
|
|
3731
3760
|
options.providerOptions
|
|
3732
3761
|
);
|
|
3733
3762
|
const callerOnFinish = options.onFinish;
|
|
3734
|
-
return (0,
|
|
3763
|
+
return (0, import_ai3.streamText)({
|
|
3735
3764
|
...options,
|
|
3736
3765
|
...textAbortOptions(options.abortSignal, call.signal),
|
|
3737
3766
|
model: target.languageModel,
|
|
@@ -3753,7 +3782,7 @@ function createModelKit(config, adapters) {
|
|
|
3753
3782
|
model: languageModel2,
|
|
3754
3783
|
providerOptions: mergeTextProviderOptions(entry, options.providerOptions)
|
|
3755
3784
|
};
|
|
3756
|
-
const result = await (0,
|
|
3785
|
+
const result = await (0, import_ai3.generateObject)(sdkOptions);
|
|
3757
3786
|
await emit(withRowUnit(textUsageEvent(entry, provider, result.usage)));
|
|
3758
3787
|
return result;
|
|
3759
3788
|
},
|
|
@@ -3770,7 +3799,7 @@ function createModelKit(config, adapters) {
|
|
|
3770
3799
|
await callerOnFinish?.(event);
|
|
3771
3800
|
}
|
|
3772
3801
|
};
|
|
3773
|
-
return (0,
|
|
3802
|
+
return (0, import_ai3.streamObject)(sdkOptions);
|
|
3774
3803
|
}
|
|
3775
3804
|
};
|
|
3776
3805
|
}
|
|
@@ -5486,12 +5515,12 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
|
|
|
5486
5515
|
|
|
5487
5516
|
// src/adapters/google-image.ts
|
|
5488
5517
|
var import_google2 = require("@ai-sdk/google");
|
|
5489
|
-
var
|
|
5518
|
+
var import_ai4 = require("ai");
|
|
5490
5519
|
var import_zod11 = require("zod");
|
|
5491
5520
|
var GEMINI_IMAGE_TIMEOUT_MS = 6e5;
|
|
5492
5521
|
var defaultGoogleImageDeps = {
|
|
5493
5522
|
createGoogleClient: (opts) => (0, import_google2.createGoogleGenerativeAI)(opts),
|
|
5494
|
-
runTextGeneration: (opts) => (0,
|
|
5523
|
+
runTextGeneration: (opts) => (0, import_ai4.generateText)(opts)
|
|
5495
5524
|
};
|
|
5496
5525
|
var causeChainNodeSchema = import_zod11.z.object({
|
|
5497
5526
|
message: import_zod11.z.string().optional(),
|
|
@@ -7218,13 +7247,13 @@ async function generateReplicateAudio(req, ctx, deps) {
|
|
|
7218
7247
|
}
|
|
7219
7248
|
|
|
7220
7249
|
// src/adapters/xai-video.ts
|
|
7221
|
-
var
|
|
7250
|
+
var import_ai5 = require("ai");
|
|
7222
7251
|
var import_xai2 = require("@ai-sdk/xai");
|
|
7223
7252
|
var import_zod15 = require("zod");
|
|
7224
7253
|
var POLL_INTERVAL_MS2 = 1e4;
|
|
7225
7254
|
var POLL_TIMEOUT_MS2 = 15 * 6e4;
|
|
7226
7255
|
var defaultXaiDeps = {
|
|
7227
|
-
createXaiClient: () => ({ generateVideo:
|
|
7256
|
+
createXaiClient: () => ({ generateVideo: import_ai5.experimental_generateVideo })
|
|
7228
7257
|
};
|
|
7229
7258
|
function createXaiVideoAdapter(deps = defaultXaiDeps) {
|
|
7230
7259
|
return {
|
|
@@ -7264,7 +7293,7 @@ async function generateXaiVideo(req, ctx, deps) {
|
|
|
7264
7293
|
retryable: false
|
|
7265
7294
|
});
|
|
7266
7295
|
}
|
|
7267
|
-
const refUrls = (req.referenceImages ?? []).map(refToUrl).slice(0,
|
|
7296
|
+
const refUrls = (req.referenceImages ?? []).map(refToUrl).slice(0, 5);
|
|
7268
7297
|
const xaiOptions = {
|
|
7269
7298
|
pollIntervalMs: POLL_INTERVAL_MS2,
|
|
7270
7299
|
pollTimeoutMs: POLL_TIMEOUT_MS2
|