mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-09 16:40:10 +01:00
Fill tokenizer legacy counts where possible.
This commit is contained in:
parent
9784950c54
commit
2ed1cee82e
@ -894,6 +894,25 @@ PromptManagerModule.prototype.populateTokenHandler = function(messageCollection)
|
||||
|
||||
this.tokenUsage = this.tokenHandler.getTotal();
|
||||
|
||||
// Update general token counts
|
||||
const chatHistory = messageCollection.getItemByIdentifier('chatHistory');
|
||||
const startChat = chatHistory.getCollection()[0]?.getTokens() || 0;
|
||||
const continueNudge = chatHistory.getCollection().find(message => message.identifier === 'continueNudge')?.getTokens() || 0;
|
||||
|
||||
this.tokenHandler.counts = {
|
||||
...this.tokenHandler.counts,
|
||||
...{
|
||||
'start_chat': startChat,
|
||||
'prompt': 0,
|
||||
'bias': this.tokenHandler.counts.bias ?? 0,
|
||||
'nudge': continueNudge,
|
||||
'jailbreak': this.tokenHandler.counts.jailbreak ?? 0,
|
||||
'impersonate': 0,
|
||||
'examples': this.tokenHandler.counts.dialogueExamples ?? 0,
|
||||
'conversation': this.tokenHandler.counts.chatHistory ?? 0,
|
||||
}
|
||||
};
|
||||
|
||||
this.log('Updated token cache with ' + this.tokenUsage);
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ function prepareOpenAIMessages({
|
||||
const chat = chatCompletion.getChat();
|
||||
openai_messages_count = chat.filter(x => x?.role === "user" || x?.role === "assistant")?.length || 0;
|
||||
|
||||
return [chat, false];
|
||||
return [chat, promptManager.tokenHandler.counts];
|
||||
}
|
||||
|
||||
function getGroupMembers(activeGroup) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user