increase token buffer to 2048 for safer margin
This commit is contained in:
parent
96f8edc2e7
commit
3a4952087d
1 changed files with 1 additions and 1 deletions
|
|
@ -13,7 +13,7 @@ function estimateTokens(text) {
|
|||
function calculateAvailableTokens(chatHistory, maxTokens) {
|
||||
const inputText = chatHistory.map(msg => msg.content).join('');
|
||||
const inputTokens = estimateTokens(inputText);
|
||||
const availableTokens = Math.max(100, maxTokens - inputTokens - 50); // Reserve 50 tokens buffer
|
||||
const availableTokens = Math.max(100, maxTokens - inputTokens - 2048); // Reserve 2048 tokens buffer
|
||||
console.log(`Token calculation: max=${maxTokens}, input≈${inputTokens}, available≈${availableTokens}`);
|
||||
return availableTokens;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue