mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Refactor token counting after completion. Simplify code.
This commit is contained in:
@ -512,7 +512,7 @@ function populateDialogueExamples(prompts, chatCompletion) {
|
||||
* @param {string} options.type - The type of the chat, can be 'impersonate'.
|
||||
*/
|
||||
function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, type, cyclePrompt} = {}) {
|
||||
//Helper function for the recurring task of preparing a prompt for the chat completion
|
||||
// Helper function for the recurring task of preparing a prompt for the chat completion
|
||||
const addToChatCompletion = (source, target = null) => {
|
||||
// We need the prompts array to determine a position for the source.
|
||||
if (false === prompts.has(source)) return;
|
||||
@ -779,9 +779,8 @@ function prepareOpenAIMessages({
|
||||
chatCompletion.log(error);
|
||||
}
|
||||
} finally {
|
||||
const messages = chatCompletion.getMessages();
|
||||
if (null === promptManager.error) promptManager.populateTokenHandler(messages);
|
||||
promptManager.setMessages(messages);
|
||||
// Pass chat completion to prompt manager for inspection
|
||||
promptManager.setChatCompletion(chatCompletion);
|
||||
|
||||
// All information are up-to-date, render.
|
||||
if (false === dryRun) promptManager.render(false);
|
||||
|
Reference in New Issue
Block a user