@jhzhu89/m2r 0.1.9 → 0.1.10
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.js +23 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16097,15 +16097,10 @@ var init_validate = __esm(() => {
|
|
|
16097
16097
|
exports_external.object({ type: exports_external.literal("any") }),
|
|
16098
16098
|
exports_external.object({ type: exports_external.literal("tool"), name: exports_external.string() })
|
|
16099
16099
|
]);
|
|
16100
|
-
thinking = exports_external.
|
|
16101
|
-
exports_external.
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
}),
|
|
16105
|
-
exports_external.object({
|
|
16106
|
-
type: exports_external.literal("disabled")
|
|
16107
|
-
})
|
|
16108
|
-
]);
|
|
16100
|
+
thinking = exports_external.object({
|
|
16101
|
+
type: exports_external.string(),
|
|
16102
|
+
budget_tokens: exports_external.number().optional()
|
|
16103
|
+
});
|
|
16109
16104
|
schema = exports_external.object({
|
|
16110
16105
|
model: exports_external.string(),
|
|
16111
16106
|
messages: exports_external.array(message),
|
|
@@ -16119,6 +16114,7 @@ var init_validate = __esm(() => {
|
|
|
16119
16114
|
stop_sequences: exports_external.array(exports_external.string()).optional(),
|
|
16120
16115
|
tool_choice: toolChoice.optional(),
|
|
16121
16116
|
thinking: thinking.optional(),
|
|
16117
|
+
output_config: exports_external.object({ effort: exports_external.enum(["low", "medium", "high", "max"]).optional() }).optional(),
|
|
16122
16118
|
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
16123
16119
|
});
|
|
16124
16120
|
countTokensSchema = exports_external.object({
|
|
@@ -16150,11 +16146,26 @@ function parseToolChoice(tc) {
|
|
|
16150
16146
|
}
|
|
16151
16147
|
return;
|
|
16152
16148
|
}
|
|
16153
|
-
function
|
|
16149
|
+
function budgetToEffort(budget) {
|
|
16150
|
+
if (budget <= 4000)
|
|
16151
|
+
return "low";
|
|
16152
|
+
if (budget <= 16000)
|
|
16153
|
+
return "medium";
|
|
16154
|
+
return "high";
|
|
16155
|
+
}
|
|
16156
|
+
function parseThinking(t, outputEffort) {
|
|
16157
|
+
const effort = outputEffort === "max" ? "high" : outputEffort;
|
|
16154
16158
|
if (!isRecord(t))
|
|
16155
16159
|
return;
|
|
16156
16160
|
if (t.type === "enabled" && typeof t.budget_tokens === "number") {
|
|
16157
|
-
return {
|
|
16161
|
+
return {
|
|
16162
|
+
type: "enabled",
|
|
16163
|
+
budgetTokens: t.budget_tokens,
|
|
16164
|
+
effort: effort ?? budgetToEffort(t.budget_tokens)
|
|
16165
|
+
};
|
|
16166
|
+
}
|
|
16167
|
+
if (t.type === "adaptive") {
|
|
16168
|
+
return { type: "enabled", budgetTokens: 0, effort };
|
|
16158
16169
|
}
|
|
16159
16170
|
return;
|
|
16160
16171
|
}
|
|
@@ -16228,7 +16239,7 @@ function fromRequest(body) {
|
|
|
16228
16239
|
topP: body.top_p,
|
|
16229
16240
|
stopSequences: body.stop_sequences,
|
|
16230
16241
|
toolChoice: parseToolChoice(body.tool_choice),
|
|
16231
|
-
thinking: parseThinking(body.thinking)
|
|
16242
|
+
thinking: parseThinking(body.thinking, body.output_config?.effort)
|
|
16232
16243
|
};
|
|
16233
16244
|
}
|
|
16234
16245
|
|