mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into immutable-config
This commit is contained in:
@ -862,3 +862,34 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the budget tokens for a given reasoning effort.
|
||||
* @param {number} maxTokens Maximum tokens
|
||||
* @param {string} reasoningEffort Reasoning effort
|
||||
* @param {boolean} stream If streaming is enabled
|
||||
* @returns {number} Budget tokens
|
||||
*/
|
||||
export function calculateBudgetTokens(maxTokens, reasoningEffort, stream) {
|
||||
let budgetTokens = 0;
|
||||
|
||||
switch (reasoningEffort) {
|
||||
case 'low':
|
||||
budgetTokens = Math.floor(maxTokens * 0.1);
|
||||
break;
|
||||
case 'medium':
|
||||
budgetTokens = Math.floor(maxTokens * 0.25);
|
||||
break;
|
||||
case 'high':
|
||||
budgetTokens = Math.floor(maxTokens * 0.5);
|
||||
break;
|
||||
}
|
||||
|
||||
budgetTokens = Math.max(budgetTokens, 1024);
|
||||
|
||||
if (!stream) {
|
||||
budgetTokens = Math.min(budgetTokens, 21333);
|
||||
}
|
||||
|
||||
return budgetTokens;
|
||||
}
|
||||
|
Reference in New Issue
Block a user