[feat] added 'Use Probability Condition' in lorebook
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "RisuAI",
|
||||
"version": "1.22.1"
|
||||
"version": "1.22.2"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
@@ -79,6 +79,7 @@ export const languageEnglish = {
|
||||
scenario: "A brief description about character's scenario. \n\n**It is not recommended to use this option. Describe it in character description instead.**",
|
||||
utilityBot: "When activated, it ignores main prompt. \n\n**It is not recommended to use this option. Modifiy system prompt instead.**",
|
||||
loreSelective: "If Selective mode is toggled, both Activation Key and Secondary key should have a match to activate the lore.",
|
||||
loreRandomActivation: "If Use Probability Condition is abled, if the lore's other conditions are all met, the lore will be activated with a set probability which is set by 'Probability' each time a chat is sent.",
|
||||
additionalAssets: "Additional assets to display in your chat. \n\n - use `{{raw::<asset name>}}` to use as path.\n - use `{{img::<asset name>}}` to use as image",
|
||||
superMemory: "SuperMemory makes your character memorize more by giving summarized data to AI.\n\n"
|
||||
+ "SuperMemory model is a model that summarizes that text. davinci is recommended, and Auxiliary models are not recommended unless it is an unfiltered model with over 2000 tokens with great summarizing skill.\n\n"
|
||||
@@ -294,5 +295,7 @@ export const languageEnglish = {
|
||||
orderByOrder: "Talk by Order",
|
||||
removeFromGroup: "Do you really want to remove {{char}} from group?",
|
||||
talkness: "Talkativeness",
|
||||
active: "Active"
|
||||
active: "Active",
|
||||
loreRandomActivation: "Use Probability Condition",
|
||||
activationProbability: "Probability"
|
||||
}
|
||||
@@ -273,5 +273,7 @@ export const languageKorean = {
|
||||
orderByOrder: "순서대로 말하기",
|
||||
removeFromGroup: "정말로 {{char}}을 그룹에서 삭제시키겠습니까?",
|
||||
talkness: "대화량",
|
||||
active: "활성화"
|
||||
active: "활성화",
|
||||
loreRandomActivation: "확률 조건 사용",
|
||||
activationProbability: "발동 확률"
|
||||
}
|
||||
@@ -39,9 +39,20 @@
|
||||
{#if value.selective}
|
||||
<span class="text-neutral-200 mt-6">{language.SecondaryKeys}</span>
|
||||
<span class="text-xs text-gray-500">{language.activationKeysInfo}</span>
|
||||
<input class="text-neutral-200 p-2 bg-transparent input-text focus:bg-selected text-sm" bind:value={value.secondkey}>
|
||||
<input class="text-neutral-200 p-2 bg-transparent input-text focus:bg-selected text-sm" bind:value={value.activationPercent} min="0" max="100">
|
||||
{/if}
|
||||
{/if}
|
||||
{#if !(value.activationPercent === undefined || value.activationPercent === null)}
|
||||
<span class="text-neutral-200 mt-6">{language.activationProbability}</span>
|
||||
<input class="text-neutral-200 p-2 bg-transparent input-text focus:bg-selected text-sm" bind:value={value.activationPercent} on:change={() => {
|
||||
if(isNaN(value.activationPercent) || !value.activationPercent || value.activationPercent < 0){
|
||||
value.activationPercent = 0
|
||||
}
|
||||
if(value.activationPercent > 100){
|
||||
value.activationPercent = 100
|
||||
}
|
||||
}}>
|
||||
{/if}
|
||||
<span class="text-neutral-200 mt-4">{language.insertOrder} <Help key="loreorder"/></span>
|
||||
<input class="text-neutral-200 p-2 bg-transparent input-text focus:bg-selected text-sm" bind:value={value.insertorder} type="number" min={0} max={1000}>
|
||||
<span class="text-neutral-200 mt-4">{language.prompt}</span>
|
||||
@@ -50,10 +61,18 @@
|
||||
<Check bind:check={value.alwaysActive}/>
|
||||
<span>{language.alwaysActive}</span>
|
||||
</div>
|
||||
<div class="flex items-center mt-2 mb-6">
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={value.selective}/>
|
||||
<span>{language.selective} <Help key="loreSelective"/></span>
|
||||
</div>
|
||||
<div class="flex items-center mt-2 mb-6">
|
||||
{#if value.activationPercent === undefined || value.activationPercent === null}
|
||||
<Check check={false} onChange={() => {value.activationPercent = 50}}/>
|
||||
{:else}
|
||||
<Check check={true} onChange={() => {value.activationPercent = null}}/>
|
||||
{/if}
|
||||
<span>{language.loreRandomActivation} <Help key="loreRandomActivation"/></span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -382,7 +382,8 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array):Promise<boole
|
||||
mode: "normal",
|
||||
alwaysActive: book.constant ?? false,
|
||||
selective: book.selective ?? false,
|
||||
extentions: {...book.extensions, risu_case_sensitive: book.case_sensitive}
|
||||
extentions: {...book.extensions, risu_case_sensitive: book.case_sensitive},
|
||||
activationPercent: book.extensions?.risu_activationPercent
|
||||
})
|
||||
}
|
||||
|
||||
@@ -450,18 +451,26 @@ export async function exportSpecV2(char:character) {
|
||||
|
||||
let charBook:charBookEntry[] = []
|
||||
for(const lore of char.globalLore){
|
||||
let ext:{
|
||||
risu_case_sensitive?: boolean;
|
||||
risu_activationPercent?: number
|
||||
} = cloneDeep(lore.extentions ?? {})
|
||||
|
||||
let caseSensitive = ext.risu_case_sensitive ?? false
|
||||
ext.risu_activationPercent = lore.activationPercent
|
||||
|
||||
charBook.push({
|
||||
keys: lore.key.split(',').map(r => r.trim()),
|
||||
secondary_keys: lore.selective ? lore.secondkey.split(',').map(r => r.trim()) : undefined,
|
||||
content: lore.content,
|
||||
extensions: lore.extentions ?? {},
|
||||
extensions: ext,
|
||||
enabled: true,
|
||||
insertion_order: lore.insertorder,
|
||||
constant: lore.alwaysActive,
|
||||
selective:lore.selective,
|
||||
name: lore.comment,
|
||||
comment: lore.comment,
|
||||
case_sensitive: lore.extentions?.risu_case_sensitive
|
||||
case_sensitive: caseSensitive,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { get } from "svelte/store";
|
||||
import {selectedCharID} from '../stores'
|
||||
import { DataBase, setDatabase, type loreBook } from "../storage/database";
|
||||
import { tokenize } from "../tokenizer";
|
||||
import { selectSingleFile } from "../util";
|
||||
import { checkNullish, selectSingleFile } from "../util";
|
||||
import { alertError, alertNormal } from "../alert";
|
||||
import { language } from "../../lang";
|
||||
import { downloadFile } from "../storage/globalApi";
|
||||
@@ -80,6 +80,16 @@ export async function loadLoreBookPrompt(){
|
||||
for (const lore of fullLore){
|
||||
if(lore){
|
||||
if(lore.key.length > 1 || lore.alwaysActive){
|
||||
if(!checkNullish(lore.activationPercent)){
|
||||
let activationPercent = lore.activationPercent
|
||||
if(isNaN(activationPercent) || !activationPercent || activationPercent < 0){
|
||||
activationPercent = 0
|
||||
}
|
||||
if(activationPercent < (Math.random() * 100)){
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
formatedLore.push({
|
||||
keys: lore.alwaysActive ? 'always' : (lore.key ?? '').replace(rmRegex, '').toLocaleLowerCase().split(',').filter((a) => {
|
||||
return a.length > 1
|
||||
|
||||
@@ -8,7 +8,7 @@ import { defaultAutoSuggestPrompt, defaultJailbreak, defaultMainPrompt } from '.
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = '1.22.1'
|
||||
export let appVer = '1.22.2'
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
if(checkNullish(data.characters)){
|
||||
@@ -283,6 +283,7 @@ export interface loreBook{
|
||||
extentions?:{
|
||||
risu_case_sensitive:boolean
|
||||
}
|
||||
activationPercent?:number
|
||||
}
|
||||
|
||||
export interface character{
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":"1.22.1"}
|
||||
{"version":"1.22.2"}
|
||||
Reference in New Issue
Block a user