mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-10 00:50:43 +01:00
Send main prompt with group chat
This commit is contained in:
parent
3acd865bf8
commit
dce91f8fad
@ -432,20 +432,24 @@ PromptManagerModule.prototype.handleCharacterSelected = function (event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PromptManagerModule.prototype.handleGroupSelected = function (event) {
|
PromptManagerModule.prototype.handleGroupSelected = function (event) {
|
||||||
console.log(event.detail);
|
const characterDummy = {id: event.detail.id, group: event.detail.group};
|
||||||
|
|
||||||
const characterDummy = {id: event.detail.id};
|
|
||||||
this.activeCharacter = characterDummy;
|
this.activeCharacter = characterDummy;
|
||||||
const promptList = this.getPromptListByCharacter(characterDummy);
|
const promptList = this.getPromptListByCharacter(characterDummy);
|
||||||
console.log(promptList);
|
|
||||||
if (0 === promptList.length) this.addPromptListForCharacter(characterDummy, openAiDefaultPromptList)
|
if (0 === promptList.length) this.addPromptListForCharacter(characterDummy, openAiDefaultPromptList)
|
||||||
if (0 === this.serviceSettings.prompts.length) this.setPrompts(openAiDefaultPrompts.prompts);
|
if (0 === this.serviceSettings.prompts.length) this.setPrompts(openAiDefaultPrompts.prompts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PromptManagerModule.prototype.getActiveGroupCharacters = function() {
|
||||||
|
// ToDo: Ideally, this should return the actual characters.
|
||||||
|
return (this.activeCharacter.group?.members || []).map(member => member.substring(0, member.lastIndexOf('.')));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the prompts for a specific character. Can be filtered to only include enabled prompts.
|
* Get the prompts for a specific character. Can be filtered to only include enabled prompts.
|
||||||
* @returns {object[]} The prompts for the character.
|
* @returns {object[]} The prompts for the character.
|
||||||
* @param event
|
* @param character
|
||||||
|
* @param onlyEnabled
|
||||||
*/
|
*/
|
||||||
PromptManagerModule.prototype.getPromptsForCharacter = function (character, onlyEnabled = false) {
|
PromptManagerModule.prototype.getPromptsForCharacter = function (character, onlyEnabled = false) {
|
||||||
return this.getPromptListByCharacter(character)
|
return this.getPromptListByCharacter(character)
|
||||||
@ -535,6 +539,8 @@ PromptManagerModule.prototype.getPromptIndexById = function (identifier) {
|
|||||||
* @returns {Object} An object with "role" and "content" properties
|
* @returns {Object} An object with "role" and "content" properties
|
||||||
*/
|
*/
|
||||||
PromptManagerModule.prototype.preparePrompt = function (prompt) {
|
PromptManagerModule.prototype.preparePrompt = function (prompt) {
|
||||||
|
const groupMembers = this.getActiveGroupCharacters();
|
||||||
|
if (0 < groupMembers.length) return {role: prompt.role, content: substituteParams(prompt.content ?? '', null, null, groupMembers.join(', '))}
|
||||||
return {role: prompt.role, content: substituteParams(prompt.content ?? '')};
|
return {role: prompt.role, content: substituteParams(prompt.content ?? '')};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,7 +800,7 @@ const openAiDefaultPrompts = {
|
|||||||
"system_prompt": true,
|
"system_prompt": true,
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"calculated_tokens": 81,
|
"calculated_tokens": 81,
|
||||||
"content": "Write {{char}}'s next reply in a fictional chat between {{char}} and {{user}}. Write 1 reply only in internet RP style, italicize actions, and avoid quotation marks. Use markdown. Be proactive, creative, and drive the plot and conversation forward. Write at least 1 paragraph, up to 4. Always stay in character and avoid repetition.",
|
"content": "Write {{char}}'s next reply in a fictional chat between {{charIfNotGroup}} and {{user}}. Write 1 reply only in internet RP style, italicize actions, and avoid quotation marks. Use markdown. Be proactive, creative, and drive the plot and conversation forward. Write at least 1 paragraph, up to 4. Always stay in character and avoid repetition.",
|
||||||
"identifier": "main"
|
"identifier": "main"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -382,10 +382,7 @@ async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldIn
|
|||||||
if (selected_group) {
|
if (selected_group) {
|
||||||
const names = getGroupMembers(groups);
|
const names = getGroupMembers(groups);
|
||||||
const groupChatMessage = chatCompletion.makeSystemMessage(`[Start a new group chat. Group members: ${names}]`);
|
const groupChatMessage = chatCompletion.makeSystemMessage(`[Start a new group chat. Group members: ${names}]`);
|
||||||
const groupNudgeMessage = chatCompletion.makeSystemMessage(`[Write the next reply only as ${name2}]`);
|
|
||||||
chatCompletion.replace('newMainChat', groupChatMessage)
|
chatCompletion.replace('newMainChat', groupChatMessage)
|
||||||
chatCompletion.insertAfter('main', 'groupNudgeMessage', groupNudgeMessage);
|
|
||||||
chatCompletion.remove('main'); // ToDo: Instead of removing, the main prompt could be altered to reinforce the situation being a group scene.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle NSFW prompt
|
// Handle NSFW prompt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user