From 9ec3b5cd14d782701144b3b63f4a379b9ec136c2 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 31 May 2023 05:30:02 +0900 Subject: [PATCH 1/5] bump version to 1.22 --- src-tauri/tauri.conf.json | 2 +- src/ts/storage/database.ts | 2 +- version.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a79a99b6..71fe803d 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "RisuAI", - "version": "1.21.2" + "version": "1.22.0" }, "tauri": { "allowlist": { diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts index 8076a2c1..ddd0a4a1 100644 --- a/src/ts/storage/database.ts +++ b/src/ts/storage/database.ts @@ -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.21.2' +export let appVer = '1.22.0' export function setDatabase(data:Database){ if(checkNullish(data.characters)){ diff --git a/version.json b/version.json index abf4c30b..aa370722 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{"version":"1.21.2"} \ No newline at end of file +{"version":"1.22.0"} \ No newline at end of file From e4d956d0d681fde97251347701a322fca2817914 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 31 May 2023 05:50:08 +0900 Subject: [PATCH 2/5] [fix] token fix --- src/ts/process/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 0c48d7e4..a694092e 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -207,7 +207,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n return (unformated[key] as OpenAIChat[]).map((d) => { return d.content }).join('\n\n') - }).join('\n\n')) + db.maxResponse) + 100 + }).join('\n\n')) + db.maxResponse) + 130 const examples = exampleMessage(currentChar) From 22c646ae5dfa478761e5ea60ace6d223957e3567 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 31 May 2023 08:33:49 +0900 Subject: [PATCH 3/5] [fix] group chat activation & talkness --- src/ts/process/group.ts | 8 +++++--- src/ts/process/index.ts | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ts/process/group.ts b/src/ts/process/group.ts index 86ed862d..5af16c31 100644 --- a/src/ts/process/group.ts +++ b/src/ts/process/group.ts @@ -56,6 +56,7 @@ export type GroupOrder = { export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] { let order:GroupOrder[] = []; + let ids:string[] = [] if (input) { const words = getWords(input) @@ -66,6 +67,7 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] { if (charNameChunks.includes(word)) { order.push(char); + ids.push(char.id) break; } } @@ -74,15 +76,15 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] { const shuffled = shuffle(chars) for (const char of shuffled) { - if(order.includes(char)){ + if(ids.includes(char.id)){ continue } - //TODO - const chance = 0.5 + const chance = char.talkness ?? 0.5 if (chance >= Math.random()) { order.push(char); + ids.push(char.id) } } diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index a694092e..5df79a20 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -79,6 +79,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n talkness: nowChatroom.characterActive[i] ? nowChatroom.characterTalks[i] : -1, index: i } + }).filter((v) => { + return v.talkness > 0 }) if(!nowChatroom.orderByOrder){ order = groupOrder(order, lastMessage?.data).filter((v) => { From 8e5df4409094028fc9d5c8b498174411ec494b92 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 31 May 2023 08:34:20 +0900 Subject: [PATCH 4/5] bump version to 1.22.1 --- src-tauri/tauri.conf.json | 2 +- src/ts/storage/database.ts | 2 +- version.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 71fe803d..410af6c3 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "RisuAI", - "version": "1.22.0" + "version": "1.22.1" }, "tauri": { "allowlist": { diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts index ddd0a4a1..0156f5d0 100644 --- a/src/ts/storage/database.ts +++ b/src/ts/storage/database.ts @@ -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.0' +export let appVer = '1.22.1' export function setDatabase(data:Database){ if(checkNullish(data.characters)){ diff --git a/version.json b/version.json index aa370722..8d9a1e92 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{"version":"1.22.0"} \ No newline at end of file +{"version":"1.22.1"} \ No newline at end of file From f7856dc4dd482b9fed400d6af2923e16d5d5146f Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 31 May 2023 10:25:53 +0900 Subject: [PATCH 5/5] [feat] added 'Use Probability Condition' in lorebook --- src-tauri/tauri.conf.json | 2 +- src/lang/en.ts | 5 ++++- src/lang/ko.ts | 4 +++- src/lib/SideBars/LoreBookData.svelte | 23 +++++++++++++++++++++-- src/ts/characterCards.ts | 15 ++++++++++++--- src/ts/process/lorebook.ts | 12 +++++++++++- src/ts/storage/database.ts | 3 ++- version.json | 2 +- 8 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 410af6c3..138f3ea1 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "RisuAI", - "version": "1.22.1" + "version": "1.22.2" }, "tauri": { "allowlist": { diff --git a/src/lang/en.ts b/src/lang/en.ts index 5dde3ac3..f3e9ace4 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -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::}}` to use as path.\n - use `{{img::}}` 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" } \ No newline at end of file diff --git a/src/lang/ko.ts b/src/lang/ko.ts index 0d20cea4..ac5bb1ca 100644 --- a/src/lang/ko.ts +++ b/src/lang/ko.ts @@ -273,5 +273,7 @@ export const languageKorean = { orderByOrder: "순서대로 말하기", removeFromGroup: "정말로 {{char}}을 그룹에서 삭제시키겠습니까?", talkness: "대화량", - active: "활성화" + active: "활성화", + loreRandomActivation: "확률 조건 사용", + activationProbability: "발동 확률" } \ No newline at end of file diff --git a/src/lib/SideBars/LoreBookData.svelte b/src/lib/SideBars/LoreBookData.svelte index d59c7f7f..0437e9ee 100644 --- a/src/lib/SideBars/LoreBookData.svelte +++ b/src/lib/SideBars/LoreBookData.svelte @@ -39,9 +39,20 @@ {#if value.selective} {language.SecondaryKeys} {language.activationKeysInfo} - + {/if} {/if} + {#if !(value.activationPercent === undefined || value.activationPercent === null)} + {language.activationProbability} + { + if(isNaN(value.activationPercent) || !value.activationPercent || value.activationPercent < 0){ + value.activationPercent = 0 + } + if(value.activationPercent > 100){ + value.activationPercent = 100 + } + }}> + {/if} {language.insertOrder} {language.prompt} @@ -50,10 +61,18 @@ {language.alwaysActive} -
+
{language.selective}
+
+ {#if value.activationPercent === undefined || value.activationPercent === null} + {value.activationPercent = 50}}/> + {:else} + {value.activationPercent = null}}/> + {/if} + {language.loreRandomActivation} +
{/if} diff --git a/src/ts/characterCards.ts b/src/ts/characterCards.ts index e35efd83..6053ade8 100644 --- a/src/ts/characterCards.ts +++ b/src/ts/characterCards.ts @@ -382,7 +382,8 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array):Promise 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, }) } diff --git a/src/ts/process/lorebook.ts b/src/ts/process/lorebook.ts index 45daba32..bbb2a6f7 100644 --- a/src/ts/process/lorebook.ts +++ b/src/ts/process/lorebook.ts @@ -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 diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts index 0156f5d0..2aa55fd9 100644 --- a/src/ts/storage/database.ts +++ b/src/ts/storage/database.ts @@ -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{ diff --git a/version.json b/version.json index 8d9a1e92..2f483bbb 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{"version":"1.22.1"} \ No newline at end of file +{"version":"1.22.2"} \ No newline at end of file