Skip to content

Commit a047506

Browse files
authored
1.88.0 (#330)
# 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 e090595 + dc6d39b commit a047506

22 files changed

+692
-334
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"blueimp-md5": "^2.19.0",
3333
"body-parser": "^1.20.2",
3434
"buffer": "^6.0.3",
35+
"codemirror": "^5.65.16",
3536
"core-js": "^3.35.0",
3637
"cors": "^2.8.5",
3738
"crc": "^4.3.2",

pnpm-lock.yaml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

src/etc/patchNote.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
export const patchNote = {
2-
version: "1.87",
2+
version: "1.88",
33
content:
44
`
5-
# Update 1.87
6-
- Changed name of Reverse Proxy to Custom (OpenAI-Compatible)
7-
- Added Additional Parameters to Custom (OpenAI-Compatible)
8-
- Added Height mode option
9-
- Fixed file post not working on Custom (OpenAI-Compatible)
5+
# Update 1.88
6+
- Added DeepLX API support for translation #328
7+
- Added ElevenLabs Multilingual support #328
8+
- Added CharacterJS API support for Background Embedding #324
9+
- Added CodeMinor based syntax highlighting on input #325
10+
- Added ST preset import support
11+
- Reworked Variable system, now variables are stored in CharacterJS states, rather than in the chat context
12+
1013
`
1114
}
1215

src/lang/cn.ts

+3
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ export const languageChinese = {
391391
"translatorType": "翻译类型",
392392
"deeplKey": "deepl API密钥",
393393
"deeplFreeKey": "deepl 免费 API密钥",
394+
"deeplXUrl": "deepLX URL",
395+
"deeplXToken": "deepLX Token",
394396
"exportPersona": "导出角色",
395397
"importPersona": "导入角色",
396398
"export": "导出",
@@ -403,4 +405,5 @@ export const languageChinese = {
403405
"appendNameNAI": "在NAI上附加名称",
404406
module: "模块",
405407
modules: "模块",
408+
useAdvancedEditor: "使用高级编辑器",
406409
}

src/lang/de.ts

+3
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ export const languageGerman = {
421421
translatorType: "Übersetzer-Typ",
422422
deeplKey: "DeepL API-Schlüssel",
423423
deeplFreeKey: "DeepL Gratis API-Schlüssel",
424+
deeplXUrl: "deepLX URL",
425+
deeplXToken: "deepLX Token",
424426
exportPersona: "Profil exportieren",
425427
importPersona: "Profil importieren",
426428
export: "Exportieren",
@@ -432,4 +434,5 @@ export const languageGerman = {
432434
textAdventureNAI: "Als Textabenteuer ausführen",
433435
appendNameNAI: "Namen an NAI anhängen",
434436
customStopWords: "Benutzerdefinierte Stoppwörter",
437+
useAdvancedEditor: "Erweiterten Editor verwenden",
435438
}

src/lang/en.ts

+4
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ export const languageEnglish = {
456456
translatorType: "Translator Type",
457457
deeplKey: "deepL API Key",
458458
deeplFreeKey: "deepL Free API Key",
459+
deeplXUrl: "deepLX URL",
460+
deeplXToken: "deepLX Token",
459461
exportPersona: "Export Persona",
460462
importPersona: "Import Persona",
461463
export: "Export",
@@ -551,4 +553,6 @@ export const languageEnglish = {
551553
popularityLevelDesc: "Popularity increases with downloads, etc. to estimate, 3.7 popularity is about 1 downloads.",
552554
additionalParams: "Additional Parameters",
553555
heightMode: "Height Mode",
556+
useAdvancedEditor: "Use Advanced Editor",
557+
noWaitForTranslate: "No Wait for Translate",
554558
}

src/lang/ko.ts

+3
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ export const languageKorean = {
394394
translatorType: "번역기 타입",
395395
deeplKey: "deepL API 키",
396396
deeplFreeKey: "deepL 무료 API 키",
397+
deeplXUrl: "deepLX URL",
398+
deeplXToken: "deepLX Token",
397399
exportPersona: "페르소나 엑스포트",
398400
importPersona: "페르소나 임포트",
399401
export: "엑스포트",
@@ -432,4 +434,5 @@ export const languageKorean = {
432434
largePersonaPortrait: "페르소나 세로 이미지",
433435
module: "모듈",
434436
modules: "모듈",
437+
useAdvancedEditor: "고급 에디터 사용",
435438
}

src/lang/vi.ts

+3
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ export const LanguageVietnamese = {
392392
"translatorType": "Loại dịch giả",
393393
"deeplKey": "Khóa API deepL",
394394
"deeplFreeKey": "Khóa API miễn phí deepL",
395+
"deeplXUrl": "deepLX URL",
396+
"deeplXToken": "deepLX Token",
395397
"exportPersona": "Xuất khẩu nhân vật",
396398
"importPersona": "Nhập khẩu nhân vật",
397399
"export": "Xuất khẩu",
@@ -406,4 +408,5 @@ export const LanguageVietnamese = {
406408
"defaultPrompt": "Lời nhắc mặc định",
407409
module: "Mô-đun",
408410
modules: "Mô-đun",
411+
useAdvancedEditor: "Sử dụng trình biên tập nâng cao",
409412
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<script>
2+
import { onMount, createEventDispatcher } from 'svelte';
3+
import { EditIcon, LanguagesIcon } from "lucide-svelte";
4+
import { DataBase } from "../../ts/storage/database";
5+
import CodeMirror from 'codemirror';
6+
import 'codemirror/lib/codemirror.css';
7+
8+
export let value, translate;
9+
10+
const dispatch = createEventDispatcher();
11+
let toggleTranslate = !$DataBase.useAutoTranslateInput;
12+
let velement, veditor;
13+
let telement, teditor;
14+
let _value = value;
15+
let _translate = translate;
16+
17+
const markdowns = [
18+
{
19+
regex: /["“”](.*?)(["“”]|$)/gs,
20+
className: "ci-quote",
21+
},
22+
{
23+
regex: /`([^`]+)`/gs,
24+
className: "ci-backtick",
25+
},
26+
{
27+
regex: /\*\*\*([^*]+)(\*\*\*|$)/gs,
28+
className: "ci-asterisk3",
29+
},
30+
{
31+
regex: /(?<!\*)\*\*([^*]+)(\*\*(?!\*)|$)/gs,
32+
className: "ci-asterisk2",
33+
},
34+
{
35+
regex: /(?<!\*)\*([^*]+)(\*(?!\*)|$)/gs,
36+
className: "ci-asterisk1",
37+
},
38+
];
39+
40+
onMount(() => {
41+
veditor = initEditor(velement, value);
42+
teditor = initEditor(telement, translate);
43+
veditor.on('change', (_, evt) => {
44+
if(evt.origin != 'setValue' && !toggleTranslate) {
45+
const input = veditor.getValue('\r\n');
46+
if(input != value) {
47+
value = _value = input;
48+
dispatch('change', { translate: false, value: input });
49+
}
50+
}
51+
});
52+
teditor.on('change', (_, evt) => {
53+
if(evt.origin != 'setValue' && toggleTranslate) {
54+
const input = teditor.getValue('\r\n');
55+
if(input != translate) {
56+
translate = _translate = input;
57+
dispatch('change', { translate: true, value: input });
58+
}
59+
}
60+
});
61+
toggleTranslateText();
62+
});
63+
64+
$: if(value != _value) {
65+
veditor.setValue(_value = value);
66+
}
67+
$: if(translate != _translate) {
68+
teditor.setValue(_translate = translate);
69+
}
70+
71+
function toggleTranslateText() {
72+
toggleTranslate = !toggleTranslate;
73+
if(toggleTranslate) {
74+
velement.style.display = "none";
75+
telement.style.display = null;
76+
teditor.refresh();
77+
} else {
78+
velement.style.display = null;
79+
telement.style.display = "none";
80+
veditor.refresh();
81+
}
82+
}
83+
84+
function initEditor(element, value) {
85+
const editor = CodeMirror(element, {
86+
lineNumbers: true,
87+
value: value,
88+
});
89+
editor.on('change', (sender) => updateMarks(sender.doc));
90+
return editor;
91+
}
92+
93+
function updateMarks(doc) {
94+
const text = doc.getValue();
95+
for (const mark of doc.getAllMarks()) {
96+
mark.clear();
97+
}
98+
for(const markdown of markdowns) {
99+
for (const match of text.matchAll(markdown.regex)) {
100+
const start = doc.posFromIndex(match.index);
101+
const end = doc.posFromIndex(match.index + match[0].length);
102+
doc.markText(start, end, { className: markdown.className });
103+
}
104+
}
105+
}
106+
</script>
107+
108+
<div class="flex flex-1 items-end ml-2 mr-2">
109+
{#if $DataBase.useAutoTranslateInput}
110+
<button
111+
on:click={toggleTranslateText}
112+
class="mr-2 bg-textcolor2 flex justify-center items-center text-gray-100 w-12 h-12 rounded-md hover:bg-green-500 transition-colors">
113+
{#if toggleTranslate}
114+
<LanguagesIcon />
115+
{:else}
116+
<EditIcon />
117+
{/if}
118+
</button>
119+
{/if}
120+
<div class="flex-1">
121+
<div class="chatEditor" bind:this={velement}></div>
122+
<div class="chatEditor" hidden bind:this={telement}></div>
123+
</div>
124+
</div>
125+
<style>
126+
.chatEditor {
127+
display: table;
128+
table-layout: fixed;
129+
width: 100%;
130+
}
131+
.chatEditor :global(.CodeMirror) {
132+
min-height: 2em;
133+
height: auto;
134+
background-color: var(--risu-theme-bgcolor);
135+
color: #DD0;
136+
}
137+
.chatEditor :global(.CodeMirror:focus-within) {
138+
background-color: var(--risu-theme-textcolor2);
139+
}
140+
.chatEditor :global(.CodeMirror-gutters) {
141+
background-color: var(--risu-theme-selected);
142+
border-left-color: var(--risu-theme-borderc);
143+
}
144+
.chatEditor :global(.ci-quote) {
145+
color: #FFF;
146+
}
147+
.chatEditor :global(.ci-backtick) {
148+
color: #6AC;
149+
}
150+
.chatEditor :global(.ci-asterisk3) {
151+
font-weight: bold;
152+
font-style: italic;
153+
color: #E22;
154+
}
155+
.chatEditor :global(.ci-asterisk2) {
156+
font-style: italic;
157+
color: #E84;
158+
}
159+
.chatEditor :global(.ci-asterisk1) {
160+
font-style: italic;
161+
color: #990;
162+
}
163+
</style>

src/lib/ChatScreens/DefaultChatScreen.svelte

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import Suggestion from './Suggestion.svelte';
3+
import AdvancedChatEditor from './AdvancedChatEditor.svelte';
34
import { CameraIcon, DatabaseIcon, DicesIcon, GlobeIcon, ImagePlusIcon, LanguagesIcon, Laugh, MenuIcon, MicOffIcon, PackageIcon, RefreshCcwIcon, ReplyIcon, Send, StepForwardIcon } from "lucide-svelte";
45
import { CurrentCharacter, CurrentChat, CurrentUsername, selectedCharID, CurrentUserIcon, CurrentShowMemoryLimit,CurrentSimpleCharacter } from "../../ts/stores";
56
import Chat from "./Chat.svelte";
@@ -385,6 +386,7 @@
385386
}
386387
</script>
387388
<!-- svelte-ignore a11y-click-events-have-key-events -->
389+
<!-- svelte-ignore a11y-no-static-element-interactions -->
388390
<div class="w-full h-full" style={customStyle} on:click={() => {
389391
openMenu = false
390392
}}>
@@ -405,6 +407,8 @@
405407
<Laugh/>
406408
</div>
407409
{/if}
410+
411+
{#if !$DataBase.useAdvancedEditor}
408412
<textarea class="text-textcolor p-2 min-w-0 bg-transparent input-text text-xl flex-grow ml-4 mr-2 border-darkbutton resize-none focus:bg-selected overflow-y-hidden overflow-x-hidden max-w-full"
409413
bind:value={messageInput}
410414
bind:this={inputEle}
@@ -423,9 +427,16 @@
423427
on:input={()=>{updateInputSizeAll();updateInputTransateMessage(false)}}
424428
style:height={inputHeight}
425429
/>
430+
{:else}
431+
<AdvancedChatEditor
432+
bind:value={messageInput}
433+
bind:translate={messageInputTranslate}
434+
on:change={(e) => { updateInputTransateMessage(e.detail.translate);}}
435+
/>
436+
{/if}
426437

427438

428-
{#if $doingChat || doingChatInputTranslate}
439+
{#if $doingChat || doingChatInputTranslate}
429440
<div
430441
class="mr-2 bg-selected flex justify-center items-center text-gray-100 w-12 h-12 rounded-md hover:bg-green-500 transition-colors" on:click={abortChat}>
431442
<div class="loadmove" class:autoload={autoMode}>
@@ -443,7 +454,7 @@
443454
class="mr-2 bg-textcolor2 flex justify-center items-center text-gray-100 w-12 h-12 rounded-md hover:bg-green-500 transition-colors"><MenuIcon />
444455
</div>
445456
</div>
446-
{#if $DataBase.useAutoTranslateInput}
457+
{#if $DataBase.useAutoTranslateInput && !$DataBase.useAdvancedEditor}
447458
<div class="flex items-center mt-2 mb-2">
448459
<label for='messageInputTranslate' class="text-textcolor ml-4">
449460
<LanguagesIcon />

src/lib/Setting/Pages/AdvancedSettings.svelte

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<div class="flex items-center mt-4">
7575
<Check bind:check={$DataBase.newOAIHandle} name={language.newOAIHandle}/>
7676
</div>
77+
<div class="flex items-center mt-4">
78+
<Check bind:check={$DataBase.noWaitForTranslate} name={language.noWaitForTranslate}/>
79+
</div>
7780
<div class="flex items-center mt-4">
7881
<Check bind:check={$DataBase.allowAllExtentionFiles} name="Allow all in file select"/>
7982
</div>

src/lib/Setting/Pages/DisplaySettings.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@
192192
<Check bind:check={$DataBase.roundIcons} name={language.roundIcons}/>
193193
</div>
194194

195+
<div class="flex items-center mt-2">
196+
<Check bind:check={$DataBase.useAdvancedEditor} name={language.useAdvancedEditor}/>
197+
</div>
198+
195199
{#if $DataBase.textScreenColor}
196200
<div class="flex items-center mt-2">
197201
<Check check={true} onChange={() => {

src/lib/Setting/Pages/LanguageSettings.svelte

+9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<OptionInput value="google" >Google</OptionInput>
5959
<OptionInput value="deepl" >DeepL</OptionInput>
6060
<OptionInput value="llm" >Ax. Model</OptionInput>
61+
<OptionInput value="deeplX" >DeepL X</OptionInput>
6162
</SelectInput>
6263

6364
{#if $DataBase.translatorType === 'deepl'}
@@ -71,6 +72,14 @@
7172
<Check bind:check={$DataBase.deeplOptions.freeApi} name={language.deeplFreeKey}/>
7273
</div>
7374
{/if}
75+
76+
{#if $DataBase.translatorType === 'deeplX'}
77+
<span class="text-textcolor mt-4">{language.deeplXUrl}</span>
78+
<TextInput bind:value={$DataBase.deeplXOptions.url} />
79+
80+
<span class="text-textcolor mt-4">{language.deeplXToken}</span>
81+
<TextInput bind:value={$DataBase.deeplXOptions.token} />
82+
{/if}
7483

7584
{#if $DataBase.translatorType === 'llm'}
7685
<span class="text-textcolor mt-4">{language.translationPrompt}</span>

0 commit comments

Comments
 (0)