revert: remove memo field logic from prompt text processing

The memo field was used in prompt text logic, but its usage
affects string merging conditions for the `formated` inside
pushPrompts(). To avoid unintended merging issues, logic
involving the memo field has been rolled back.
This commit is contained in:
poroyo
2025-05-19 19:52:07 +09:00
parent 42b2fe5486
commit bf1ea155a3

View File

@@ -400,15 +400,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{
if(currentChat.note){
unformated.authorNote.push({
role: 'system',
content: risuChatParser(currentChat.note, {chara: currentChar}),
memo: 'authornote'
content: risuChatParser(currentChat.note, {chara: currentChar})
})
}
else if(getAuthorNoteDefaultText() !== ''){
unformated.authorNote.push({
role: 'system',
content: risuChatParser(getAuthorNoteDefaultText(), {chara: currentChar}),
memo: 'authornote'
content: risuChatParser(getAuthorNoteDefaultText(), {chara: currentChar})
})
}
@@ -438,8 +436,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
unformated.description.push({
role: 'system',
content: description,
memo: 'description',
content: description
})
if(nowChatroom.type === 'group'){
@@ -460,8 +457,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
for(const lorebook of normalActives){
unformated.lorebook.push({
role: lorebook.role,
content: risuChatParser(lorebook.prompt, {chara: currentChar}),
memo: 'lore',
content: risuChatParser(lorebook.prompt, {chara: currentChar})
})
}
@@ -485,8 +481,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
if(DBState.db.personaPrompt){
unformated.personaPrompt.push({
role: 'system',
content: risuChatParser(getPersonaPrompt(), {chara: currentChar}),
memo: 'persona',
content: risuChatParser(getPersonaPrompt(), {chara: currentChar})
})
}
@@ -511,8 +506,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
for(const lorebook of postEverythingLorebooks){
unformated.postEverything.push({
role: lorebook.role,
content: risuChatParser(lorebook.prompt, {chara: currentChar}),
memo: 'postEverything',
content: risuChatParser(lorebook.prompt, {chara: currentChar})
})
}
@@ -1100,12 +1094,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{
}
}
type MemoType = 'persona' | 'description' | 'authornote' | 'supaMemory';
const promptBodyMap: Record<MemoType, string[]> = { persona: [], description: [], authornote: [], supaMemory: [] };
function pushPromptInfoBody(memo: MemoType, fmt: string) {
promptBodyMap[memo].push(risuChatParser(fmt));
}
if(promptTemplate){
const template = promptTemplate
@@ -1118,7 +1106,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
pushPromptInfoBody(card.type, card.innerFormat)
}
}
}
@@ -1133,7 +1121,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
pushPromptInfoBody(card.type, card.innerFormat)
}
}
}
@@ -1148,7 +1136,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
pushPromptInfoBody(card.type, card.innerFormat)
}
}
}
@@ -1267,7 +1255,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content)
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
pushPromptInfoBody('supaMemory', card.innerFormat)
}
}
}
@@ -1388,29 +1376,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{
return true
}
function isPromptMemo(m: string): m is MemoType {
return ['persona', 'description', 'authornote', 'supaMemory'].includes(m);
}
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
const promptBodyInfo: OpenAIChat[] = formated.flatMap(format => {
if (isPromptMemo(format.memo)) {
return promptBodyMap[format.memo].map(content => ({
role: format.role,
content,
}))
}
if (format.memo == null) {
return [format]
}
return []
})
promptInfo.promptText = promptBodyInfo
}
let result = ''
let emoChanged = false
let resendChat = false