refactor: Improve loadLoreBookV3Prompt activation logic and key matching

This commit is contained in:
kwaroran
2024-05-26 12:25:15 +09:00
parent f92b1ffb3b
commit 5aef62766e

View File

@@ -231,7 +231,9 @@ export async function loadLoreBookV3Prompt(){
fullWordMatching:boolean fullWordMatching:boolean
}) => { }) => {
const sliced = messages.slice(messages.length - arg.searchDepth,messages.length) const sliced = messages.slice(messages.length - arg.searchDepth,messages.length)
let mText = sliced.join(" ") + recursiveAdditionalPrompt let mText = sliced.map((msg) => {
return msg.data
}).join('||')
if(arg.regex){ if(arg.regex){
const regexString = arg.keys[0] const regexString = arg.keys[0]
if(!regexString.startsWith('/')){ if(!regexString.startsWith('/')){
@@ -254,16 +256,21 @@ export async function loadLoreBookV3Prompt(){
if(arg.fullWordMatching){ if(arg.fullWordMatching){
const splited = mText.split(' ') const splited = mText.split(' ')
return arg.keys.some((key) => { for(const key of arg.keys){
return splited.includes(key) if(splited.includes(key)){
}) return true
}
}
} }
else{ else{
mText = mText.replace(/ /g,'') mText = mText.replace(/ /g,'')
return arg.keys.some((key) => { for(const key of arg.keys){
return mText.includes(key.toLowerCase()) if(mText.includes(key)){
}) return true
}
}
} }
return false
} }