Skip to content

Commit 97dffb0

Browse files
authored
1.103.3 (#428)
# 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 3d5f98e + deef7de commit 97dffb0

File tree

9 files changed

+83
-6
lines changed

9 files changed

+83
-6
lines changed

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.103.2"
11+
"version": "1.103.3"
1212
},
1313
"tauri": {
1414
"allowlist": {

src/lang/en.ts

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const languageEnglish = {
122122
triggerScript: "Trigger Script is a custom script that runs when a condition is met. it can be used to modify the chat data, run a command, change variable, and etc. the type depends when it is triggered. it can also be run by buttons, which can be used with {{button::Display::TriggerName}}, or HTML buttons with `risu-trigger=\"<TriggerName>\"` attribute.",
123123
autoContinueChat: "If enabled, it will try to continue the chat if it doesn't ends with a punctuation. DONT USE THIS WITH LANGUAGES THAT DOESN'T USE PUNCTUATION.",
124124
combineTranslation: "If enabled, text that is one sentence but separated by HTML tags will be combined together and translated, then Modify Display script will be reapplied to the translated output.\nThis helps the translator to make the correct translation.\nIf the UI becomes weird when you enable this option, please turn off the option and report it.",
125+
dynamicAssets: "If enabled, if the asset name is not found when processing data, it will try to find the closest asset name by using vector search and replace it with the closest asset name.",
125126
},
126127
setup: {
127128
chooseProvider: "Choose AI Provider",
@@ -590,4 +591,5 @@ export const languageEnglish = {
590591
run: "Run",
591592
noMessage: "Type something to start the chat.",
592593
combineTranslation : "Combine Translation",
594+
dynamicAssets: "Dynamic Assets",
593595
}

src/lib/Setting/Pages/AdvancedSettings.svelte

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
<Help key="removePunctuationHypa"/>
114114
</Check>
115115
</div>
116+
<div class="flex items-center mt-4">
117+
<Check bind:check={$DataBase.dynamicAssets} name={language.dynamicAssets}>
118+
<Help key="dynamicAssets"/>
119+
</Check>
120+
</div>
116121
<div class="flex items-center mt-4">
117122
<Check bind:check={$DataBase.usePlainFetch} name={language.forcePlainFetch}> <Help key="forcePlainFetch" unrecommended/></Check>
118123
</div>

src/lib/SideBars/CharConfig.svelte

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import { updateInlayScreen } from "src/ts/process/inlayScreen";
3131
import { registerOnnxModel } from "src/ts/process/transformers";
3232
import MultiLangInput from "../UI/GUI/MultiLangInput.svelte";
33+
import { shareRealmCard } from "src/ts/realm";
3334
3435
3536
let subMenu = 0
@@ -835,7 +836,8 @@
835836
return
836837
}
837838
if(await alertTOS()){
838-
openHubUpload = true
839+
// openHubUpload = true
840+
shareRealmCard()
839841
}
840842
}} className="mt-2">
841843
{#if currentChar.data.realmId}

src/ts/parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
7777
})
7878

7979

80-
const assetRegex = /{{(raw|img|video|audio|bg|emotion|asset|video-img)::(.+?)}}/g
80+
export const assetRegex = /{{(raw|img|video|audio|bg|emotion|asset|video-img)::(.+?)}}/g
8181

