feat: add model thinking level metadata

closes #3208
This commit is contained in:
Mario Zechner
2026-05-02 01:20:01 +02:00
parent 73b7b2c564
commit 80f06d3636
28 changed files with 527 additions and 243 deletions

View File

@@ -495,11 +495,12 @@ function supportsAdaptiveThinking(modelId: string, modelName?: string): boolean
}
function mapThinkingLevelToEffort(
model: Model<"bedrock-converse-stream">,
level: SimpleStreamOptions["reasoning"],
modelId: string,
modelName?: string,
): "low" | "medium" | "high" | "xhigh" | "max" {
const candidates = getModelMatchCandidates(modelId, modelName);
const mapped = level ? model.thinkingLevelMap?.[level] : undefined;
if (typeof mapped === "string") return mapped as "low" | "medium" | "high" | "xhigh" | "max";
switch (level) {
case "minimal":
case "low":
@@ -508,14 +509,6 @@ function mapThinkingLevelToEffort(
return "medium";
case "high":
return "high";
case "xhigh":
if (candidates.some((s) => s.includes("opus-4-6"))) {
return "max";
}
if (candidates.some((s) => s.includes("opus-4-7"))) {
return "xhigh";
}
return "high";
default:
return "high";
}
@@ -892,7 +885,7 @@ function buildAdditionalModelRequestFields(
const result: Record<string, any> = supportsAdaptiveThinking(model.id, model.name)
? {
thinking: { type: "adaptive", ...(display !== undefined ? { display } : {}) },
output_config: { effort: mapThinkingLevelToEffort(options.reasoning, model.id, model.name) },
output_config: { effort: mapThinkingLevelToEffort(model, options.reasoning) },
}
: (() => {
const defaultBudgets: Record<ThinkingLevel, number> = {