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:
@@ -400,15 +400,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(currentChat.note){
|
if(currentChat.note){
|
||||||
unformated.authorNote.push({
|
unformated.authorNote.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: risuChatParser(currentChat.note, {chara: currentChar}),
|
content: risuChatParser(currentChat.note, {chara: currentChar})
|
||||||
memo: 'authornote'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else if(getAuthorNoteDefaultText() !== ''){
|
else if(getAuthorNoteDefaultText() !== ''){
|
||||||
unformated.authorNote.push({
|
unformated.authorNote.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: risuChatParser(getAuthorNoteDefaultText(), {chara: currentChar}),
|
content: risuChatParser(getAuthorNoteDefaultText(), {chara: currentChar})
|
||||||
memo: 'authornote'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,8 +436,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
|
|
||||||
unformated.description.push({
|
unformated.description.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: description,
|
content: description
|
||||||
memo: 'description',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if(nowChatroom.type === 'group'){
|
if(nowChatroom.type === 'group'){
|
||||||
@@ -460,8 +457,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
for(const lorebook of normalActives){
|
for(const lorebook of normalActives){
|
||||||
unformated.lorebook.push({
|
unformated.lorebook.push({
|
||||||
role: lorebook.role,
|
role: lorebook.role,
|
||||||
content: risuChatParser(lorebook.prompt, {chara: currentChar}),
|
content: risuChatParser(lorebook.prompt, {chara: currentChar})
|
||||||
memo: 'lore',
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,8 +481,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(DBState.db.personaPrompt){
|
if(DBState.db.personaPrompt){
|
||||||
unformated.personaPrompt.push({
|
unformated.personaPrompt.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: risuChatParser(getPersonaPrompt(), {chara: currentChar}),
|
content: risuChatParser(getPersonaPrompt(), {chara: currentChar})
|
||||||
memo: 'persona',
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,8 +506,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
for(const lorebook of postEverythingLorebooks){
|
for(const lorebook of postEverythingLorebooks){
|
||||||
unformated.postEverything.push({
|
unformated.postEverything.push({
|
||||||
role: lorebook.role,
|
role: lorebook.role,
|
||||||
content: risuChatParser(lorebook.prompt, {chara: currentChar}),
|
content: risuChatParser(lorebook.prompt, {chara: currentChar})
|
||||||
memo: 'postEverything',
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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){
|
if(promptTemplate){
|
||||||
const template = 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)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|
||||||
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
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)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|
||||||
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
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 || '')
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
||||||
|
|
||||||
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
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)
|
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|
||||||
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
||||||
pushPromptInfoBody('supaMemory', card.innerFormat)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1388,29 +1376,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
return true
|
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 result = ''
|
||||||
let emoChanged = false
|
let emoChanged = false
|
||||||
let resendChat = false
|
let resendChat = false
|
||||||
|
|||||||
Reference in New Issue
Block a user