8282
async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|character, mode:'normal'|'back', mode2:'unset'|'pre'|'post' = 'unset'){
8383
const db = get(DataBase)

src/ts/process/scripts.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { downloadFile } from "../storage/globalApi";
55
import { alertError, alertNormal } from "../alert";
66
import { language } from "src/lang";
77
import { selectSingleFile } from "../util";
8-
import { risuChatParser as risuChatParserOrg, type simpleCharacterArgument } from "../parser";
8+
import { assetRegex, risuChatParser as risuChatParserOrg, type simpleCharacterArgument } from "../parser";
99
import { autoMarkPlugin } from "../plugins/automark";
1010
import { runCharacterJS } from "../plugins/embedscript";
1111
import { metricaPlugin } from "../plugins/metrica";
1212
import { OaiFixKorean } from "../plugins/fixer";
1313
import { getModuleRegexScripts } from "./modules";
14+
import { HypaProcesser } from "./memory/hypamemory";
1415

1516
const dreg = /{{data}}/g
1617
const randomness = /\|\|\|/g
@@ -211,6 +212,26 @@ export async function processScriptFull(char:character|groupChat|simpleCharacter
211212
}
212213
}
213214
}
215+
216+
if(db.dynamicAssets && (char.type === 'simple' || char.type === 'character') && char.additionalAssets && char.additionalAssets.length > 0){
217+
const assetNames = char.additionalAssets.map((v) => v[0])
218+
const processer = new HypaProcesser('MiniLM')
219+
await processer.addText(assetNames)
220+
const matches = data.matchAll(assetRegex)
221+
222+
for(const match of matches){
223+
const type = match[1]
224+
const assetName = match[2]
225+
if(!assetNames.includes(assetName)){
226+
const searched = await processer.similaritySearch(assetName)
227+
const bestMatch = searched[0]
228+
if(bestMatch){
229+
data = data.replaceAll(match[0], `{{${type}::${bestMatch}}}`)
230+
}
231+
}
232+
}
233+
}
234+
214235
return {data, emoChanged}
215236
}
216237

src/ts/realm.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { get } from "svelte/store";
2+
import { exportSpecV2 } from "./characterCards";
3+
import { VirtualWriter } from "./storage/globalApi";
4+
import { sleep } from "./util";
5+
import { CurrentCharacter } from "./stores";
6+
import { DataBase, type character } from "./storage/database";
7+
import { alertStore } from "./alert";
8+
9+
let pong = false;
10+
11+
window.addEventListener("message", (event) => {
12+
if (event.origin === "https://realm.risuai.net") {
13+
if (event.data === "pong") {
14+
pong = true;
15+
}
16+
}
17+
});
18+
19+
export async function shareRealmCard() {
20+
const char = structuredClone(get(CurrentCharacter)) as character
21+
const writer = new VirtualWriter()
22+
await exportSpecV2(char, 'png', {writer: writer})
23+
openRealm(char.name, writer.buf.buffer)
24+
}
25+
26+
export async function openRealm(name:string,data:ArrayBuffer) {
27+
const tk = get(DataBase)?.account?.token;
28+
const id = get(DataBase)?.account?.id
29+
const win = window.open(`https://realm.risuai.net/upload?token=${tk}&token_id=${id}`, "_blank");
30+
pong = false;
31+
while(true){
32+
if(pong){
33+
break;
34+
}
35+
win.postMessage("ping", "https://realm.risuai.net")
36+
await sleep(500);
37+
}
38+
alertStore.set({
39+
type: 'none',
40+
msg: ''
41+
})
42+
43+
const nameBuf = new TextEncoder().encode(name);
44+
45+
win.postMessage("filedata", "https://realm.risuai.net", [nameBuf,data]);
46+
}

src/ts/storage/database.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { OobaChatCompletionRequestParams } from '../model/ooba';
1414

1515
export const DataBase = writable({} as any as Database)
1616
export const loadedStore = writable(false)
17-
export let appVer = "1.103.2"
17+
export let appVer = "1.103.3"
1818
export let webAppSubVer = ''
1919

2020
export function setDatabase(data:Database){
@@ -655,6 +655,7 @@ export interface Database{
655655
sideBarSize:number
656656
textAreaTextSize:number
657657
combineTranslation:boolean
658+
dynamicAssets:boolean
658659
}
659660

660661
export interface customscript{

version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.103.2"}
1+
{"version":"1.103.3"}

0 commit comments

Comments
 (0)