mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-04-03 21:51:04 +02:00
Refactor addItem method of MessageCollection
This commit is contained in:
parent
4100ae9e0b
commit
d82ea66664
@ -517,7 +517,7 @@ function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, ty
|
|||||||
const prompt = prompts.get(source);
|
const prompt = prompts.get(source);
|
||||||
const index = target ? prompts.index(target) : prompts.index(source);
|
const index = target ? prompts.index(target) : prompts.index(source);
|
||||||
const collection = new MessageCollection(source);
|
const collection = new MessageCollection(source);
|
||||||
collection.addItem(Message.fromPrompt(prompt));
|
collection.add(Message.fromPrompt(prompt));
|
||||||
chatCompletion.add(collection, index);
|
chatCompletion.add(collection, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -534,7 +534,7 @@ function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, ty
|
|||||||
// Add quiet prompt to control prompts
|
// Add quiet prompt to control prompts
|
||||||
// This should always be last, even in control prompts. Add all further control prompts BEFORE this prompt
|
// This should always be last, even in control prompts. Add all further control prompts BEFORE this prompt
|
||||||
const quietPromptMessage = Message.fromPrompt(prompts.get('quietPrompt')) ?? null;
|
const quietPromptMessage = Message.fromPrompt(prompts.get('quietPrompt')) ?? null;
|
||||||
if (quietPromptMessage) controlPrompts.addItem(quietPromptMessage);
|
if (quietPromptMessage) controlPrompts.add(quietPromptMessage);
|
||||||
|
|
||||||
chatCompletion.reserveBudget(controlPrompts);
|
chatCompletion.reserveBudget(controlPrompts);
|
||||||
|
|
||||||
@ -1428,7 +1428,7 @@ class MessageCollection {
|
|||||||
* Add a new item to the collection.
|
* Add a new item to the collection.
|
||||||
* @param {Object} item - The Message or MessageCollection instance to be added.
|
* @param {Object} item - The Message or MessageCollection instance to be added.
|
||||||
*/
|
*/
|
||||||
addItem(item) {
|
add(item) {
|
||||||
this.collection.push(item);
|
this.collection.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user