fix: avoid skipping example chats in a dialogue when close to quota
This commit is contained in:
parent
99005d6396
commit
ac0a431cbe
|
@ -818,18 +818,20 @@ function populateDialogueExamples(prompts, chatCompletion, messageExamples) {
|
|||
|
||||
if (chatCompletion.canAfford(newExampleChat)) chatCompletion.insert(newExampleChat, 'dialogueExamples');
|
||||
|
||||
dialogue.forEach((prompt, promptIndex) => {
|
||||
for (let promptIndex = 0; promptIndex < dialogue.length; promptIndex++) {
|
||||
const prompt = dialogue[promptIndex];
|
||||
const role = 'system';
|
||||
const content = prompt.content || '';
|
||||
const identifier = `dialogueExamples ${dialogueIndex}-${promptIndex}`;
|
||||
|
||||
const chatMessage = new Message(role, content, identifier);
|
||||
chatMessage.setName(prompt.name);
|
||||
if (chatCompletion.canAfford(chatMessage)) {
|
||||
chatCompletion.insert(chatMessage, 'dialogueExamples');
|
||||
examplesAdded++;
|
||||
if (!chatCompletion.canAfford(chatMessage)) {
|
||||
break;
|
||||
}
|
||||
});
|
||||
chatCompletion.insert(chatMessage, 'dialogueExamples');
|
||||
examplesAdded++;
|
||||
}
|
||||
|
||||
if (0 === examplesAdded) {
|
||||
chatCompletion.removeLastFrom('dialogueExamples');
|
||||
|
|
Loading…
Reference in New Issue