[feat] lorebook fullWordMatching
This commit is contained in:
@@ -357,4 +357,5 @@ export const languageEnglish = {
|
||||
cancel: "Cancel",
|
||||
renameFolder: "Rename Folder",
|
||||
changeFolderColor: "Change Folder Color",
|
||||
fullWordMatching: "Full Word Matching",
|
||||
}
|
||||
@@ -48,6 +48,9 @@
|
||||
<div class="flex items-center mt-4">
|
||||
<Check bind:check={$DataBase.characters[$selectedCharID].loreSettings.recursiveScanning} name={language.recursiveScanning}/>
|
||||
</div>
|
||||
<div class="flex items-center mt-4">
|
||||
<Check bind:check={$DataBase.characters[$selectedCharID].loreSettings.fullWordMatching} name={language.fullWordMatching}/>
|
||||
</div>
|
||||
<span class="text-neutral-200 mt-4 mb-2">{language.loreBookDepth}</span>
|
||||
<NumberInput size="sm" min={0} max={20} bind:value={$DataBase.characters[$selectedCharID].loreSettings.scanDepth} />
|
||||
<span class="text-neutral-200">{language.loreBookToken}</span>
|
||||
|
||||
@@ -275,7 +275,8 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array, mode?:'hub'|'
|
||||
loresettings = {
|
||||
tokenBudget:charbook.token_budget,
|
||||
scanDepth:charbook.scan_depth,
|
||||
recursiveScanning: charbook.recursive_scanning
|
||||
recursiveScanning: charbook.recursive_scanning,
|
||||
fullWordMatching: charbook?.extensions?.risu_fullWordMatching ?? false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,6 +383,9 @@ async function createBaseV2(char:character) {
|
||||
case_sensitive: caseSensitive,
|
||||
})
|
||||
}
|
||||
char.loreExt ??= {}
|
||||
|
||||
char.loreExt.risu_fullWordMatching = char.loreSettings?.fullWordMatching ?? false
|
||||
|
||||
const card:CharacterCardV2 = {
|
||||
spec: "chara_card_v2",
|
||||
|
||||
@@ -72,6 +72,7 @@ export async function loadLoreBookPrompt(){
|
||||
const currentChat = char.chats[page].message
|
||||
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
||||
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
|
||||
const fullWordMatching = char.loreSettings?.fullWordMatching ?? false
|
||||
|
||||
let activatiedPrompt: string[] = []
|
||||
|
||||
@@ -120,6 +121,7 @@ export async function loadLoreBookPrompt(){
|
||||
while(loreListUpdated){
|
||||
loreListUpdated = false
|
||||
const formatedChat = formatedChatMain + activatiedPrompt.join('').replace(rmRegex,'').toLocaleLowerCase()
|
||||
const formatedChatList = fullWordMatching ? formatedChat.split(' ') : formatedChat
|
||||
for(let i=0;i<formatedLore.length;i++){
|
||||
const lore = formatedLore[i]
|
||||
if(lore.activatied){
|
||||
@@ -141,7 +143,7 @@ export async function loadLoreBookPrompt(){
|
||||
if(Array.isArray(lore.keys)){
|
||||
for(const key of lore.keys){
|
||||
if(key){
|
||||
if(formatedChat.includes(key)){
|
||||
if(formatedChatList.includes(key)){
|
||||
firstKeyActivation = true
|
||||
break
|
||||
}
|
||||
@@ -163,7 +165,7 @@ export async function loadLoreBookPrompt(){
|
||||
continue
|
||||
}
|
||||
for(const key of lore.secondKey){
|
||||
if(formatedChat.includes(key)){
|
||||
if(formatedChatList.includes(key)){
|
||||
activatiedPrompt.push(lore.content)
|
||||
lore.activatied = true
|
||||
loreListUpdated = true
|
||||
|
||||
@@ -375,6 +375,7 @@ export interface loreSettings{
|
||||
tokenBudget: number
|
||||
scanDepth:number
|
||||
recursiveScanning: boolean
|
||||
fullWordMatching?: boolean
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user