mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix user messages not being added when populating example dialogue
This commit is contained in:
@ -477,7 +477,7 @@ function populateChatHistory(prompts, chatCompletion, type = null, cyclePrompt =
|
|||||||
* @param {ChatCompletion} chatCompletion - An instance of ChatCompletion class that will be populated with the prompts.
|
* @param {ChatCompletion} chatCompletion - An instance of ChatCompletion class that will be populated with the prompts.
|
||||||
*/
|
*/
|
||||||
function populateDialogueExamples(prompts, chatCompletion) {
|
function populateDialogueExamples(prompts, chatCompletion) {
|
||||||
chatCompletion.add( new MessageCollection('dialogueExamples'), prompts.index('dialogueExamples'));
|
chatCompletion.add(new MessageCollection('dialogueExamples'), prompts.index('dialogueExamples'));
|
||||||
if (openai_msgs_example.length) {
|
if (openai_msgs_example.length) {
|
||||||
// Insert chat message examples if there's enough budget if there is enough budget left for at least one example.
|
// Insert chat message examples if there's enough budget if there is enough budget left for at least one example.
|
||||||
const dialogueExampleChat = new Message('system', oai_settings.new_example_chat_prompt, 'newChat');
|
const dialogueExampleChat = new Message('system', oai_settings.new_example_chat_prompt, 'newChat');
|
||||||
@ -488,11 +488,18 @@ function populateDialogueExamples(prompts, chatCompletion) {
|
|||||||
chatCompletion.canAfford(dialogueExample)) {
|
chatCompletion.canAfford(dialogueExample)) {
|
||||||
chatCompletion.insert(dialogueExampleChat, 'dialogueExamples');
|
chatCompletion.insert(dialogueExampleChat, 'dialogueExamples');
|
||||||
|
|
||||||
[...openai_msgs_example].forEach((prompt, index) => {
|
[...openai_msgs_example].forEach((dialogue, dialogueIndex) => {
|
||||||
const chatMessage = new Message(prompt[0]?.role || 'system', prompt[0]?.content || '', 'dialogueExamples-' + index);
|
dialogue.forEach((prompt, promptIndex) => {
|
||||||
if (chatCompletion.canAfford(chatMessage)) {
|
console.log(prompt);
|
||||||
chatCompletion.insert(chatMessage, 'dialogueExamples');
|
const role = prompt.name === 'example_assistant' ? 'assistant' : 'user';
|
||||||
}
|
const content = prompt.content || '';
|
||||||
|
const identifier = `dialogueExamples ${dialogueIndex}-${promptIndex}`;
|
||||||
|
|
||||||
|
const chatMessage = new Message(role, content, identifier);
|
||||||
|
if (chatCompletion.canAfford(chatMessage)) {
|
||||||
|
chatCompletion.insert(chatMessage, 'dialogueExamples');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user