@llumiverse/drivers
Version:
LLM driver implementations. Currently supported are: openai, huggingface, bedrock, replicate.
60 lines • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveClaudeThinking = resolveClaudeThinking;
const core_1 = require("@llumiverse/core");
/**
* Resolve thinking and effort configuration for a Claude model.
*
* - Extended thinking: enabled by setting `thinking_budget_tokens`.
* - Adaptive thinking: enabled by setting `effort` on models that support it (Opus 4.6+, Sonnet 4.6+).
* - `include_thoughts`: display-only; does not enable thinking.
*
* @param model - The model identifier string
* @param options - User-provided Claude options (thinking_budget_tokens, effort, include_thoughts)
*/
function resolveClaudeThinking(model, options) {
const supportsAdaptive = (0, core_1.supportsAdaptiveThinking)(model);
const samplingRestriction = (0, core_1.hasSamplingParameterRestriction)(model);
const supportsThinking = (0, core_1.isClaudeVersionGTE)(model, 3, 7);
const budgetTokens = options?.thinking_budget_tokens;
// Adaptive thinking is active when the caller supplies an effort level on a
// model that supports it. Extended thinking is active when a budget is set.
const adaptiveEnabled = supportsAdaptive && options?.effort != null;
const extendedEnabled = budgetTokens != null;
let thinking;
if (!supportsThinking) {
// Pre-3.7 models: no thinking support
thinking = undefined;
}
else if (extendedEnabled) {
// Explicit budget — use extended thinking regardless of adaptive support.
// On adaptive models this uses the deprecated path, but user input takes priority.
thinking = {
type: "enabled",
budget_tokens: budgetTokens,
};
}
else if (supportsAdaptive) {
// Adaptive models: enable when effort is set, omit otherwise (thinking is OFF by default).
// display controls whether thinking blocks are returned; defaults to omitted.
thinking = adaptiveEnabled
? { type: "adaptive", display: options?.include_thoughts ? "summarized" : "omitted" }
: undefined;
}
else {
// Older thinking models (3.7, 4.5): no adaptive support, thinking is always disabled
// unless an explicit budget is provided (handled above).
thinking = { type: "disabled" };
}
// Output config for effort parameter (Opus 4.5+, Sonnet 4.6+, all 4.7+)
const outputConfig = options?.effort
? { effort: options.effort }
: undefined;
return {
thinking,
outputConfig,
hasSamplingRestriction: samplingRestriction,
supportsThinking,
};
}
//# sourceMappingURL=claude-thinking.js.map