@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.js
CHANGED
|
@@ -3114,7 +3114,15 @@ function missingKey(ctx, name) {
|
|
|
3114
3114
|
retryable: false
|
|
3115
3115
|
});
|
|
3116
3116
|
}
|
|
3117
|
-
function
|
|
3117
|
+
function minimaxDefaults(params) {
|
|
3118
|
+
return params.responseFormat?.type === "json" ? { reasoning_split: true, thinking: { type: "disabled" } } : { reasoning_split: true };
|
|
3119
|
+
}
|
|
3120
|
+
var JSON_FENCE = /^\s*```(?:json)?\s*\n?([\s\S]*?)\n?\s*```\s*$/;
|
|
3121
|
+
function stripJsonFence(text2) {
|
|
3122
|
+
const match = JSON_FENCE.exec(text2);
|
|
3123
|
+
return match?.[1] ?? text2;
|
|
3124
|
+
}
|
|
3125
|
+
function minimaxMiddleware(providerName) {
|
|
3118
3126
|
return {
|
|
3119
3127
|
specificationVersion: "v3",
|
|
3120
3128
|
transformParams: async ({ params }) => {
|
|
@@ -3124,9 +3132,19 @@ function reasoningSplitMiddleware(providerName) {
|
|
|
3124
3132
|
...params,
|
|
3125
3133
|
providerOptions: {
|
|
3126
3134
|
...params.providerOptions,
|
|
3127
|
-
[providerName]: {
|
|
3135
|
+
[providerName]: { ...minimaxDefaults(params), ...existing }
|
|
3128
3136
|
}
|
|
3129
3137
|
};
|
|
3138
|
+
},
|
|
3139
|
+
wrapGenerate: async ({ doGenerate, params }) => {
|
|
3140
|
+
const result = await doGenerate();
|
|
3141
|
+
if (providerName !== "minimax" || params.responseFormat?.type !== "json") return result;
|
|
3142
|
+
return {
|
|
3143
|
+
...result,
|
|
3144
|
+
content: result.content.map(
|
|
3145
|
+
(part) => part.type === "text" ? { ...part, text: stripJsonFence(part.text) } : part
|
|
3146
|
+
)
|
|
3147
|
+
};
|
|
3130
3148
|
}
|
|
3131
3149
|
};
|
|
3132
3150
|
}
|
|
@@ -3163,7 +3181,7 @@ var aiSdkTextAdapter = {
|
|
|
3163
3181
|
return wrapLanguageModel({
|
|
3164
3182
|
model,
|
|
3165
3183
|
middleware: [
|
|
3166
|
-
|
|
3184
|
+
minimaxMiddleware(route2.provider),
|
|
3167
3185
|
extractReasoningMiddleware({ tagName: "think" })
|
|
3168
3186
|
]
|
|
3169
3187
|
});
|