Merge pull request #986 from SillyTavern/prompt-manager-hotfix

Prompt manager hotfix
This commit is contained in:
Cohee 2023-08-20 21:27:25 +03:00 committed by GitHub
commit db9e9342fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -1164,7 +1164,6 @@ PromptManagerModule.prototype.setChatCompletion = function (chatCompletion) {
this.setMessages(messages);
this.populateTokenCounts(messages);
this.populateLegacyTokenCounts(messages);
}
/**
@ -1194,7 +1193,7 @@ PromptManagerModule.prototype.populateTokenCounts = function (messages) {
PromptManagerModule.prototype.populateLegacyTokenCounts = function (messages) {
// Update general token counts
const chatHistory = messages.getItemByIdentifier('chatHistory');
const startChat = chatHistory?.getCollection()[0].getTokens() || 0;
const startChat = chatHistory?.getCollection()[0]?.getTokens() || 0;
const continueNudge = chatHistory?.getCollection().find(message => message.identifier === 'continueNudge')?.getTokens() || 0;
this.tokenHandler.counts = {

View File

@ -489,7 +489,7 @@ function populateChatHistory(prompts, chatCompletion, type = null, cyclePrompt =
// Reserve budget for group nudge
let groupNudgeMessage = null;
if (selected_group) {
const groupNudgeMessage = new Message.fromPrompt(prompts.get('groupNudge'));
const groupNudgeMessage = Message.fromPrompt(prompts.get('groupNudge'));
chatCompletion.reserveBudget(groupNudgeMessage);
}