@shop-os/modelkit 0.2.7 → 0.2.8
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/dist/index.cjs +21 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3200,7 +3200,15 @@ function missingKey(ctx, name) {
|
|
|
3200
3200
|
retryable: false
|
|
3201
3201
|
});
|
|
3202
3202
|
}
|
|
3203
|
-
function
|
|
3203
|
+
function minimaxDefaults(params) {
|
|
3204
|
+
return params.responseFormat?.type === "json" ? { reasoning_split: true, thinking: { type: "disabled" } } : { reasoning_split: true };
|
|
3205
|
+
}
|
|
3206
|
+
var JSON_FENCE = /^\s*```(?:json)?\s*\n?([\s\S]*?)\n?\s*```\s*$/;
|
|
3207
|
+
function stripJsonFence(text2) {
|
|
3208
|
+
const match = JSON_FENCE.exec(text2);
|
|
3209
|
+
return match?.[1] ?? text2;
|
|
3210
|
+
}
|
|
3211
|
+
function minimaxMiddleware(providerName) {
|
|
3204
3212
|
return {
|
|
3205
3213
|
specificationVersion: "v3",
|
|
3206
3214
|
transformParams: async ({ params }) => {
|
|
@@ -3210,9 +3218,19 @@ function reasoningSplitMiddleware(providerName) {
|
|
|
3210
3218
|
...params,
|
|
3211
3219
|
providerOptions: {
|
|
3212
3220
|
...params.providerOptions,
|
|
3213
|
-
[providerName]: {
|
|
3221
|
+
[providerName]: { ...minimaxDefaults(params), ...existing }
|
|
3214
3222
|
}
|
|
3215
3223
|
};
|
|
3224
|
+
},
|
|
3225
|
+
wrapGenerate: async ({ doGenerate, params }) => {
|
|
3226
|
+
const result = await doGenerate();
|
|
3227
|
+
if (providerName !== "minimax" || params.responseFormat?.type !== "json") return result;
|
|
3228
|
+
return {
|
|
3229
|
+
...result,
|
|
3230
|
+
content: result.content.map(
|
|
3231
|
+
(part) => part.type === "text" ? { ...part, text: stripJsonFence(part.text) } : part
|
|
3232
|
+
)
|
|
3233
|
+
};
|
|
3216
3234
|
}
|
|
3217
3235
|
};
|
|
3218
3236
|
}
|
|
@@ -3249,7 +3267,7 @@ var aiSdkTextAdapter = {
|
|
|
3249
3267
|
return (0, import_ai2.wrapLanguageModel)({
|
|
3250
3268
|
model,
|
|
3251
3269
|
middleware: [
|
|
3252
|
-
|
|
3270
|
+
minimaxMiddleware(route2.provider),
|
|
3253
3271
|
(0, import_ai2.extractReasoningMiddleware)({ tagName: "think" })
|
|
3254
3272
|
]
|
|
3255
3273
|
});
|