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