mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-08 07:32:34 +01:00
CC: Only fit entire example dialogue blocks at once
This commit is contained in:
parent
e4dc489609
commit
a12051ee24
@ -798,9 +798,7 @@ async function populateDialogueExamples(prompts, chatCompletion, messageExamples
|
|||||||
const newExampleChat = await Message.createAsync('system', substituteParams(oai_settings.new_example_chat_prompt), 'newChat');
|
const newExampleChat = await Message.createAsync('system', substituteParams(oai_settings.new_example_chat_prompt), 'newChat');
|
||||||
for (const dialogue of [...messageExamples]) {
|
for (const dialogue of [...messageExamples]) {
|
||||||
const dialogueIndex = messageExamples.indexOf(dialogue);
|
const dialogueIndex = messageExamples.indexOf(dialogue);
|
||||||
let examplesAdded = 0;
|
const chatMessages = [];
|
||||||
|
|
||||||
if (chatCompletion.canAfford(newExampleChat)) chatCompletion.insert(newExampleChat, 'dialogueExamples');
|
|
||||||
|
|
||||||
for (let promptIndex = 0; promptIndex < dialogue.length; promptIndex++) {
|
for (let promptIndex = 0; promptIndex < dialogue.length; promptIndex++) {
|
||||||
const prompt = dialogue[promptIndex];
|
const prompt = dialogue[promptIndex];
|
||||||
@ -810,15 +808,17 @@ async function populateDialogueExamples(prompts, chatCompletion, messageExamples
|
|||||||
|
|
||||||
const chatMessage = await Message.createAsync(role, content, identifier);
|
const chatMessage = await Message.createAsync(role, content, identifier);
|
||||||
await chatMessage.setName(prompt.name);
|
await chatMessage.setName(prompt.name);
|
||||||
if (!chatCompletion.canAfford(chatMessage)) {
|
chatMessages.push(chatMessage);
|
||||||
break;
|
|
||||||
}
|
|
||||||
chatCompletion.insert(chatMessage, 'dialogueExamples');
|
|
||||||
examplesAdded++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === examplesAdded) {
|
const canAffordBlock = chatCompletion.canAfford(newExampleChat) && chatCompletion.canAffordAll(chatMessages);
|
||||||
chatCompletion.removeLastFrom('dialogueExamples');
|
if (!canAffordBlock) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
chatCompletion.insert(newExampleChat, 'dialogueExamples');
|
||||||
|
for (const chatMessage of chatMessages) {
|
||||||
|
chatCompletion.insert(chatMessage, 'dialogueExamples');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user