Skip to content

Commit 56135d4

Browse files
authored
1.107.0 (#448)
# PR Checklist - [ ] Did you check if it works normally in all models? *ignore this when it dosen't uses models* - [ ] Did you check if it works normally in all of web, local and node hosted versions? if it dosen't, did you blocked it in those versions? - [ ] Did you added a type def? # Description
2 parents 3424d01 + 73eec2f commit 56135d4

22 files changed

+181
-80
lines changed

android/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
minSdkVersion rootProject.ext.minSdkVersion
99
targetSdkVersion rootProject.ext.targetSdkVersion
1010
versionCode 2
11-
versionName "1.106.5"
11+
versionName "1.107.0"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
aaptOptions {
1414
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

android/app/release/output-metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"filters": [],
1313
"attributes": [],
1414
"versionCode": 2,
15-
"versionName": "1.106.5",
15+
"versionName": "1.107.0",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

src-tauri/tauri.conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"package": {
1010
"productName": "RisuAI",
11-
"version": "1.106.5"
11+
"version": "1.107.0"
1212
},
1313
"tauri": {
1414
"allowlist": {

src/etc/patchNote.ts

+10-42
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,16 @@
11
export const patchNote = {
2-
version: "1.106",
2+
version: "1.107",
33
content:
44
`
5-
# Update 1.106 (Character Card V3 Update 1 & Highlights)
6-
- Added Character Card V3 Support
7-
- Added Character Card V3 Export
8-
- Added Character Card V3 Import
9-
- Added Multiple character icons support
10-
- Added {{// }} CBS support
11-
- Added {{hidden_key:A}} support
12-
- Added {{reverse:B}} support
13-
- Added {{comment:B}} support
14-
- Added nickname field
15-
- Added creation date field
16-
- Added last modified date field
17-
- Added use regex field on lorebook
18-
- Rewrote lorebook system
19-
- Added decorators support
20-
- Added @@activate_only_after support
21-
- Added @@activate_only_every support
22-
- Added @@depth support
23-
- Added @@reverse_depth support
24-
- Added @@role support
25-
- Added @@@scan_depth support
26-
- Added @@is_greeting support
27-
- Added @@position support
28-
- Added @@ignore_on_max_context support
29-
- Added @@additional_keys support
30-
- Added @@exclude_keys support
31-
- Added @@activate support
32-
- Added @@dont_activate support
33-
- Added @@disable_ui_prompt support
34-
- Deprecated legacy decorators
35-
- Deprecated @@end, use @@role end instead
36-
- Deprecated @@assistant, use @@role assistant instead
37-
- Deprecated @@user, use @@role user instead
38-
- Deprecated @@system, use @@role system instead
39-
- Added Highlight system
40-
- Requires Custom Highlight API support in the browser/OS
41-
- This would enable Highlights of CBS, decorators, and more
42-
- Added Long press to close edit
43-
- Added Long press to remove recursive
44-
- Changed Regex OUT to multi-line input, rather than single line
45-
- Changed many Trigger Script fields to multi-line input, rather than single line
5+
# Update 1.107 (Things & Stuff Update)
6+
- Added custom toggle system in prompt template
7+
- Added default variable setting in prompt template and characters
8+
- Removed experimental flag from HypaMemory V2
9+
- Added HypaMemory V2 chunk size and allocation size setting
10+
- Changed old COT toggle to deprecated, dude to new custom toggle system
11+
- Fixed Supamemory summary not working when generation choices are more than 1
12+
- Fixed triggerscript not handling undefined values as null
13+
- Fixed Character Card V3 export not working or missing fields in specific cases
4614
`
4715
}
4816

src/lang/en.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export const languageEnglish = {
126126
dynamicAssetsEditDisplay: "If enabled, the dynamic assets will be applied to the Modify Display stage too. however, this can cause performance issues.",
127127
nickname: "Nickname would used be in {{char}} or <char> in chat instead of character's name if it is set.",
128128
useRegexLorebook: "If enabled, it will use regex for lorebook search, instead of string matching. it uses /regex/flags format.",
129+
customChainOfThought: "Warning: chain of thought toggle is no longer recommended to use. put chain of thought prompt in other prompt entries instead.",
130+
customPromptTemplateToggle: "Here you can define your own prompt toggles. use `<toggle variable>=<toggle name>` format, seperated by newline. for example, `cot=Toggle COT`. you can use these toggles in prompt by using `{{getglobalvar::toggle_<toggle variable>}}`. like `{{getglobalvar::toggle_cot}}`.",
131+
defaultVariables: "Here you can define your own default variables. use `<variable name>=<variable value>` format, seperated by newline. for example, `name=RisuAI`, which then can be used with trigger scripts and variables CBS like `{{getvar::A}}`, `{{setvar::A::B}}` or `{{? $A + 1}}`. if prompt template's default variable and character's default variable has same name, character's default variable will be used.",
129132
},
130133
setup: {
131134
chooseProvider: "Choose AI Provider",
@@ -607,5 +610,12 @@ export const languageEnglish = {
607610
risupresetDesc: "Risupreset format is a format specifically designed for RisuAI presets.",
608611
jsonDesc: "JSON format is a format that is easy to read and write for both humans and machines.",
609612
nickname: "Nickname",
610-
useRegexLorebook: "Use Regex"
613+
useRegexLorebook: "Use Regex",
614+
customPromptTemplateToggle: "Custom Toggles",
615+
defaultVariables: "Default Variables",
616+
hypaAllocatedTokens: "Allocated Tokens",
617+
hypaChunkSize: "Chunk Size",
618+
hypaV2Desc: "HypaMemory V2 is a long-term memory system that use both summarized data and vector search.",
619+
supaDesc: "SupaMemory is a long-term memory system that uses summarized data to AI.",
620+
hanuraiDesc: "HanuraiMemory is a memory system that uses vector search.",
611621
}

src/lib/Setting/Pages/AdvancedSettings.svelte

+12-8
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@
110110
<Help key="experimental"/>
111111
</Check>
112112
</div>
113-
<div class="flex items-center mt-4">
114-
<Check bind:check={$DataBase.chainOfThought} name={language.cot}>
115-
<Help key="chainOfThought"/><Help key="experimental"/>
116-
</Check>
117-
</div>
113+
{#if $DataBase.showUnrecommended}
114+
<div class="flex items-center mt-4">
115+
<Check bind:check={$DataBase.chainOfThought} name={language.cot}>
116+
<Help key="customChainOfThought" unrecommended/>
117+
</Check>
118+
</div>
119+
{/if}
118120
<div class="flex items-center mt-4">
119121
<Check bind:check={$DataBase.removePunctuationHypa} name={language.removePunctuationHypa}>
120122
<Help key="removePunctuationHypa"/>
@@ -132,9 +134,11 @@
132134
</Check>
133135
</div>
134136
{/if}
135-
<div class="flex items-center mt-4">
136-
<Check bind:check={$DataBase.usePlainFetch} name={language.forcePlainFetch}> <Help key="forcePlainFetch" unrecommended/></Check>
137-
</div>
137+
{#if $DataBase.showUnrecommended}
138+
<div class="flex items-center mt-4">
139+
<Check bind:check={$DataBase.usePlainFetch} name={language.forcePlainFetch}> <Help key="forcePlainFetch" unrecommended/></Check>
140+
</div>
141+
{/if}
138142
<div class="flex items-center mt-4">
139143
<Check check={$DataBase.tpo} name="Alpha DevMode" onChange={() => {
140144
// access code is "tendo"

src/lib/Setting/Pages/OtherBotSettings.svelte

+7-1
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,20 @@
238238
</SelectInput>
239239

240240
{#if $DataBase.hanuraiEnable}
241+
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.hanuraiDesc}</span>
241242
<span>Chunk Size</span>
242243
<NumberInput size="sm" marginBottom bind:value={$DataBase.hanuraiTokens} min={100} />
243244
<div class="flex">
244245
<Check bind:check={$DataBase.hanuraiSplit} name="Text Spliting"/>
245246
</div>
246247
{:else if $DataBase.supaMemoryType === 'hypaV2'}
247-
<span class="text-textcolor mt-4">{language.HypaMemory} V2 is Experimental</span>
248+
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.hypaV2Desc}</span>
249+
<span class="text-textcolor">{language.hypaChunkSize}</span>
250+
<NumberInput size="sm" marginBottom bind:value={$DataBase.hypaChunkSize} min={100} />
251+
<span class="text-textcolor">{language.hypaAllocatedTokens}</span>
252+
<NumberInput size="sm" marginBottom bind:value={$DataBase.hypaAllocatedTokens} min={100} />
248253
{:else if $DataBase.supaMemoryType !== 'none'}
254+
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.supaDesc}</span>
249255
<span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span>
250256
<SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaMemoryType}>
251257
<OptionInput value="distilbart" >distilbart-cnn-6-6 (Free/Local)</OptionInput>

src/lib/Setting/Pages/PromptSettings.svelte

+12-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import Check from "src/lib/UI/GUI/CheckInput.svelte";
99
import TextInput from "src/lib/UI/GUI/TextInput.svelte";
1010
import NumberInput from "src/lib/UI/GUI/NumberInput.svelte";
11+
import Help from "src/lib/Others/Help.svelte";
12+
import TextAreaInput from "src/lib/UI/GUI/TextAreaInput.svelte";
1113
1214
let sorted = 0
1315
let opened = 0
@@ -109,9 +111,15 @@
109111
<Check bind:check={$DataBase.promptSettings.sendChatAsSystem} name={language.sendChatAsSystem} className="mt-4"/>
110112
<Check bind:check={$DataBase.promptSettings.sendName} name={language.sendName} className="mt-4"/>
111113
<Check bind:check={$DataBase.promptSettings.utilOverride} name={language.utilOverride} className="mt-4"/>
112-
<Check bind:check={$DataBase.promptSettings.customChainOfThought} name={language.customChainOfThought} className="mt-4"/>
113-
{#if $DataBase.promptSettings.customChainOfThought}
114-
<span class="text-textcolor mt-4">{language.maxThoughtTagDepth}</span>
115-
<NumberInput bind:value={$DataBase.promptSettings.maxThoughtTagDepth}/>
114+
{#if $DataBase.showUnrecommended}
115+
<Check bind:check={$DataBase.promptSettings.customChainOfThought} name={language.customChainOfThought} className="mt-4">
116+
<Help unrecommended key='customChainOfThought' />
117+
</Check>
116118
{/if}
119+
<span class="text-textcolor mt-4">{language.maxThoughtTagDepth}</span>
120+
<NumberInput bind:value={$DataBase.promptSettings.maxThoughtTagDepth}/>
121+
<span class="text-textcolor mt-4">{language.customPromptTemplateToggle} <Help key='customPromptTemplateToggle' /></span>
122+
<TextAreaInput bind:value={$DataBase.customPromptTemplateToggle}/>
123+
<span class="text-textcolor mt-4">{language.defaultVariables} <Help key='defaultVariables' /></span>
124+
<TextAreaInput bind:value={$DataBase.templateDefaultVariables}/>
117125
{/if}

src/lib/SideBars/CharConfig.svelte

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import LoreBook from "./LoreBook/LoreBookSetting.svelte";
1010
import { alertConfirm, alertNormal, alertSelectChar, alertTOS, showHypaV2Alert } from "../../ts/alert";
1111
import BarIcon from "./BarIcon.svelte";
12-
import { findCharacterbyId, getAuthorNoteDefaultText, selectMultipleFile } from "../../ts/util";
12+
import { findCharacterbyId, getAuthorNoteDefaultText, parseKeyValue, selectMultipleFile } from "../../ts/util";
1313
import { onDestroy } from "svelte";
1414
import {isEqual} from 'lodash'
1515
import Help from "../Others/Help.svelte";
@@ -246,6 +246,15 @@
246246
<div class="flex mt-6 items-center">
247247
<Check bind:check={$DataBase.jailbreakToggle} name={language.jailbreakToggle}/>
248248
</div>
249+
250+
{#each parseKeyValue($DataBase.customPromptTemplateToggle) as toggle}
251+
<div class="flex mt-2 items-center">
252+
<Check check={$DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
253+
$DataBase.globalChatVariables[`toggle_${toggle[0]}`] = $DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
254+
}} />
255+
</div>
256+
{/each}
257+
249258

250259
{#if $DataBase.supaMemoryType !== 'none' || $DataBase.hanuraiEnable}
251260
{#if $DataBase.hanuraiEnable}
@@ -756,6 +765,9 @@
756765
<span class="text-textcolor mt-2">{language.backgroundHTML} <Help key="backgroundHTML" /></span>
757766
<TextAreaInput highlight margin="both" autocomplete="off" bind:value={currentChar.data.backgroundHTML}></TextAreaInput>
758767

768+
<span class="text-textcolor mt-2">{language.defaultVariables} <Help key="defaultVariables" /></span>
769+
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.defaultVariables}></TextAreaInput>
770+
759771
<span class="text-textcolor">{language.creator}</span>
760772
<TextInput size="sm" autocomplete="off" bind:value={currentChar.data.additionalData.creator} />
761773

src/lib/SideBars/SideChatList.svelte

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import type { character, groupChat } from "src/ts/storage/database";
33
import { DataBase } from "src/ts/storage/database";
44
import TextInput from "../UI/GUI/TextInput.svelte";
5-
import { DownloadIcon, EditIcon, FolderUpIcon, MenuIcon, TrashIcon } from "lucide-svelte";
5+
import { DownloadIcon, PencilIcon, FolderUpIcon, MenuIcon, TrashIcon } from "lucide-svelte";
66
import { exportChat, importChat } from "src/ts/characters";
77
import { alertConfirm, alertError, alertSelect } from "src/ts/alert";
88
import { language } from "src/lang";
99
import Button from "../UI/GUI/Button.svelte";
10-
import { findCharacterbyId } from "src/ts/util";
10+
import { findCharacterbyId, parseKeyValue } from "src/ts/util";
1111
import CheckInput from "../UI/GUI/CheckInput.svelte";
1212
import { createMultiuserRoom } from "src/ts/sync/multiuser";
1313
import { CurrentCharacter } from "src/ts/stores";
@@ -62,7 +62,7 @@
6262
<button class="text-textcolor2 hover:text-green-500 mr-1 cursor-pointer" on:click={() => {
6363
editMode = !editMode
6464
}}>
65-
<EditIcon size={18}/>
65+
<PencilIcon size={18}/>
6666
</button>
6767
<button class="text-textcolor2 hover:text-green-500 mr-1 cursor-pointer" on:click={async (e) => {
6868
e.stopPropagation()
@@ -101,7 +101,7 @@
101101
<button class="text-textcolor2 hover:text-green-500 cursor-pointer" on:click={() => {
102102
editMode = !editMode
103103
}}>
104-
<EditIcon size={18}/>
104+
<PencilIcon size={18}/>
105105
</button>
106106
</div>
107107

@@ -110,6 +110,14 @@
110110
<CheckInput bind:check={$DataBase.jailbreakToggle} name={language.jailbreakToggle}/>
111111
</div>
112112

113+
{#each parseKeyValue($DataBase.customPromptTemplateToggle) as toggle}
114+
<div class="flex mt-2 items-center">
115+
<CheckInput check={$DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
116+
$DataBase.globalChatVariables[`toggle_${toggle[0]}`] = $DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
117+
}} />
118+
</div>
119+
{/each}
120+
113121
{#if $DataBase.supaMemoryType !== 'none' || $DataBase.hanuraiEnable}
114122
{#if $DataBase.hanuraiEnable}
115123
<div class="flex mt-2 items-center">

src/ts/parser.ts

+21-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { get } from 'svelte/store';
99
import css from '@adobe/css-tools'
1010
import { selectedCharID } from './stores';
1111
import { calcString } from './process/infunctions';
12-
import { findCharacterbyId, sfc32, uuidtoNumber } from './util';
12+
import { findCharacterbyId, parseKeyValue, sfc32, uuidtoNumber } from './util';
1313
import { getInlayImage } from './process/files/image';
1414
import { autoMarkNew } from './plugins/automark';
1515
import { getModuleLorebooks } from './process/modules';
@@ -783,6 +783,9 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
783783
}
784784
return null
785785
}
786+
case 'getglobalvar':{
787+
return getGlobalChatVar(v)
788+
}
786789
case 'button':{
787790
return `<button class="button-default" risu-trigger="${arra[2]}">${arra[1]}</button>`
788791
}
@@ -1458,7 +1461,23 @@ export function getChatVar(key:string){
14581461
}
14591462
const chat = char.chats[char.chatPage]
14601463
chat.scriptstate = chat.scriptstate ?? {}
1461-
return (chat.scriptstate['$' + key])?.toString() ?? 'null'
1464+
const state = (chat.scriptstate['$' + key])
1465+
if(state === undefined || state === null){
1466+
const defaultVariables = parseKeyValue(char.defaultVariables).concat(parseKeyValue(db.templateDefaultVariables))
1467+
const findResult = defaultVariables.find((f) => {
1468+
return f[0] === key
1469+
})
1470+
if(findResult){
1471+
return findResult[1]
1472+
}
1473+
return 'null'
1474+
}
1475+
return state.toString()
1476+
}
1477+
1478+
export function getGlobalChatVar(key:string){
1479+
const db = get(DataBase)
1480+
return db.globalChatVariables[key] ?? 'null'
14621481
}
14631482

14641483
export function setChatVar(key:string, value:string){

src/ts/process/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
669669
formatedChat = name + ': ' + formatedChat
670670
attr.push('nameAdded')
671671
}
672-
if(usingPromptTemplate && db.promptSettings.customChainOfThought && db.promptSettings.maxThoughtTagDepth !== -1){
672+
if(usingPromptTemplate && db.promptSettings.maxThoughtTagDepth !== -1){
673673
const depth = ms.length - index
674674
if(depth >= db.promptSettings.maxThoughtTagDepth){
675675
formatedChat = formatedChat.replace(/<Thoughts>(.+?)<\/Thoughts>/gm, '')

src/ts/process/memory/hypav2.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async function summary(stringlizedChat:string):Promise<{
3535
formated: promptbody,
3636
bias: {},
3737
useStreaming: false,
38+
noMultiGen: true
3839
}, 'model')
3940
if(da.type === 'fail' || da.type === 'streaming' || da.type === 'multiline'){
4041
return {
@@ -67,7 +68,8 @@ export async function hypaMemoryV2(
6768

6869
//this is for the prompt
6970

70-
let allocatedTokens = 3000
71+
let allocatedTokens = db.hypaAllocatedTokens
72+
let chunkSize = db.hypaChunkSize
7173
currentTokens += allocatedTokens
7274
currentTokens += 50 //this is for the template prompt
7375
let mainPrompt = ""
@@ -93,13 +95,20 @@ export async function hypaMemoryV2(
9395

9496
while(currentTokens >= maxContextTokens){
9597

96-
const idx = (Math.floor(chats.length/2))
97-
const targetId = chats[idx].memo
98-
const halfData = chats.slice(idx)
98+
let idx = 0
99+
let targetId = ''
100+
const halfData:OpenAIChat[] = []
99101

100102
let halfDataTokens = 0
101-
for(const chat of halfData){
103+
while(halfDataTokens < chunkSize){
104+
const chat = chats[idx]
105+
if(!chat){
106+
break
107+
}
102108
halfDataTokens += await tokenizer.tokenizeChat(chat)
109+
halfData.push(chat)
110+
idx++
111+
targetId = chat.memo
103112
}
104113

105114
const stringlizedChat = halfData.map(e => `${e.role}: ${e.content}`).join('\n')

src/ts/process/memory/supaMemory.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ export async function supaMemory(
264264
]
265265
const da = await requestChatData({
266266
formated: promptbody,
267-
bias: {}
267+
bias: {},
268+
useStreaming: false,
269+
noMultiGen: true
268270
}, 'submodel')
269271
if(da.type === 'fail' || da.type === 'streaming' || da.type === 'multiline'){
270272
return {

0 commit comments

Comments
 (0)