mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-08 07:32:34 +01:00
Reserve 3 extra tokens for each chat completion
This commit is contained in:
parent
6362f76812
commit
004baf7b87
@ -576,6 +576,7 @@ function populateChatCompletion(prompts, chatCompletion, { bias, quietPrompt, ty
|
|||||||
chatCompletion.add(collection, index);
|
chatCompletion.add(collection, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
chatCompletion.reserveBudget(3); // every reply is primed with <|start|>assistant<|message|>
|
||||||
// Character and world information
|
// Character and world information
|
||||||
addToChatCompletion('worldInfoBefore');
|
addToChatCompletion('worldInfoBefore');
|
||||||
addToChatCompletion('main');
|
addToChatCompletion('main');
|
||||||
@ -1761,9 +1762,12 @@ class ChatCompletion {
|
|||||||
/**
|
/**
|
||||||
* Reserves the tokens required by the given message from the token budget.
|
* Reserves the tokens required by the given message from the token budget.
|
||||||
*
|
*
|
||||||
* @param {Message|MessageCollection} message - The message whose tokens to reserve.
|
* @param {Message|MessageCollection|number} message - The message whose tokens to reserve.
|
||||||
*/
|
*/
|
||||||
reserveBudget(message) { this.decreaseTokenBudgetBy(message.getTokens()) };
|
reserveBudget(message) {
|
||||||
|
const tokens = typeof message === 'number' ? message : message.getTokens();
|
||||||
|
this.decreaseTokenBudgetBy(tokens);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees up the tokens used by the given message from the token budget.
|
* Frees up the tokens used by the given message from the token budget.
|
||||||
|
Loading…
Reference in New Issue
Block a user