@shop-os/modelkit 0.2.6 → 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/dist/index.cjs +45 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -2981,10 +2981,12 @@ function toGeneratedImage(image) {
|
|
|
2981
2981
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2982
2982
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
2983
2983
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2984
|
+
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
2984
2985
|
import { createPerplexity } from "@ai-sdk/perplexity";
|
|
2985
2986
|
import { createXai } from "@ai-sdk/xai";
|
|
2986
2987
|
import { createDeepSeek } from "@ai-sdk/deepseek";
|
|
2987
2988
|
import { createMoonshotAI } from "@ai-sdk/moonshotai";
|
|
2989
|
+
import { extractReasoningMiddleware, wrapLanguageModel } from "ai";
|
|
2988
2990
|
import { z as z5 } from "zod";
|
|
2989
2991
|
var TEXT_PROVIDERS = [
|
|
2990
2992
|
"openai",
|
|
@@ -3112,6 +3114,22 @@ function missingKey(ctx, name) {
|
|
|
3112
3114
|
retryable: false
|
|
3113
3115
|
});
|
|
3114
3116
|
}
|
|
3117
|
+
function reasoningSplitMiddleware(providerName) {
|
|
3118
|
+
return {
|
|
3119
|
+
specificationVersion: "v3",
|
|
3120
|
+
transformParams: async ({ params }) => {
|
|
3121
|
+
if (providerName !== "minimax") return params;
|
|
3122
|
+
const existing = params.providerOptions?.[providerName] ?? {};
|
|
3123
|
+
return {
|
|
3124
|
+
...params,
|
|
3125
|
+
providerOptions: {
|
|
3126
|
+
...params.providerOptions,
|
|
3127
|
+
[providerName]: { reasoning_split: true, ...existing }
|
|
3128
|
+
}
|
|
3129
|
+
};
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3115
3133
|
var aiSdkTextAdapter = {
|
|
3116
3134
|
id: "ai-sdk-text",
|
|
3117
3135
|
languageModel(ctx) {
|
|
@@ -3134,11 +3152,22 @@ var aiSdkTextAdapter = {
|
|
|
3134
3152
|
return createDeepSeek(settings)(route2.modelId);
|
|
3135
3153
|
case "moonshot":
|
|
3136
3154
|
return createMoonshotAI(settings)(route2.modelId);
|
|
3137
|
-
case "openai-compatible":
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3155
|
+
case "openai-compatible": {
|
|
3156
|
+
const model = createOpenAICompatible({
|
|
3157
|
+
name: route2.provider,
|
|
3158
|
+
apiKey,
|
|
3159
|
+
baseURL: route2.baseURL,
|
|
3160
|
+
fetch: ctx.fetch,
|
|
3161
|
+
...route2.headers ? { headers: route2.headers } : {}
|
|
3162
|
+
})(route2.modelId);
|
|
3163
|
+
return wrapLanguageModel({
|
|
3164
|
+
model,
|
|
3165
|
+
middleware: [
|
|
3166
|
+
reasoningSplitMiddleware(route2.provider),
|
|
3167
|
+
extractReasoningMiddleware({ tagName: "think" })
|
|
3168
|
+
]
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3142
3171
|
case "openai":
|
|
3143
3172
|
return createOpenAI(settings)(route2.modelId);
|
|
3144
3173
|
}
|