Migrate all DataBase to DBState
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Sidebar from './lib/SideBars/Sidebar.svelte';
|
import Sidebar from './lib/SideBars/Sidebar.svelte';
|
||||||
import { DynamicGUI, settingsOpen, sideBarStore, ShowRealmFrameStore, openPresetList, openPersonaList, MobileGUI, CustomGUISettingMenuStore } from './ts/stores';
|
import { DynamicGUI, settingsOpen, sideBarStore, ShowRealmFrameStore, openPresetList, openPersonaList, MobileGUI, CustomGUISettingMenuStore } from './ts/stores';
|
||||||
import { DataBase, loadedStore } from './ts/storage/database.svelte';
|
import { DBState, loadedStore } from './ts/storage/database.svelte';
|
||||||
import ChatScreen from './lib/ChatScreens/ChatScreen.svelte';
|
import ChatScreen from './lib/ChatScreens/ChatScreen.svelte';
|
||||||
import AlertComp from './lib/Others/AlertComp.svelte';
|
import AlertComp from './lib/Others/AlertComp.svelte';
|
||||||
import RealmPopUp from './lib/UI/Realm/RealmPopUp.svelte';
|
import RealmPopUp from './lib/UI/Realm/RealmPopUp.svelte';
|
||||||
@@ -21,15 +21,9 @@
|
|||||||
import CustomGUISettingMenu from './lib/Setting/Pages/CustomGUISettingMenu.svelte';
|
import CustomGUISettingMenu from './lib/Setting/Pages/CustomGUISettingMenu.svelte';
|
||||||
|
|
||||||
|
|
||||||
let didFirstSetup: boolean = $state(false)
|
let didFirstSetup: boolean = $derived(DBState.db?.didFirstSetup)
|
||||||
let gridOpen = $state(false)
|
let gridOpen = $state(false)
|
||||||
|
|
||||||
DataBase.subscribe(db => {
|
|
||||||
if(db.didFirstSetup !== didFirstSetup){
|
|
||||||
didFirstSetup = db.didFirstSetup || false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main class="flex bg-bg w-full h-full max-w-100vw text-textcolor">
|
<main class="flex bg-bg w-full h-full max-w-100vw text-textcolor">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount, createEventDispatcher } from 'svelte';
|
import { onMount, createEventDispatcher } from 'svelte';
|
||||||
import { EditIcon, LanguagesIcon } from "lucide-svelte";
|
import { EditIcon, LanguagesIcon } from "lucide-svelte";
|
||||||
import { DataBase, DBState } from "../../ts/storage/database.svelte";
|
import { DBState } from "../../ts/storage/database.svelte";
|
||||||
import CodeMirror from 'codemirror';
|
import CodeMirror from 'codemirror';
|
||||||
import 'codemirror/lib/codemirror.css';
|
import 'codemirror/lib/codemirror.css';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { get } from 'svelte/store';
|
|
||||||
import { FileAudioIcon, PlusIcon } from "lucide-svelte";
|
import { FileAudioIcon, PlusIcon } from "lucide-svelte";
|
||||||
import { DataBase, setDatabase, type character, type groupChat } from "src/ts/storage/database.svelte";
|
import { type character, type groupChat } from "src/ts/storage/database.svelte";
|
||||||
import { getFileSrc, saveAsset } from "src/ts/storage/globalApi";
|
import { getFileSrc, saveAsset } from "src/ts/storage/globalApi";
|
||||||
import { selectMultipleFile } from "src/ts/util";
|
import { selectMultipleFile } from "src/ts/util";
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -48,8 +47,6 @@
|
|||||||
currentCharacter.additionalAssets.push([name, imgp, extension])
|
currentCharacter.additionalAssets.push([name, imgp, extension])
|
||||||
currentCharacter = currentCharacter
|
currentCharacter = currentCharacter
|
||||||
}
|
}
|
||||||
const db = get(DataBase);
|
|
||||||
setDatabase(db)
|
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
|
|||||||
@@ -1,42 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ParseMarkdown, risuChatParser } from "src/ts/parser";
|
import { ParseMarkdown, risuChatParser } from "src/ts/parser";
|
||||||
import { DataBase, type Database, type character, type groupChat } from "src/ts/storage/database.svelte";
|
import { DBState, type character, type groupChat } from "src/ts/storage/database.svelte";
|
||||||
import { moduleBackgroundEmbedding, ReloadGUIPointer, selectedCharID } from "src/ts/stores";
|
import { moduleBackgroundEmbedding, ReloadGUIPointer, selectedCharID } from "src/ts/stores";
|
||||||
import { onDestroy } from "svelte";
|
|
||||||
|
|
||||||
let backgroundHTML = $state('')
|
let backgroundHTML = $derived(DBState.db?.characters?.[$selectedCharID]?.backgroundHTML)
|
||||||
let lastdb:Database
|
|
||||||
let currentChar:character|groupChat = $state()
|
let currentChar:character|groupChat = $state()
|
||||||
let selectedId = 0
|
|
||||||
|
|
||||||
function checkUpdate(){
|
|
||||||
if(selectedId > 0 && lastdb){
|
|
||||||
if(lastdb.characters[selectedId] && lastdb.characters[selectedId].backgroundHTML !== backgroundHTML){
|
|
||||||
backgroundHTML = lastdb.characters[selectedId].backgroundHTML
|
|
||||||
currentChar = lastdb.characters[selectedId]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(backgroundHTML !== ''){
|
|
||||||
backgroundHTML = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsubDatabase = DataBase.subscribe(v => {
|
|
||||||
lastdb = v
|
|
||||||
checkUpdate()
|
|
||||||
})
|
|
||||||
|
|
||||||
const unsubID = selectedCharID.subscribe(v => {
|
|
||||||
selectedId = v
|
|
||||||
checkUpdate()
|
|
||||||
})
|
|
||||||
|
|
||||||
onDestroy(() => {
|
|
||||||
unsubDatabase()
|
|
||||||
unsubID()
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -140,15 +140,13 @@
|
|||||||
}
|
}
|
||||||
if(rerollid < rerolls.length - 1){
|
if(rerollid < rerolls.length - 1){
|
||||||
if(Array.isArray(rerolls[rerollid + 1])){
|
if(Array.isArray(rerolls[rerollid + 1])){
|
||||||
let db = DBState.db
|
|
||||||
rerollid += 1
|
rerollid += 1
|
||||||
let rerollData = structuredClone(rerolls[rerollid])
|
let rerollData = structuredClone(rerolls[rerollid])
|
||||||
let msgs = db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
let msgs = DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
||||||
for(let i = 0; i < rerollData.length; i++){
|
for(let i = 0; i < rerollData.length; i++){
|
||||||
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
||||||
}
|
}
|
||||||
db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message = msgs
|
DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message = msgs
|
||||||
DBState.db = db
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -199,15 +197,13 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(Array.isArray(rerolls[rerollid - 1])){
|
if(Array.isArray(rerolls[rerollid - 1])){
|
||||||
let db = DBState.db
|
|
||||||
rerollid -= 1
|
rerollid -= 1
|
||||||
let rerollData = structuredClone(rerolls[rerollid])
|
let rerollData = structuredClone(rerolls[rerollid])
|
||||||
let msgs = db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
let msgs = DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
||||||
for(let i = 0; i < rerollData.length; i++){
|
for(let i = 0; i < rerollData.length; i++){
|
||||||
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
||||||
}
|
}
|
||||||
db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message = msgs
|
DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message = msgs
|
||||||
DBState.db = db
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
import PlaygroundSyntax from "./PlaygroundSyntax.svelte";
|
import PlaygroundSyntax from "./PlaygroundSyntax.svelte";
|
||||||
import { findCharacterIndexbyId } from "src/ts/util";
|
import { findCharacterIndexbyId } from "src/ts/util";
|
||||||
import { characterFormatUpdate, createBlankChar } from "src/ts/characters";
|
import { characterFormatUpdate, createBlankChar } from "src/ts/characters";
|
||||||
import { get } from "svelte/store";
|
import { DBState, type character } from "src/ts/storage/database.svelte";
|
||||||
import { DataBase, setDatabase, type character } from "src/ts/storage/database.svelte";
|
|
||||||
import PlaygroundImageGen from "./PlaygroundImageGen.svelte";
|
import PlaygroundImageGen from "./PlaygroundImageGen.svelte";
|
||||||
import PlaygroundParser from "./PlaygroundParser.svelte";
|
import PlaygroundParser from "./PlaygroundParser.svelte";
|
||||||
import ToolConvertion from "./ToolConvertion.svelte";
|
import ToolConvertion from "./ToolConvertion.svelte";
|
||||||
@@ -18,17 +17,16 @@
|
|||||||
let easterEggTouch = $state(0)
|
let easterEggTouch = $state(0)
|
||||||
|
|
||||||
const playgroundChat = () => {
|
const playgroundChat = () => {
|
||||||
let db = get(DataBase)
|
|
||||||
const charIndex = findCharacterIndexbyId('§playground')
|
const charIndex = findCharacterIndexbyId('§playground')
|
||||||
PlaygroundStore.set(2)
|
PlaygroundStore.set(2)
|
||||||
|
|
||||||
if (charIndex !== -1) {
|
if (charIndex !== -1) {
|
||||||
|
|
||||||
const char = db.characters[charIndex] as character
|
const char = DBState.db.characters[charIndex] as character
|
||||||
char.utilityBot = true
|
char.utilityBot = true
|
||||||
char.name = 'assistant'
|
char.name = 'assistant'
|
||||||
char.firstMessage = '{{none}}'
|
char.firstMessage = '{{none}}'
|
||||||
db.characters[charIndex] = char
|
DBState.db.characters[charIndex] = char
|
||||||
characterFormatUpdate(charIndex)
|
characterFormatUpdate(charIndex)
|
||||||
|
|
||||||
selectedCharID.set(charIndex)
|
selectedCharID.set(charIndex)
|
||||||
@@ -38,8 +36,7 @@
|
|||||||
const character = createBlankChar()
|
const character = createBlankChar()
|
||||||
character.chaId = '§playground'
|
character.chaId = '§playground'
|
||||||
|
|
||||||
db.characters.push(character)
|
DBState.db.characters.push(character)
|
||||||
setDatabase(db)
|
|
||||||
|
|
||||||
playgroundChat()
|
playgroundChat()
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import { alertConfirm } from "src/ts/alert";
|
import { alertConfirm } from "src/ts/alert";
|
||||||
import { checkDriver } from "src/ts/drive/drive";
|
import { checkDriver } from "src/ts/drive/drive";
|
||||||
import { DataBase } from "src/ts/storage/database.svelte";
|
|
||||||
import { isNodeServer, isTauri } from "src/ts/storage/globalApi";
|
import { isNodeServer, isTauri } from "src/ts/storage/globalApi";
|
||||||
import { persistantStorageRecommended } from "src/ts/storage/persistant";
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
const option = await alertChatOptions()
|
const option = await alertChatOptions()
|
||||||
switch(option){
|
switch(option){
|
||||||
case 0:{
|
case 0:{
|
||||||
const newChat = structuredClone(chara.chats[i])
|
const newChat = structuredClone($state.snapshot(chara.chats[i]))
|
||||||
newChat.name = `Copy of ${newChat.name}`
|
newChat.name = `Copy of ${newChat.name}`
|
||||||
chara.chats.unshift(newChat)
|
chara.chats.unshift(newChat)
|
||||||
chara.chatPage = 0
|
chara.chatPage = 0
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
const da = db.characterOrder[mainIndex.index]
|
const da = db.characterOrder[mainIndex.index]
|
||||||
if(typeof(da) !== 'string'){
|
if(typeof(da) !== 'string'){
|
||||||
mainId = da.id
|
mainId = da.id
|
||||||
movingFolder = structuredClone(da)
|
movingFolder = structuredClone($state.snapshot(da))
|
||||||
if(targetIndex.folder){
|
if(targetIndex.folder){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
if(!latin1.test(enNotes)){
|
if(!latin1.test(enNotes)){
|
||||||
alertError("English version of creator notes must contain only Latin-1 characters")
|
alertError("English version of creator notes must contain only Latin-1 characters")
|
||||||
}
|
}
|
||||||
shareRisuHub2(char, {
|
shareRisuHub2($state.snapshot(char) as character, {
|
||||||
anon: privateMode,
|
anon: privateMode,
|
||||||
nsfw: nsfwMode,
|
nsfw: nsfwMode,
|
||||||
tag: tags,
|
tag: tags,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { sleep } from "./util"
|
|||||||
import { language } from "../lang"
|
import { language } from "../lang"
|
||||||
import { isNodeServer, isTauri } from "./storage/globalApi"
|
import { isNodeServer, isTauri } from "./storage/globalApi"
|
||||||
import { Capacitor } from "@capacitor/core"
|
import { Capacitor } from "@capacitor/core"
|
||||||
import { DataBase, type MessageGenerationInfo } from "./storage/database.svelte"
|
import { getDatabase, type MessageGenerationInfo } from "./storage/database.svelte"
|
||||||
|
|
||||||
interface alertData{
|
interface alertData{
|
||||||
type: 'error'|'normal'|'none'|'ask'|'wait'|'selectChar'
|
type: 'error'|'normal'|'none'|'ask'|'wait'|'selectChar'
|
||||||
@@ -27,7 +27,7 @@ export const alertGenerationInfoStore = writable<AlertGenerationInfoStoreData>(n
|
|||||||
|
|
||||||
export function alertError(msg:string){
|
export function alertError(msg:string){
|
||||||
console.error(msg)
|
console.error(msg)
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
|
|
||||||
if(typeof(msg) !== 'string'){
|
if(typeof(msg) !== 'string'){
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get, writable, type Writable } from "svelte/store"
|
import { get, writable, type Writable } from "svelte/store"
|
||||||
import { alertCardExport, alertConfirm, alertError, alertInput, alertMd, alertNormal, alertSelect, alertStore, alertTOS, alertWait } from "./alert"
|
import { alertCardExport, alertConfirm, alertError, alertInput, alertMd, alertNormal, alertSelect, alertStore, alertTOS, alertWait } from "./alert"
|
||||||
import { DataBase, defaultSdDataFunc, type character, setDatabase, type customscript, type loreSettings, type loreBook, type triggerscript, importPreset, type groupChat, setCurrentCharacter, getCurrentCharacter } from "./storage/database.svelte"
|
import { defaultSdDataFunc, type character, setDatabase, type customscript, type loreSettings, type loreBook, type triggerscript, importPreset, type groupChat, setCurrentCharacter, getCurrentCharacter, getDatabase, setDatabaseLite } from "./storage/database.svelte"
|
||||||
import { checkNullish, decryptBuffer, encryptBuffer, isKnownUri, selectFileByDom, selectMultipleFile, sleep } from "./util"
|
import { checkNullish, decryptBuffer, encryptBuffer, isKnownUri, selectFileByDom, selectMultipleFile, sleep } from "./util"
|
||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
import { v4 as uuidv4, v4 } from 'uuid';
|
import { v4 as uuidv4, v4 } from 'uuid';
|
||||||
@@ -52,13 +52,13 @@ async function importCharacterProcess(f:{
|
|||||||
const data = f.data instanceof Uint8Array ? f.data : new Uint8Array(await f.data.arrayBuffer())
|
const data = f.data instanceof Uint8Array ? f.data : new Uint8Array(await f.data.arrayBuffer())
|
||||||
const da = JSON.parse(Buffer.from(data).toString('utf-8'))
|
const da = JSON.parse(Buffer.from(data).toString('utf-8'))
|
||||||
if(await importCharacterCardSpec(da)){
|
if(await importCharacterCardSpec(da)){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
return db.characters.length - 1
|
return db.characters.length - 1
|
||||||
}
|
}
|
||||||
if((da.char_name || da.name) && (da.char_persona || da.description) && (da.char_greeting || da.first_mes)){
|
if((da.char_name || da.name) && (da.char_persona || da.description) && (da.char_greeting || da.first_mes)){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.characters.push(convertOffSpecCards(da))
|
db.characters.push(convertOffSpecCards(da))
|
||||||
DataBase.set(db)
|
setDatabaseLite(db)
|
||||||
alertNormal(language.importedCharacter)
|
alertNormal(language.importedCharacter)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ async function importCharacterProcess(f:{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.statics.imports += 1
|
db.statics.imports += 1
|
||||||
|
|
||||||
if(f.name.endsWith('charx')){
|
if(f.name.endsWith('charx')){
|
||||||
@@ -99,7 +99,7 @@ async function importCharacterProcess(f:{
|
|||||||
card.data.extensions.risuai.customScripts = md.regex ?? []
|
card.data.extensions.risuai.customScripts = md.regex ?? []
|
||||||
}
|
}
|
||||||
await importCharacterCardSpec(card, undefined, 'normal', reader.assets)
|
await importCharacterCardSpec(card, undefined, 'normal', reader.assets)
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
return db.characters.length - 1
|
return db.characters.length - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ async function importCharacterProcess(f:{
|
|||||||
const decrypted = await decryptBuffer(encrypted, password)
|
const decrypted = await decryptBuffer(encrypted, password)
|
||||||
const charaData:CharacterCardV2Risu = JSON.parse(Buffer.from(decrypted).toString('utf-8'))
|
const charaData:CharacterCardV2Risu = JSON.parse(Buffer.from(decrypted).toString('utf-8'))
|
||||||
if(await importCharacterCardSpec(charaData, img, "normal", assets)){
|
if(await importCharacterCardSpec(charaData, img, "normal", assets)){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
return db.characters.length - 1
|
return db.characters.length - 1
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -210,7 +210,7 @@ async function importCharacterProcess(f:{
|
|||||||
try {
|
try {
|
||||||
const charaData:CharacterCardV2Risu = JSON.parse(Buffer.from(decrypted).toString('utf-8'))
|
const charaData:CharacterCardV2Risu = JSON.parse(Buffer.from(decrypted).toString('utf-8'))
|
||||||
if(await importCharacterCardSpec(charaData, img, "normal", assets)){
|
if(await importCharacterCardSpec(charaData, img, "normal", assets)){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
return db.characters.length - 1
|
return db.characters.length - 1
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -232,13 +232,13 @@ async function importCharacterProcess(f:{
|
|||||||
console.log(charaData)
|
console.log(charaData)
|
||||||
const imgp = await saveAsset(await reencodeImage(img))
|
const imgp = await saveAsset(await reencodeImage(img))
|
||||||
db.characters.push(convertOffSpecCards(charaData, imgp))
|
db.characters.push(convertOffSpecCards(charaData, imgp))
|
||||||
DataBase.set(db)
|
setDatabaseLite(db)
|
||||||
alertNormal(language.importedCharacter)
|
alertNormal(language.importedCharacter)
|
||||||
return db.characters.length - 1
|
return db.characters.length - 1
|
||||||
}
|
}
|
||||||
await importCharacterCardSpec(parsed, img, "normal", assets)
|
await importCharacterCardSpec(parsed, img, "normal", assets)
|
||||||
|
|
||||||
db = get(DataBase)
|
db = getDatabase()
|
||||||
return db.characters.length - 1
|
return db.characters.length - 1
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ export async function characterURLImport() {
|
|||||||
const importData = JSON.parse(Buffer.from(decodeURIComponent(data), 'base64').toString('utf-8'))
|
const importData = JSON.parse(Buffer.from(decodeURIComponent(data), 'base64').toString('utf-8'))
|
||||||
importData.id = v4()
|
importData.id = v4()
|
||||||
|
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(importData.lowLevelAccess){
|
if(importData.lowLevelAccess){
|
||||||
const conf = await alertConfirm(language.lowLevelAccessConfirm)
|
const conf = await alertConfirm(language.lowLevelAccessConfirm)
|
||||||
if(!conf){
|
if(!conf){
|
||||||
@@ -363,7 +363,7 @@ export async function characterURLImport() {
|
|||||||
const module = new Uint8Array(await data.arrayBuffer())
|
const module = new Uint8Array(await data.arrayBuffer())
|
||||||
const md = await readModule(Buffer.from(module))
|
const md = await readModule(Buffer.from(module))
|
||||||
md.id = v4()
|
md.id = v4()
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
db.modules.push(md)
|
db.modules.push(md)
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
alertNormal(language.successImport)
|
alertNormal(language.successImport)
|
||||||
@@ -447,7 +447,7 @@ export async function characterURLImport() {
|
|||||||
if(name.endsWith('risum')){
|
if(name.endsWith('risum')){
|
||||||
const md = await readModule(Buffer.from(data))
|
const md = await readModule(Buffer.from(data))
|
||||||
md.id = v4()
|
md.id = v4()
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
db.modules.push(md)
|
db.modules.push(md)
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
alertNormal(language.successImport)
|
alertNormal(language.successImport)
|
||||||
@@ -568,7 +568,7 @@ function convertOffSpecCards(charaData:OldTavernChar|CharacterCardV2Risu, imgp:s
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function exportChar(charaID:number):Promise<string> {
|
export async function exportChar(charaID:number):Promise<string> {
|
||||||
const db = get(DataBase)
|
const db = getDatabase({snapshot: true})
|
||||||
let char = structuredClone(db.characters[charaID])
|
let char = structuredClone(db.characters[charaID])
|
||||||
|
|
||||||
if(char.type === 'group'){
|
if(char.type === 'group'){
|
||||||
@@ -605,7 +605,7 @@ async function importCharacterCardSpec(card:CharacterCardV2Risu|CharacterCardV3,
|
|||||||
const data = card.data
|
const data = card.data
|
||||||
console.log(card)
|
console.log(card)
|
||||||
let im = img ? await saveAsset(await reencodeImage(img)) : undefined
|
let im = img ? await saveAsset(await reencodeImage(img)) : undefined
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
|
|
||||||
const risuext = structuredClone(data.extensions.risuai)
|
const risuext = structuredClone(data.extensions.risuai)
|
||||||
let emotions:[string, string][] = []
|
let emotions:[string, string][] = []
|
||||||
@@ -1434,8 +1434,8 @@ export async function shareRisuHub2(char:character, arg:{
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": 'image/png',
|
"Content-Type": 'image/png',
|
||||||
"x-risu-api-version": "4",
|
"x-risu-api-version": "4",
|
||||||
"x-risu-token": get(DataBase)?.account?.token,
|
"x-risu-token": getDatabase()?.account?.token,
|
||||||
'x-risu-username': arg.anon ? '' : (get(DataBase)?.account?.id),
|
'x-risu-username': arg.anon ? '' : (getDatabase()?.account?.id),
|
||||||
'x-risu-debug': 'true',
|
'x-risu-debug': 'true',
|
||||||
'x-risu-update-id': arg.update ? (char.realmId ?? 'null') : 'null'
|
'x-risu-update-id': arg.update ? (char.realmId ?? 'null') : 'null'
|
||||||
}
|
}
|
||||||
@@ -1540,7 +1540,7 @@ export async function downloadRisuHub(id:string, arg:{
|
|||||||
data: res.body
|
data: res.body
|
||||||
})
|
})
|
||||||
checkCharOrder()
|
checkCharOrder()
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db.characters[db.characters.length-1] && (db.goCharacterOnImport || arg.forceRedirect)){
|
if(db.characters[db.characters.length-1] && (db.goCharacterOnImport || arg.forceRedirect)){
|
||||||
const index = db.characters.length-1
|
const index = db.characters.length-1
|
||||||
characterFormatUpdate(index);
|
characterFormatUpdate(index);
|
||||||
@@ -1557,7 +1557,7 @@ export async function downloadRisuHub(id:string, arg:{
|
|||||||
|
|
||||||
await importCharacterCardSpec(data, await getHubResources(img), 'hub')
|
await importCharacterCardSpec(data, await getHubResources(img), 'hub')
|
||||||
checkCharOrder()
|
checkCharOrder()
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db.characters[db.characters.length-1] && (db.goCharacterOnImport || arg.forceRedirect)){
|
if(db.characters[db.characters.length-1] && (db.goCharacterOnImport || arg.forceRedirect)){
|
||||||
const index = db.characters.length-1
|
const index = db.characters.length-1
|
||||||
characterFormatUpdate(index);
|
characterFormatUpdate(index);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { get, writable } from "svelte/store";
|
||||||
import { DataBase, saveImage, setDatabase, type character, type Chat, defaultSdDataFunc, type loreBook } from "./storage/database.svelte";
|
import { saveImage, setDatabase, type character, type Chat, defaultSdDataFunc, type loreBook, getDatabase } from "./storage/database.svelte";
|
||||||
import { alertAddCharacter, alertConfirm, alertError, alertNormal, alertSelect, alertStore, alertWait } from "./alert";
|
import { alertAddCharacter, alertConfirm, alertError, alertNormal, alertSelect, alertStore, alertWait } from "./alert";
|
||||||
import { language } from "../lang";
|
import { language } from "../lang";
|
||||||
import { decode as decodeMsgpack } from "msgpackr";
|
import { decode as decodeMsgpack } from "msgpackr";
|
||||||
@@ -16,7 +16,7 @@ import { doingChat } from "./process";
|
|||||||
import { importCharacter } from "./characterCards";
|
import { importCharacter } from "./characterCards";
|
||||||
|
|
||||||
export function createNewCharacter() {
|
export function createNewCharacter() {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.characters.push(createBlankChar())
|
db.characters.push(createBlankChar())
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
checkCharOrder()
|
checkCharOrder()
|
||||||
@@ -24,7 +24,7 @@ export function createNewCharacter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createNewGroup(){
|
export function createNewGroup(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.characters.push({
|
db.characters.push({
|
||||||
type: 'group',
|
type: 'group',
|
||||||
name: "",
|
name: "",
|
||||||
@@ -45,7 +45,8 @@ export function createNewGroup(){
|
|||||||
chaId: uuidv4(),
|
chaId: uuidv4(),
|
||||||
firstMsgIndex: -1,
|
firstMsgIndex: -1,
|
||||||
characterTalks: [],
|
characterTalks: [],
|
||||||
characterActive: []
|
characterActive: [],
|
||||||
|
realmId: ''
|
||||||
})
|
})
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
checkCharOrder()
|
checkCharOrder()
|
||||||
@@ -82,7 +83,7 @@ export async function selectCharImg(charIndex:number) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const img = selected.data
|
const img = selected.data
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const imgp = await saveImage(await reencodeImage(img))
|
const imgp = await saveImage(await reencodeImage(img))
|
||||||
dumpCharImage(charIndex)
|
dumpCharImage(charIndex)
|
||||||
db.characters[charIndex].image = imgp
|
db.characters[charIndex].image = imgp
|
||||||
@@ -90,7 +91,7 @@ export async function selectCharImg(charIndex:number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function dumpCharImage(charIndex:number) {
|
export function dumpCharImage(charIndex:number) {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const char = db.characters[charIndex] as character
|
const char = db.characters[charIndex] as character
|
||||||
if(!char.image || char.image === ''){
|
if(!char.image || char.image === ''){
|
||||||
return
|
return
|
||||||
@@ -108,7 +109,7 @@ export function dumpCharImage(charIndex:number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function changeCharImage(charIndex:number,changeIndex:number) {
|
export function changeCharImage(charIndex:number,changeIndex:number) {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const char = db.characters[charIndex] as character
|
const char = db.characters[charIndex] as character
|
||||||
const image = char.ccAssets[changeIndex].uri
|
const image = char.ccAssets[changeIndex].uri
|
||||||
char.ccAssets.splice(changeIndex, 1)
|
char.ccAssets.splice(changeIndex, 1)
|
||||||
@@ -128,7 +129,7 @@ export async function addCharEmotion(charId:number) {
|
|||||||
addingEmotion.set(false)
|
addingEmotion.set(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
for(const f of selected){
|
for(const f of selected){
|
||||||
const img = f.data
|
const img = f.data
|
||||||
const imgp = await saveImage(img)
|
const imgp = await saveImage(img)
|
||||||
@@ -144,7 +145,7 @@ export async function addCharEmotion(charId:number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function rmCharEmotion(charId:number, emotionId:number) {
|
export async function rmCharEmotion(charId:number, emotionId:number) {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let dbChar = db.characters[charId]
|
let dbChar = db.characters[charId]
|
||||||
if(dbChar.type !== 'group'){
|
if(dbChar.type !== 'group'){
|
||||||
dbChar.emotionImages.splice(emotionId, 1)
|
dbChar.emotionImages.splice(emotionId, 1)
|
||||||
@@ -161,7 +162,7 @@ export async function exportChat(page:number){
|
|||||||
const doTranslate = (mode === '2' || mode === '3') ? (await alertSelect([language.translateContent, language.doNotTranslate])) === '0' : false
|
const doTranslate = (mode === '2' || mode === '3') ? (await alertSelect([language.translateContent, language.doNotTranslate])) === '0' : false
|
||||||
const anonymous = (mode === '2' || mode === '3') ? ((await alertSelect([language.includePersonaName, language.hidePersonaName])) === '1') : false
|
const anonymous = (mode === '2' || mode === '3') ? ((await alertSelect([language.includePersonaName, language.hidePersonaName])) === '1') : false
|
||||||
const selectedID = get(selectedCharID)
|
const selectedID = get(selectedCharID)
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const chat = db.characters[selectedID].chats[page]
|
const chat = db.characters[selectedID].chats[page]
|
||||||
const char = db.characters[selectedID]
|
const char = db.characters[selectedID]
|
||||||
const date = new Date().toJSON();
|
const date = new Date().toJSON();
|
||||||
@@ -335,7 +336,7 @@ export async function importChat(){
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const selectedID = get(selectedCharID)
|
const selectedID = get(selectedCharID)
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
|
|
||||||
if(dat.name.endsWith('jsonl')){
|
if(dat.name.endsWith('jsonl')){
|
||||||
const lines = Buffer.from(dat.data).toString('utf-8').split('\n')
|
const lines = Buffer.from(dat.data).toString('utf-8').split('\n')
|
||||||
@@ -412,14 +413,14 @@ export async function importChat(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatTavernChat(chat:string, charName:string){
|
function formatTavernChat(chat:string, charName:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return chat.replace(/<([Uu]ser)>|\{\{([Uu]ser)\}\}/g, getUserName()).replace(/((\{\{)|<)([Cc]har)(=.+)?((\}\})|>)/g, charName)
|
return chat.replace(/<([Uu]ser)>|\{\{([Uu]ser)\}\}/g, getUserName()).replace(/((\{\{)|<)([Cc]har)(=.+)?((\}\})|>)/g, charName)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function characterFormatUpdate(index:number|character, arg:{
|
export function characterFormatUpdate(index:number|character, arg:{
|
||||||
updateInteraction?:boolean,
|
updateInteraction?:boolean,
|
||||||
} = {}){
|
} = {}){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let cha = typeof(index) === 'number' ? db.characters[index] : index
|
let cha = typeof(index) === 'number' ? db.characters[index] : index
|
||||||
if(cha.chats.length === 0){
|
if(cha.chats.length === 0){
|
||||||
cha.chats = [{
|
cha.chats = [{
|
||||||
@@ -587,7 +588,7 @@ export async function makeGroupImage() {
|
|||||||
type: 'wait',
|
type: 'wait',
|
||||||
msg: `Loading..`
|
msg: `Loading..`
|
||||||
})
|
})
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const charID = get(selectedCharID)
|
const charID = get(selectedCharID)
|
||||||
const group = db.characters[charID]
|
const group = db.characters[charID]
|
||||||
if(group.type !== 'group'){
|
if(group.type !== 'group'){
|
||||||
@@ -687,7 +688,7 @@ export async function addDefaultCharacters() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let char:character = va.data
|
let char:character = va.data
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(char.emotionImages && char.emotionImages.length > 0){
|
if(char.emotionImages && char.emotionImages.length > 0){
|
||||||
for(let i=0;i<char.emotionImages.length;i++){
|
for(let i=0;i<char.emotionImages.length;i++){
|
||||||
await sleep(10)
|
await sleep(10)
|
||||||
@@ -720,7 +721,7 @@ export async function addDefaultCharacters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function removeChar(index:number,name:string, type:'normal'|'permanent'|'permanentForce' = 'normal'){
|
export async function removeChar(index:number,name:string, type:'normal'|'permanent'|'permanentForce' = 'normal'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(type !== 'permanentForce'){
|
if(type !== 'permanentForce'){
|
||||||
const conf = await alertConfirm(language.removeConfirm + name)
|
const conf = await alertConfirm(language.removeConfirm + name)
|
||||||
if(!conf){
|
if(!conf){
|
||||||
@@ -771,7 +772,7 @@ export async function addCharacter(arg:{
|
|||||||
MobileGUIStack.set(1)
|
MobileGUIStack.set(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db.characters[db.characters.length-1]){
|
if(db.characters[db.characters.length-1]){
|
||||||
changeChar(db.characters.length-1)
|
changeChar(db.characters.length-1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import { requestChatData } from "../process/request";
|
|||||||
import { checkCharOrder, globalFetch, isNodeServer, isTauri, saveAsset } from "../storage/globalApi";
|
import { checkCharOrder, globalFetch, isNodeServer, isTauri, saveAsset } from "../storage/globalApi";
|
||||||
import { tokenize } from "../tokenizer";
|
import { tokenize } from "../tokenizer";
|
||||||
import { createBlankChar } from "../characters";
|
import { createBlankChar } from "../characters";
|
||||||
import { DataBase, setDatabase, type character } from "../storage/database.svelte";
|
import { getDatabase, setDatabase, type character } from "../storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
|
||||||
import { sleep } from "../util";
|
import { sleep } from "../util";
|
||||||
import { Capacitor } from "@capacitor/core";
|
import { Capacitor } from "@capacitor/core";
|
||||||
|
|
||||||
@@ -306,7 +305,7 @@ async function createBotFromWeb() {
|
|||||||
})
|
})
|
||||||
const d = (sel === 0) ? (await createBotFromWebMain(search)) : (await createBotByAI(search))
|
const d = (sel === 0) ? (await createBotFromWebMain(search)) : (await createBotByAI(search))
|
||||||
if(d.ok === 'creation'){
|
if(d.ok === 'creation'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const cha = d.data
|
const cha = d.data
|
||||||
const fm = await createFirstMsg(cha.desc)
|
const fm = await createFirstMsg(cha.desc)
|
||||||
if(fm.type === 'multiline' || fm.type === 'fail' || fm.type === 'streaming'){
|
if(fm.type === 'multiline' || fm.type === 'fail' || fm.type === 'streaming'){
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { get } from "svelte/store"
|
|
||||||
import { hubURL } from "../characterCards"
|
import { hubURL } from "../characterCards"
|
||||||
import { DataBase } from "../storage/database.svelte"
|
import { getDatabase } from "../storage/database.svelte"
|
||||||
import { alertError, alertSelect } from "../alert"
|
import { alertError, alertSelect } from "../alert"
|
||||||
|
|
||||||
export async function risuLogin() {
|
export async function risuLogin() {
|
||||||
@@ -14,7 +13,7 @@ export async function risuLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function saveRisuAccountData() {
|
export async function saveRisuAccountData() {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(!db.account){
|
if(!db.account){
|
||||||
alertError("Not logged in error")
|
alertError("Not logged in error")
|
||||||
return
|
return
|
||||||
@@ -33,7 +32,7 @@ export async function saveRisuAccountData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadRisuAccountData() {
|
export async function loadRisuAccountData() {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(!db.account){
|
if(!db.account){
|
||||||
alertError("Not logged in error")
|
alertError("Not logged in error")
|
||||||
return
|
return
|
||||||
@@ -52,7 +51,7 @@ export async function loadRisuAccountData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadRisuAccountBackup() {
|
export async function loadRisuAccountBackup() {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(!db.account){
|
if(!db.account){
|
||||||
alertError("Not logged in error")
|
alertError("Not logged in error")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import { BaseDirectory, readFile, readDir, writeFile } from "@tauri-apps/plugin-
|
|||||||
import { alertError, alertNormal, alertStore, alertWait } from "../alert";
|
import { alertError, alertNormal, alertStore, alertWait } from "../alert";
|
||||||
import { LocalWriter, forageStorage, isTauri } from "../storage/globalApi";
|
import { LocalWriter, forageStorage, isTauri } from "../storage/globalApi";
|
||||||
import { decodeRisuSave, encodeRisuSave } from "../storage/risuSave";
|
import { decodeRisuSave, encodeRisuSave } from "../storage/risuSave";
|
||||||
import { get } from "svelte/store";
|
import { getDatabase, setDatabaseLite } from "../storage/database.svelte";
|
||||||
import { DataBase } from "../storage/database.svelte";
|
|
||||||
import { save } from "@tauri-apps/plugin-dialog";
|
|
||||||
import { relaunch } from "@tauri-apps/plugin-process";
|
import { relaunch } from "@tauri-apps/plugin-process";
|
||||||
import { sleep } from "../util";
|
import { sleep } from "../util";
|
||||||
import { hubURL } from "../characterCards";
|
import { hubURL } from "../characterCards";
|
||||||
@@ -32,7 +30,7 @@ export async function SaveLocalBackup(){
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(get(DataBase)),
|
body: JSON.stringify(getDatabase()),
|
||||||
})
|
})
|
||||||
if(corrupted.status === 400){
|
if(corrupted.status === 400){
|
||||||
alertError('Failed, Backup data is corrupted')
|
alertError('Failed, Backup data is corrupted')
|
||||||
@@ -70,7 +68,7 @@ export async function SaveLocalBackup(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbData = encodeRisuSave(get(DataBase), 'compression')
|
const dbData = encodeRisuSave(getDatabase(), 'compression')
|
||||||
|
|
||||||
alertWait(`Saving local Backup... (Saving database)`)
|
alertWait(`Saving local Backup... (Saving database)`)
|
||||||
|
|
||||||
@@ -113,7 +111,7 @@ export async function LoadLocalBackup(){
|
|||||||
if(name === 'database.risudat'){
|
if(name === 'database.risudat'){
|
||||||
const db = new Uint8Array(data)
|
const db = new Uint8Array(data)
|
||||||
const dbData = await decodeRisuSave(db)
|
const dbData = await decodeRisuSave(db)
|
||||||
DataBase.set(dbData)
|
setDatabaseLite(dbData)
|
||||||
if(isTauri){
|
if(isTauri){
|
||||||
await writeFile('database/database.bin', db, {baseDir: BaseDirectory.AppData})
|
await writeFile('database/database.bin', db, {baseDir: BaseDirectory.AppData})
|
||||||
relaunch()
|
relaunch()
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { get } from "svelte/store";
|
|
||||||
import { alertError, alertInput, alertNormal, alertSelect, alertStore } from "../alert";
|
import { alertError, alertInput, alertNormal, alertSelect, alertStore } from "../alert";
|
||||||
import { DataBase, type Database } from "../storage/database.svelte";
|
import { getDatabase, type Database } from "../storage/database.svelte";
|
||||||
import { forageStorage, getUnpargeables, isTauri, openURL } from "../storage/globalApi";
|
import { forageStorage, getUnpargeables, isTauri, openURL } from "../storage/globalApi";
|
||||||
import { BaseDirectory, exists, readFile, readDir, writeFile } from "@tauri-apps/plugin-fs";
|
import { BaseDirectory, exists, readFile, readDir, writeFile } from "@tauri-apps/plugin-fs";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
@@ -109,7 +108,7 @@ let BackupDb:Database = null
|
|||||||
|
|
||||||
|
|
||||||
export async function syncDrive() {
|
export async function syncDrive() {
|
||||||
BackupDb = structuredClone(get(DataBase))
|
BackupDb = structuredClone(getDatabase())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ async function backupDrive(ACCESS_TOKEN:string) {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(get(DataBase)),
|
body: JSON.stringify(getDatabase()),
|
||||||
})
|
})
|
||||||
if(corrupted.status === 400){
|
if(corrupted.status === 400){
|
||||||
alertError('Failed, Backup data is corrupted')
|
alertError('Failed, Backup data is corrupted')
|
||||||
@@ -177,7 +176,7 @@ async function backupDrive(ACCESS_TOKEN:string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbData = encodeRisuSave(get(DataBase), 'compression')
|
const dbData = encodeRisuSave(getDatabase(), 'compression')
|
||||||
|
|
||||||
alertStore.set({
|
alertStore.set({
|
||||||
type: "wait",
|
type: "wait",
|
||||||
@@ -206,7 +205,7 @@ async function loadDrive(ACCESS_TOKEN:string, mode: 'backup'|'sync'):Promise<voi
|
|||||||
const files:DriveFile[] = await getFilesInFolder(ACCESS_TOKEN)
|
const files:DriveFile[] = await getFilesInFolder(ACCESS_TOKEN)
|
||||||
let foragekeys:string[] = []
|
let foragekeys:string[] = []
|
||||||
let loadedForageKeys = false
|
let loadedForageKeys = false
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
|
|
||||||
async function checkImageExists(images:string) {
|
async function checkImageExists(images:string) {
|
||||||
if(db?.account?.useSync){
|
if(db?.account?.useSync){
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { get } from "svelte/store";
|
import { getDatabase } from "../storage/database.svelte";
|
||||||
import { DataBase } from "../storage/database.svelte";
|
|
||||||
|
|
||||||
export function updateAnimationSpeed(){
|
export function updateAnimationSpeed(){
|
||||||
const db = get(DataBase);
|
const db = getDatabase();
|
||||||
document.documentElement.style.setProperty('--risu-animation-speed', db.animationSpeed + 's');
|
document.documentElement.style.setProperty('--risu-animation-speed', db.animationSpeed + 's');
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { get, writable } from "svelte/store";
|
||||||
import { DataBase, setDatabase } from "../storage/database.svelte";
|
import { getDatabase, setDatabase } from "../storage/database.svelte";
|
||||||
import { downloadFile } from "../storage/globalApi";
|
import { downloadFile } from "../storage/globalApi";
|
||||||
import { BufferToText, selectSingleFile } from "../util";
|
import { BufferToText, selectSingleFile } from "../util";
|
||||||
import { alertError } from "../alert";
|
import { alertError } from "../alert";
|
||||||
@@ -115,7 +115,7 @@ export const ColorSchemeTypeStore = writable('dark' as 'dark'|'light')
|
|||||||
export const colorSchemeList = Object.keys(colorShemes) as (keyof typeof colorShemes)[]
|
export const colorSchemeList = Object.keys(colorShemes) as (keyof typeof colorShemes)[]
|
||||||
|
|
||||||
export function changeColorScheme(colorScheme: string){
|
export function changeColorScheme(colorScheme: string){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(colorScheme !== 'custom'){
|
if(colorScheme !== 'custom'){
|
||||||
db.colorScheme = structuredClone(colorShemes[colorScheme])
|
db.colorScheme = structuredClone(colorShemes[colorScheme])
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ export function changeColorScheme(colorScheme: string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function updateColorScheme(){
|
export function updateColorScheme(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
|
|
||||||
let colorScheme = db.colorScheme
|
let colorScheme = db.colorScheme
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ export function updateColorScheme(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function exportColorScheme(){
|
export function exportColorScheme(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let json = JSON.stringify(db.colorScheme)
|
let json = JSON.stringify(db.colorScheme)
|
||||||
downloadFile('colorScheme.json', json)
|
downloadFile('colorScheme.json', json)
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ export async function importColorScheme(){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
changeColorScheme('custom')
|
changeColorScheme('custom')
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.colorScheme = colorScheme
|
db.colorScheme = colorScheme
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
updateColorScheme()
|
updateColorScheme()
|
||||||
@@ -194,7 +194,7 @@ export async function importColorScheme(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function updateTextThemeAndCSS(){
|
export function updateTextThemeAndCSS(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const root = document.querySelector(':root') as HTMLElement;
|
const root = document.querySelector(':root') as HTMLElement;
|
||||||
if(!root){
|
if(!root){
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
import { DataBase } from "../storage/database.svelte";
|
import { getDatabase } from "../storage/database.svelte";
|
||||||
|
|
||||||
export let textAreaSize = writable(0)
|
export let textAreaSize = writable(0)
|
||||||
export let sideBarSize = writable(0)
|
export let sideBarSize = writable(0)
|
||||||
export let textAreaTextSize = writable(0)
|
export let textAreaTextSize = writable(0)
|
||||||
|
|
||||||
export function updateGuisize(){
|
export function updateGuisize(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const root = document.querySelector(':root') as HTMLElement;
|
const root = document.querySelector(':root') as HTMLElement;
|
||||||
if(!root){
|
if(!root){
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { alertSelect, alertToast, doingAlert } from "./alert"
|
import { alertSelect, alertToast, doingAlert } from "./alert"
|
||||||
import { DataBase, changeToPreset as changeToPreset2 } from "./storage/database.svelte"
|
import { changeToPreset as changeToPreset2, getDatabase } from "./storage/database.svelte"
|
||||||
import { MobileGUIStack, MobileSideBar, openPersonaList, openPresetList, SafeModeStore, selectedCharID, settingsOpen } from "./stores"
|
import { MobileGUIStack, MobileSideBar, openPersonaList, openPresetList, SafeModeStore, selectedCharID, settingsOpen } from "./stores"
|
||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
import { updateTextThemeAndCSS } from "./gui/colorscheme"
|
import { updateTextThemeAndCSS } from "./gui/colorscheme"
|
||||||
@@ -197,7 +197,7 @@ export function initMobileGesture(){
|
|||||||
|
|
||||||
function changeToPreset(num:number){
|
function changeToPreset(num:number){
|
||||||
if(!doingAlert()){
|
if(!doingAlert()){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let pres = db.botPresets
|
let pres = db.botPresets
|
||||||
if(pres.length > num){
|
if(pres.length > num){
|
||||||
alertToast(`Changed to Preset: ${pres[num].name}`)
|
alertToast(`Changed to Preset: ${pres[num].name}`)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { get } from "svelte/store"
|
|
||||||
import { alertNormal, alertSelect } from "../alert"
|
import { alertNormal, alertSelect } from "../alert"
|
||||||
import { keiServerURL } from "./kei"
|
import { keiServerURL } from "./kei"
|
||||||
import { DataBase, setDatabase } from "../storage/database.svelte"
|
import { getDatabase, setDatabase } from "../storage/database.svelte"
|
||||||
|
|
||||||
export async function autoServerBackup(){
|
export async function autoServerBackup(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const res = await fetch(keiServerURL() + '/autobackup/list', {
|
const res = await fetch(keiServerURL() + '/autobackup/list', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -81,7 +80,7 @@ export async function autoServerBackup(){
|
|||||||
let lastKeiSave = 0
|
let lastKeiSave = 0
|
||||||
export async function saveDbKei() {
|
export async function saveDbKei() {
|
||||||
try{
|
try{
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db.account.kei){
|
if(db.account.kei){
|
||||||
if(Date.now() - lastKeiSave < 60000 * 5){
|
if(Date.now() - lastKeiSave < 60000 * 5){
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { get } from "svelte/store";
|
|
||||||
import { hubURL } from "../characterCards";
|
import { hubURL } from "../characterCards";
|
||||||
import { DataBase } from "../storage/database.svelte";
|
import { getDatabase } from "../storage/database.svelte";
|
||||||
|
|
||||||
export function keiServerURL(){
|
export function keiServerURL(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(db.keiServerURL) return db.keiServerURL;
|
if(db.keiServerURL) return db.keiServerURL;
|
||||||
return hubURL + "/kei";
|
return hubURL + "/kei";
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import { get } from "svelte/store"
|
import { getDatabase } from "../storage/database.svelte"
|
||||||
import { DataBase } from "../storage/database.svelte"
|
|
||||||
|
|
||||||
export async function openRouterModels() {
|
export async function openRouterModels() {
|
||||||
try {
|
try {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let headers = {
|
let headers = {
|
||||||
"Authorization": "Bearer " + db.openrouterKey,
|
"Authorization": "Bearer " + db.openrouterKey,
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import DOMPurify from 'isomorphic-dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
import markdownit from 'markdown-it'
|
import markdownit from 'markdown-it'
|
||||||
import { DataBase, getCurrentCharacter, setDatabase, type Database, type Message, type character, type customscript, type groupChat, type triggerscript } from './storage/database.svelte';
|
import { getCurrentCharacter, getDatabase, setDatabase, type Database, type Message, type character, type customscript, type groupChat, type triggerscript } from './storage/database.svelte';
|
||||||
import { getFileSrc } from './storage/globalApi';
|
import { getFileSrc } from './storage/globalApi';
|
||||||
import { processScriptFull } from './process/scripts';
|
import { processScriptFull } from './process/scripts';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
@@ -75,7 +75,7 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
|
|||||||
|
|
||||||
|
|
||||||
function renderMarkdown(md:markdownit, data:string){
|
function renderMarkdown(md:markdownit, data:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let quotes = ['“', '”', '‘', '’']
|
let quotes = ['“', '”', '‘', '’']
|
||||||
if(db?.customQuotes){
|
if(db?.customQuotes){
|
||||||
quotes = db.customQuotesData ?? quotes
|
quotes = db.customQuotesData ?? quotes
|
||||||
@@ -254,7 +254,7 @@ async function renderHighlightableMarkdown(data:string) {
|
|||||||
export const assetRegex = /{{(raw|path|img|image|video|audio|bg|emotion|asset|video-img|source)::(.+?)}}/g
|
export const assetRegex = /{{(raw|path|img|image|video|audio|bg|emotion|asset|video-img|source)::(.+?)}}/g
|
||||||
|
|
||||||
async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|character, mode:'normal'|'back', mode2:'unset'|'pre'|'post' = 'unset'){
|
async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|character, mode:'normal'|'back', mode2:'unset'|'pre'|'post' = 'unset'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const assetWidthString = (db.assetWidth && db.assetWidth !== -1 || db.assetWidth === 0) ? `max-width:${db.assetWidth}rem;` : ''
|
const assetWidthString = (db.assetWidth && db.assetWidth !== -1 || db.assetWidth === 0) ? `max-width:${db.assetWidth}rem;` : ''
|
||||||
|
|
||||||
let assetPaths:{[key:string]:{
|
let assetPaths:{[key:string]:{
|
||||||
@@ -500,7 +500,7 @@ export async function hasher(data:Uint8Array){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function convertImage(data:Uint8Array) {
|
export async function convertImage(data:Uint8Array) {
|
||||||
if(!get(DataBase).imageCompression){
|
if(!getDatabase().imageCompression){
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
const type = checkImageType(data)
|
const type = checkImageType(data)
|
||||||
@@ -1775,7 +1775,7 @@ export function risuChatParser(da:string, arg:{
|
|||||||
cbsConditions?:CbsConditions
|
cbsConditions?:CbsConditions
|
||||||
} = {}):string{
|
} = {}):string{
|
||||||
const chatID = arg.chatID ?? -1
|
const chatID = arg.chatID ?? -1
|
||||||
const db = arg.db ?? get(DataBase)
|
const db = arg.db ?? getDatabase()
|
||||||
const aChara = arg.chara
|
const aChara = arg.chara
|
||||||
const visualize = arg.visualize ?? false
|
const visualize = arg.visualize ?? false
|
||||||
let chara:character|string = null
|
let chara:character|string = null
|
||||||
@@ -1797,7 +1797,7 @@ export function risuChatParser(da:string, arg:{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(arg.tokenizeAccurate){
|
if(arg.tokenizeAccurate){
|
||||||
const db = arg.db ?? get(DataBase)
|
const db = arg.db ?? getDatabase()
|
||||||
const selchar = chara ?? db.characters[get(selectedCharID)]
|
const selchar = chara ?? db.characters[get(selectedCharID)]
|
||||||
if(!selchar){
|
if(!selchar){
|
||||||
chara = 'bot'
|
chara = 'bot'
|
||||||
@@ -2103,7 +2103,7 @@ export function risuChatParser(da:string, arg:{
|
|||||||
|
|
||||||
|
|
||||||
export function getChatVar(key:string){
|
export function getChatVar(key:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
if(!char){
|
if(!char){
|
||||||
@@ -2126,12 +2126,12 @@ export function getChatVar(key:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getGlobalChatVar(key:string){
|
export function getGlobalChatVar(key:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.globalChatVariables[key] ?? 'null'
|
return db.globalChatVariables[key] ?? 'null'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setChatVar(key:string, value:string){
|
export function setChatVar(key:string, value:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { DataBase, saveImage, setDatabase } from "./storage/database.svelte"
|
import { getDatabase, saveImage, setDatabase } from "./storage/database.svelte"
|
||||||
import { getUserName, selectSingleFile, sleep } from "./util"
|
import { getUserName, selectSingleFile, sleep } from "./util"
|
||||||
import { alertError, alertNormal, alertStore } from "./alert"
|
import { alertError, alertNormal, alertStore } from "./alert"
|
||||||
import { downloadFile, readImage } from "./storage/globalApi"
|
import { downloadFile, readImage } from "./storage/globalApi"
|
||||||
@@ -14,7 +14,7 @@ export async function selectUserImg() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const img = selected.data
|
const img = selected.data
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const imgp = await saveImage(img)
|
const imgp = await saveImage(img)
|
||||||
db.userIcon = imgp
|
db.userIcon = imgp
|
||||||
db.personas[db.selectedPersona] = {
|
db.personas[db.selectedPersona] = {
|
||||||
@@ -27,7 +27,7 @@ export async function selectUserImg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function saveUserPersona() {
|
export function saveUserPersona() {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.personas[db.selectedPersona].name=db.username
|
db.personas[db.selectedPersona].name=db.username
|
||||||
db.personas[db.selectedPersona].icon=db.userIcon,
|
db.personas[db.selectedPersona].icon=db.userIcon,
|
||||||
db.personas[db.selectedPersona].personaPrompt=db.personaPrompt,
|
db.personas[db.selectedPersona].personaPrompt=db.personaPrompt,
|
||||||
@@ -39,7 +39,7 @@ export function changeUserPersona(id:number, save:'save'|'noSave' = 'save') {
|
|||||||
if(save === 'save'){
|
if(save === 'save'){
|
||||||
saveUserPersona()
|
saveUserPersona()
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const pr = db.personas[id]
|
const pr = db.personas[id]
|
||||||
db.personaPrompt = pr.personaPrompt
|
db.personaPrompt = pr.personaPrompt
|
||||||
db.username = pr.name,
|
db.username = pr.name,
|
||||||
@@ -56,7 +56,7 @@ interface PersonaCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function exportUserPersona(){
|
export async function exportUserPersona(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase({snapshot: true})
|
||||||
if(!db.userIcon){
|
if(!db.userIcon){
|
||||||
alertError(language.errors.noUserIcon)
|
alertError(language.errors.noUserIcon)
|
||||||
return
|
return
|
||||||
@@ -107,7 +107,7 @@ export async function importUserPersona(){
|
|||||||
}
|
}
|
||||||
const data:PersonaCard = JSON.parse(Buffer.from(decoded, 'base64').toString('utf-8'))
|
const data:PersonaCard = JSON.parse(Buffer.from(decoded, 'base64').toString('utf-8'))
|
||||||
if(data.name && data.personaPrompt){
|
if(data.name && data.personaPrompt){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.personas.push({
|
db.personas.push({
|
||||||
name: data.name,
|
name: data.name,
|
||||||
icon: await saveImage(await reencodeImage(v.data)),
|
icon: await saveImage(await reencodeImage(v.data)),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { get } from 'svelte/store'
|
|||||||
import type { ScriptMode } from '../process/scripts'
|
import type { ScriptMode } from '../process/scripts'
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import WorkerUrl from './embedworker?worker&url'
|
import WorkerUrl from './embedworker?worker&url'
|
||||||
import { DataBase, type Message } from '../storage/database.svelte'
|
import { getDatabase, type Message } from '../storage/database.svelte'
|
||||||
import { selectedCharID } from '../stores'
|
import { selectedCharID } from '../stores'
|
||||||
import { setDatabase } from '../storage/database.svelte'
|
import { setDatabase } from '../storage/database.svelte'
|
||||||
|
|
||||||
@@ -77,14 +77,16 @@ function runVirtualJS(code:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
addWorkerFunction('getChat', async () => {
|
addWorkerFunction('getChat', async () => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase({
|
||||||
|
snapshot: true
|
||||||
|
})
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return structuredClone(char.chats[char.chatPage].message)
|
return structuredClone(char.chats[char.chatPage].message)
|
||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setChat', async (data:Message[]) => {
|
addWorkerFunction('setChat', async (data:Message[]) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
let newChat:Message[] = []
|
let newChat:Message[] = []
|
||||||
for(const dat of data){
|
for(const dat of data){
|
||||||
@@ -117,14 +119,14 @@ addWorkerFunction('setChat', async (data:Message[]) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('getName', async () => {
|
addWorkerFunction('getName', async () => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return char.name
|
return char.name
|
||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setName', async (data:string) => {
|
addWorkerFunction('setName', async (data:string) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
return false
|
return false
|
||||||
@@ -135,7 +137,7 @@ addWorkerFunction('setName', async (data:string) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('getDescription', async () => {
|
addWorkerFunction('getDescription', async () => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
if(char.type === 'group'){
|
if(char.type === 'group'){
|
||||||
@@ -145,7 +147,7 @@ addWorkerFunction('getDescription', async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setDescription', async (data:string) => {
|
addWorkerFunction('setDescription', async (data:string) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char =db.characters[selectedChar]
|
const char =db.characters[selectedChar]
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
@@ -161,14 +163,14 @@ addWorkerFunction('setDescription', async (data:string) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('getCharacterFirstMessage', async () => {
|
addWorkerFunction('getCharacterFirstMessage', async () => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return char.firstMessage
|
return char.firstMessage
|
||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setCharacterFirstMessage', async (data:string) => {
|
addWorkerFunction('setCharacterFirstMessage', async (data:string) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
@@ -181,14 +183,14 @@ addWorkerFunction('setCharacterFirstMessage', async (data:string) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('getBackgroundEmbedding', async () => {
|
addWorkerFunction('getBackgroundEmbedding', async () => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return char.backgroundHTML
|
return char.backgroundHTML
|
||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setBackgroundEmbedding', async (data:string) => {
|
addWorkerFunction('setBackgroundEmbedding', async (data:string) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
return false
|
return false
|
||||||
@@ -200,7 +202,7 @@ addWorkerFunction('setBackgroundEmbedding', async (data:string) => {
|
|||||||
|
|
||||||
|
|
||||||
addWorkerFunction('getState', async (statename) => {
|
addWorkerFunction('getState', async (statename) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
@@ -208,7 +210,7 @@ addWorkerFunction('getState', async (statename) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setState', async (statename, data) => {
|
addWorkerFunction('setState', async (statename, data) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
@@ -245,7 +247,7 @@ export async function runCharacterJS(arg:{
|
|||||||
}):Promise<any>{
|
}):Promise<any>{
|
||||||
try {
|
try {
|
||||||
if(arg.code === null){
|
if(arg.code === null){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
arg.code = db.characters[selectedChar].virtualscript
|
arg.code = db.characters[selectedChar].virtualscript
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { get, writable } from "svelte/store";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { alertError } from "../alert";
|
import { alertError } from "../alert";
|
||||||
import { DataBase } from "../storage/database.svelte";
|
import { getDatabase, setDatabaseLite } from "../storage/database.svelte";
|
||||||
import { checkNullish, selectSingleFile, sleep } from "../util";
|
import { checkNullish, selectSingleFile, sleep } from "../util";
|
||||||
import type { OpenAIChat } from "../process";
|
import type { OpenAIChat } from "../process";
|
||||||
import { globalFetch } from "../storage/globalApi";
|
import { globalFetch } from "../storage/globalApi";
|
||||||
@@ -29,7 +29,7 @@ export type RisuPlugin = ProviderPlugin
|
|||||||
|
|
||||||
export async function importPlugin(){
|
export async function importPlugin(){
|
||||||
try {
|
try {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const f = await selectSingleFile(['js'])
|
const f = await selectSingleFile(['js'])
|
||||||
if(!f){
|
if(!f){
|
||||||
return
|
return
|
||||||
@@ -96,7 +96,7 @@ export async function importPlugin(){
|
|||||||
db.plugins ??= []
|
db.plugins ??= []
|
||||||
db.plugins.push(pluginData)
|
db.plugins.push(pluginData)
|
||||||
|
|
||||||
DataBase.set(db)
|
setDatabaseLite(db)
|
||||||
loadPlugins()
|
loadPlugins()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@@ -123,7 +123,7 @@ function postMsgPluginWorker(type:string, body:any){
|
|||||||
let pluginTranslator = false
|
let pluginTranslator = false
|
||||||
|
|
||||||
export async function loadPlugins() {
|
export async function loadPlugins() {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(pluginWorker){
|
if(pluginWorker){
|
||||||
pluginWorker.terminate()
|
pluginWorker.terminate()
|
||||||
pluginWorker = null
|
pluginWorker = null
|
||||||
@@ -219,7 +219,7 @@ export async function loadPlugins() {
|
|||||||
}
|
}
|
||||||
case "getArg":{
|
case "getArg":{
|
||||||
try {
|
try {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const arg:string[] = data.body.arg.split('::')
|
const arg:string[] = data.body.arg.split('::')
|
||||||
for(const plug of db.plugins){
|
for(const plug of db.plugins){
|
||||||
if(arg[0] === plug.name){
|
if(arg[0] === plug.name){
|
||||||
@@ -243,7 +243,7 @@ export async function loadPlugins() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "getChar":{
|
case "getChar":{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const charid = get(selectedCharID)
|
const charid = get(selectedCharID)
|
||||||
const char = db.characters[charid]
|
const char = db.characters[charid]
|
||||||
postMsgPluginWorker('fetchData',{
|
postMsgPluginWorker('fetchData',{
|
||||||
@@ -253,7 +253,7 @@ export async function loadPlugins() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "setChar":{
|
case "setChar":{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const charid = get(selectedCharID)
|
const charid = get(selectedCharID)
|
||||||
db.characters[charid] = data.body
|
db.characters[charid] = data.body
|
||||||
break
|
break
|
||||||
@@ -303,7 +303,7 @@ export async function pluginProcess(arg:{
|
|||||||
bias: {[key:string]:string}
|
bias: {[key:string]:string}
|
||||||
}|{}){
|
}|{}){
|
||||||
try {
|
try {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(!pluginWorker){
|
if(!pluginWorker){
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { DataBase, getCurrentCharacter, getCurrentChat, setCurrentChat, setDatabase } from "../storage/database.svelte";
|
import { getCurrentCharacter, getCurrentChat, getDatabase, setCurrentChat, setDatabase } from "../storage/database.svelte";
|
||||||
import { selectedCharID } from "../stores";
|
import { selectedCharID } from "../stores";
|
||||||
import { alertInput, alertMd, alertNormal, alertSelect, alertToast } from "../alert";
|
import { alertInput, alertMd, alertNormal, alertSelect, alertToast } from "../alert";
|
||||||
import { sayTTS } from "./tts";
|
import { sayTTS } from "./tts";
|
||||||
@@ -40,7 +40,7 @@ export async function processMultiCommand(command:string) {
|
|||||||
|
|
||||||
|
|
||||||
async function processCommand(command:string, pipe:string):Promise<false | string>{
|
async function processCommand(command:string, pipe:string):Promise<false | string>{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const currentChar = db.characters[get(selectedCharID)]
|
const currentChar = db.characters[get(selectedCharID)]
|
||||||
const currentChat = currentChar.chats[currentChar.chatPage]
|
const currentChat = currentChar.chats[currentChar.chatPage]
|
||||||
let {commandName, arg, namedArg} = commandParser(command, pipe)
|
let {commandName, arg, namedArg} = commandParser(command, pipe)
|
||||||
@@ -180,7 +180,7 @@ async function processCommand(command:string, pipe:string):Promise<false | strin
|
|||||||
}
|
}
|
||||||
case 'setvar':{
|
case 'setvar':{
|
||||||
console.log(namedArg, arg)
|
console.log(namedArg, arg)
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
@@ -194,7 +194,7 @@ async function processCommand(command:string, pipe:string):Promise<false | strin
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
case 'addvar':{
|
case 'addvar':{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
@@ -207,7 +207,7 @@ async function processCommand(command:string, pipe:string):Promise<false | strin
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
case 'getvar':{
|
case 'getvar':{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import { DataBase, type Chat, type character } from "src/ts/storage/database.svelte";
|
import { getDatabase, type Chat, type character } from "src/ts/storage/database.svelte";
|
||||||
import { HypaProcesser } from '../memory/hypamemory'
|
import { HypaProcesser } from '../memory/hypamemory'
|
||||||
import type { OpenAIChat } from "..";
|
|
||||||
import { stringlizeChat } from "../stringlize";
|
|
||||||
import { get } from "svelte/store";
|
|
||||||
import { getUserName } from "src/ts/util";
|
import { getUserName } from "src/ts/util";
|
||||||
|
|
||||||
export async function additionalInformations(char: character,chats:Chat,){
|
export async function additionalInformations(char: character,chats:Chat,){
|
||||||
const processer = new HypaProcesser('MiniLM')
|
const processer = new HypaProcesser('MiniLM')
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
|
|
||||||
const info = char.additionalText
|
const info = char.additionalText
|
||||||
if(info){
|
if(info){
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import localforage from "localforage";
|
import localforage from "localforage";
|
||||||
import { selectSingleFile } from "../../util";
|
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import { DataBase } from "../../storage/database.svelte";
|
import { getDatabase } from "../../storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
|
||||||
import { checkImageType } from "../../parser";
|
import { checkImageType } from "../../parser";
|
||||||
|
|
||||||
const inlayStorage = localforage.createInstance({
|
const inlayStorage = localforage.createInstance({
|
||||||
@@ -85,7 +83,7 @@ export async function getInlayImage(id: string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function supportsInlayImage(){
|
export function supportsInlayImage(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.aiModel.startsWith('gptv') || db.aiModel === 'gemini-pro-vision' || db.aiModel.startsWith('claude-3') || db.aiModel.startsWith('gpt4_turbo') || db.aiModel.startsWith('gpt5') || db.aiModel.startsWith('gpt4o') ||
|
return db.aiModel.startsWith('gptv') || db.aiModel === 'gemini-pro-vision' || db.aiModel.startsWith('claude-3') || db.aiModel.startsWith('gpt4_turbo') || db.aiModel.startsWith('gpt5') || db.aiModel.startsWith('gpt4o') ||
|
||||||
(db.aiModel === 'reverse_proxy' && (
|
(db.aiModel === 'reverse_proxy' && (
|
||||||
db.proxyRequestModel?.startsWith('gptv') || db.proxyRequestModel === 'gemini-pro-vision' || db.proxyRequestModel?.startsWith('claude-3') || db.proxyRequestModel.startsWith('gpt4_turbo') ||
|
db.proxyRequestModel?.startsWith('gptv') || db.proxyRequestModel === 'gemini-pro-vision' || db.proxyRequestModel?.startsWith('claude-3') || db.proxyRequestModel.startsWith('gpt4_turbo') ||
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DataBase, setDatabase } from 'src/ts/storage/database.svelte';
|
import { getDatabase, setDatabase } from 'src/ts/storage/database.svelte';
|
||||||
import { selectedCharID } from 'src/ts/stores';
|
import { selectedCharID } from 'src/ts/stores';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import { doingChat, sendChat } from '..';
|
import { doingChat, sendChat } from '..';
|
||||||
@@ -19,7 +19,7 @@ async function sendPofile(arg:sendFileArg){
|
|||||||
let note = ''
|
let note = ''
|
||||||
let speaker = ''
|
let speaker = ''
|
||||||
let parseMode = 0
|
let parseMode = 0
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let currentChar = db.characters[get(selectedCharID)]
|
let currentChar = db.characters[get(selectedCharID)]
|
||||||
let currentChat = currentChar.chats[currentChar.chatPage]
|
let currentChat = currentChar.chats[currentChar.chatPage]
|
||||||
const lines = arg.file.split('\n')
|
const lines = arg.file.split('\n')
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { findCharacterbyId } from "../util";
|
|||||||
import { alertConfirm, alertError, alertSelectChar } from "../alert";
|
import { alertConfirm, alertError, alertSelectChar } from "../alert";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { DataBase, setDatabase } from "../storage/database.svelte";
|
import { getDatabase, setDatabase } from "../storage/database.svelte";
|
||||||
import { selectedCharID } from "../stores";
|
import { selectedCharID } from "../stores";
|
||||||
|
|
||||||
export async function addGroupChar(){
|
export async function addGroupChar(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let selectedId = get(selectedCharID)
|
let selectedId = get(selectedCharID)
|
||||||
let group = db.characters[selectedId]
|
let group = db.characters[selectedId]
|
||||||
if(group.type === 'group'){
|
if(group.type === 'group'){
|
||||||
@@ -36,7 +36,7 @@ export async function addGroupChar(){
|
|||||||
|
|
||||||
|
|
||||||
export function rmCharFromGroup(index:number){
|
export function rmCharFromGroup(index:number){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let selectedId = get(selectedCharID)
|
let selectedId = get(selectedCharID)
|
||||||
let group = db.characters[selectedId]
|
let group = db.characters[selectedId]
|
||||||
if(group.type === 'group'){
|
if(group.type === 'group'){
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { get, writable } from "svelte/store";
|
||||||
import { DataBase, setDatabase, type character, type MessageGenerationInfo, type Chat } from "../storage/database.svelte";
|
import { setDatabase, type character, type MessageGenerationInfo, type Chat, getDatabase, setDatabaseLite } from "../storage/database.svelte";
|
||||||
import { CharEmotion, selectedCharID } from "../stores";
|
import { CharEmotion, selectedCharID } from "../stores";
|
||||||
import { ChatTokenizer, tokenize, tokenizeNum } from "../tokenizer";
|
import { ChatTokenizer, tokenize, tokenizeNum } from "../tokenizer";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { alertError } from "../alert";
|
import { alertError } from "../alert";
|
||||||
import { loadLoreBookPrompt, loadLoreBookV3Prompt } from "./lorebook";
|
import { loadLoreBookV3Prompt } from "./lorebook";
|
||||||
import { findCharacterbyId, getAuthorNoteDefaultText, getPersonaPrompt, getUserName, isLastCharPunctuation, trimUntilPunctuation } from "../util";
|
import { findCharacterbyId, getAuthorNoteDefaultText, getPersonaPrompt, getUserName, isLastCharPunctuation, trimUntilPunctuation } from "../util";
|
||||||
import { requestChatData } from "./request";
|
import { requestChatData } from "./request";
|
||||||
import { stableDiff } from "./stableDiff";
|
import { stableDiff } from "./stableDiff";
|
||||||
@@ -120,7 +120,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
chatProcessStage.set(0)
|
chatProcessStage.set(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.statics.messages += 1
|
db.statics.messages += 1
|
||||||
let selectedChar = get(selectedCharID)
|
let selectedChar = get(selectedCharID)
|
||||||
const nowChatroom = db.characters[selectedChar]
|
const nowChatroom = db.characters[selectedChar]
|
||||||
@@ -783,7 +783,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
currentChat.hypaV2Data = sp.memory ?? currentChat.hypaV2Data
|
currentChat.hypaV2Data = sp.memory ?? currentChat.hypaV2Data
|
||||||
db.characters[selectedChar].chats[selectedChat].hypaV2Data = currentChat.hypaV2Data
|
db.characters[selectedChar].chats[selectedChat].hypaV2Data = currentChat.hypaV2Data
|
||||||
console.log(currentChat.hypaV2Data)
|
console.log(currentChat.hypaV2Data)
|
||||||
DataBase.set(db)
|
setDatabaseLite(db)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
const sp = await supaMemory(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer, {
|
const sp = await supaMemory(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer, {
|
||||||
@@ -798,7 +798,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
currentChat.supaMemoryData = sp.memory ?? currentChat.supaMemoryData
|
currentChat.supaMemoryData = sp.memory ?? currentChat.supaMemoryData
|
||||||
db.characters[selectedChar].chats[selectedChat].supaMemoryData = currentChat.supaMemoryData
|
db.characters[selectedChar].chats[selectedChat].supaMemoryData = currentChat.supaMemoryData
|
||||||
console.log(currentChat.supaMemoryData)
|
console.log(currentChat.supaMemoryData)
|
||||||
DataBase.set(db)
|
setDatabaseLite(db)
|
||||||
currentChat.lastMemory = sp.lastId ?? currentChat.lastMemory;
|
currentChat.lastMemory = sp.lastId ?? currentChat.lastMemory;
|
||||||
}
|
}
|
||||||
chatProcessStage.set(1)
|
chatProcessStage.set(1)
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import {selectedCharID} from '../stores'
|
import {selectedCharID} from '../stores'
|
||||||
import { DataBase, setDatabase, type Message, type loreBook } from "../storage/database.svelte";
|
import { getDatabase, setDatabase, type Message, type loreBook } from "../storage/database.svelte";
|
||||||
import { tokenize } from "../tokenizer";
|
import { tokenize } from "../tokenizer";
|
||||||
import { checkNullish, selectSingleFile } from "../util";
|
import { checkNullish, selectSingleFile } from "../util";
|
||||||
import { alertError, alertNormal } from "../alert";
|
import { alertError, alertNormal } from "../alert";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { downloadFile } from "../storage/globalApi";
|
import { downloadFile } from "../storage/globalApi";
|
||||||
import { HypaProcesser } from "./memory/hypamemory";
|
|
||||||
import { getModuleLorebooks } from "./modules";
|
import { getModuleLorebooks } from "./modules";
|
||||||
import { CCardLib } from "@risuai/ccardlib";
|
import { CCardLib } from "@risuai/ccardlib";
|
||||||
|
|
||||||
export function addLorebook(type:number) {
|
export function addLorebook(type:number) {
|
||||||
let selectedID = get(selectedCharID)
|
let selectedID = get(selectedCharID)
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(type === 0){
|
if(type === 0){
|
||||||
db.characters[selectedID].globalLore.push({
|
db.characters[selectedID].globalLore.push({
|
||||||
key: '',
|
key: '',
|
||||||
@@ -54,7 +53,7 @@ const rmRegex = / |\n/g
|
|||||||
export async function loadLoreBookPrompt(){
|
export async function loadLoreBookPrompt(){
|
||||||
|
|
||||||
const selectedID = get(selectedCharID)
|
const selectedID = get(selectedCharID)
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const char = db.characters[selectedID]
|
const char = db.characters[selectedID]
|
||||||
const page = char.chatPage
|
const page = char.chatPage
|
||||||
const characterLore = char.globalLore ?? []
|
const characterLore = char.globalLore ?? []
|
||||||
@@ -209,7 +208,7 @@ export async function loadLoreBookPrompt(){
|
|||||||
|
|
||||||
export async function loadLoreBookV3Prompt(){
|
export async function loadLoreBookV3Prompt(){
|
||||||
const selectedID = get(selectedCharID)
|
const selectedID = get(selectedCharID)
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const char = db.characters[selectedID]
|
const char = db.characters[selectedID]
|
||||||
const page = char.chatPage
|
const page = char.chatPage
|
||||||
const characterLore = char.globalLore ?? []
|
const characterLore = char.globalLore ?? []
|
||||||
@@ -531,7 +530,7 @@ export async function loadLoreBookV3Prompt(){
|
|||||||
|
|
||||||
export async function importLoreBook(mode:'global'|'local'|'sglobal'){
|
export async function importLoreBook(mode:'global'|'local'|'sglobal'){
|
||||||
const selectedID = get(selectedCharID)
|
const selectedID = get(selectedCharID)
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
|
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
|
||||||
let lore =
|
let lore =
|
||||||
mode === 'global' ? db.characters[selectedID].globalLore :
|
mode === 'global' ? db.characters[selectedID].globalLore :
|
||||||
@@ -613,7 +612,7 @@ export function convertExternalLorebook(entries:{[key:string]:CCLorebook}){
|
|||||||
export async function exportLoreBook(mode:'global'|'local'|'sglobal'){
|
export async function exportLoreBook(mode:'global'|'local'|'sglobal'){
|
||||||
try {
|
try {
|
||||||
const selectedID = get(selectedCharID)
|
const selectedID = get(selectedCharID)
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
|
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
|
||||||
const lore =
|
const lore =
|
||||||
mode === 'global' ? db.characters[selectedID].globalLore :
|
mode === 'global' ? db.characters[selectedID].globalLore :
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getChatVar, hasher, risuChatParser, setChatVar, type simpleCharacterArgument } from "../parser";
|
import { getChatVar, hasher, setChatVar, type simpleCharacterArgument } from "../parser";
|
||||||
import { LuaEngine, LuaFactory } from "wasmoon";
|
import { LuaEngine, LuaFactory } from "wasmoon";
|
||||||
import { DataBase, getCurrentCharacter, getCurrentChat, setCurrentChat, setDatabase, type Chat, type character, type groupChat } from "../storage/database.svelte";
|
import { getCurrentCharacter, getCurrentChat, getDatabase, setCurrentChat, setDatabase, type Chat, type character, type groupChat } from "../storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { ReloadGUIPointer, selectedCharID } from "../stores";
|
import { ReloadGUIPointer, selectedCharID } from "../stores";
|
||||||
import { alertError, alertInput, alertNormal } from "../alert";
|
import { alertError, alertInput, alertNormal } from "../alert";
|
||||||
@@ -332,7 +332,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return char.name
|
return char.name
|
||||||
@@ -342,7 +342,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
if(typeof name !== 'string'){
|
if(typeof name !== 'string'){
|
||||||
throw('Invalid data type')
|
throw('Invalid data type')
|
||||||
@@ -355,7 +355,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char =db.characters[selectedChar]
|
const char =db.characters[selectedChar]
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
@@ -373,7 +373,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
@@ -389,7 +389,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return char.firstMessage
|
return char.firstMessage
|
||||||
@@ -399,7 +399,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return char.backgroundHTML
|
return char.backgroundHTML
|
||||||
@@ -409,7 +409,7 @@ export async function runLua(code:string, arg:{
|
|||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
if(typeof data !== 'string'){
|
if(typeof data !== 'string'){
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import type { OpenAIChat } from "..";
|
|||||||
import { HypaProcesser } from "./hypamemory";
|
import { HypaProcesser } from "./hypamemory";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import type { ChatTokenizer } from "src/ts/tokenizer";
|
import type { ChatTokenizer } from "src/ts/tokenizer";
|
||||||
import { get } from "svelte/store";
|
import { getDatabase } from "src/ts/storage/database.svelte";
|
||||||
import { DataBase } from "src/ts/storage/database.svelte";
|
|
||||||
|
|
||||||
const maxRecentChatQuery = 4;
|
const maxRecentChatQuery = 4;
|
||||||
export async function hanuraiMemory(chats:OpenAIChat[],arg:{
|
export async function hanuraiMemory(chats:OpenAIChat[],arg:{
|
||||||
@@ -12,7 +11,7 @@ export async function hanuraiMemory(chats:OpenAIChat[],arg:{
|
|||||||
maxContextTokens:number,
|
maxContextTokens:number,
|
||||||
tokenizer:ChatTokenizer
|
tokenizer:ChatTokenizer
|
||||||
}){
|
}){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const tokenizer = arg.tokenizer
|
const tokenizer = arg.tokenizer
|
||||||
const processer = new HypaProcesser('MiniLM')
|
const processer = new HypaProcesser('MiniLM')
|
||||||
let addTexts:string[] = []
|
let addTexts:string[] = []
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { DataBase, type Chat, type character, type groupChat } from "src/ts/storage/database.svelte";
|
import { getDatabase, type Chat, type character, type groupChat } from "src/ts/storage/database.svelte";
|
||||||
import type { OpenAIChat } from "..";
|
import type { OpenAIChat } from "..";
|
||||||
import type { ChatTokenizer } from "src/ts/tokenizer";
|
import type { ChatTokenizer } from "src/ts/tokenizer";
|
||||||
import { get } from "svelte/store";
|
|
||||||
import { requestChatData } from "../request";
|
import { requestChatData } from "../request";
|
||||||
import { HypaProcesser } from "./hypamemory";
|
import { HypaProcesser } from "./hypamemory";
|
||||||
import { globalFetch } from "src/ts/storage/globalApi";
|
import { globalFetch } from "src/ts/storage/globalApi";
|
||||||
import { runSummarizer } from "../transformers";
|
import { runSummarizer } from "../transformers";
|
||||||
import { last, remove } from "lodash";
|
|
||||||
|
|
||||||
export interface HypaV2Data {
|
export interface HypaV2Data {
|
||||||
chunks: {
|
chunks: {
|
||||||
@@ -20,7 +18,7 @@ export interface HypaV2Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function summary(stringlizedChat: string): Promise<{ success: boolean; data: string }> {
|
async function summary(stringlizedChat: string): Promise<{ success: boolean; data: string }> {
|
||||||
const db = get(DataBase);
|
const db = getDatabase();
|
||||||
console.log("Summarizing");
|
console.log("Summarizing");
|
||||||
|
|
||||||
if (db.supaModelType === 'distilbart') {
|
if (db.supaModelType === 'distilbart') {
|
||||||
@@ -123,7 +121,7 @@ export async function hypaMemoryV2(
|
|||||||
arg: { asHyper?: boolean, summaryModel?: string, summaryPrompt?: string, hypaModel?: string } = {}
|
arg: { asHyper?: boolean, summaryModel?: string, summaryPrompt?: string, hypaModel?: string } = {}
|
||||||
): Promise<{ currentTokens: number; chats: OpenAIChat[]; error?: string; memory?: HypaV2Data; }> {
|
): Promise<{ currentTokens: number; chats: OpenAIChat[]; error?: string; memory?: HypaV2Data; }> {
|
||||||
|
|
||||||
const db = get(DataBase);
|
const db = getDatabase();
|
||||||
const data: HypaV2Data = room.hypaV2Data ?? { chunks: [], mainChunks: [] };
|
const data: HypaV2Data = room.hypaV2Data ?? { chunks: [], mainChunks: [] };
|
||||||
|
|
||||||
let allocatedTokens = db.hypaAllocatedTokens;
|
let allocatedTokens = db.hypaAllocatedTokens;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { get } from "svelte/store";
|
|
||||||
import type { OpenAIChat } from "..";
|
import type { OpenAIChat } from "..";
|
||||||
import { DataBase, type Chat, type character, type groupChat } from "../../storage/database.svelte";
|
import { getDatabase, type Chat, type character, type groupChat } from "../../storage/database.svelte";
|
||||||
import { tokenize, type ChatTokenizer } from "../../tokenizer";
|
import { tokenize, type ChatTokenizer } from "../../tokenizer";
|
||||||
import { requestChatData } from "../request";
|
import { requestChatData } from "../request";
|
||||||
import { HypaProcesser } from "./hypamemory";
|
import { HypaProcesser } from "./hypamemory";
|
||||||
@@ -18,7 +17,7 @@ export async function supaMemory(
|
|||||||
tokenizer:ChatTokenizer,
|
tokenizer:ChatTokenizer,
|
||||||
arg:{asHyper?:boolean} = {}
|
arg:{asHyper?:boolean} = {}
|
||||||
): Promise<{ currentTokens: number; chats: OpenAIChat[]; error?:string; memory?:string;lastId?:string}>{
|
): Promise<{ currentTokens: number; chats: OpenAIChat[]; error?:string; memory?:string;lastId?:string}>{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
|
|
||||||
currentTokens += 10
|
currentTokens += 10
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import { sleep } from "src/ts/util";
|
|||||||
import * as path from "@tauri-apps/api/path";
|
import * as path from "@tauri-apps/api/path";
|
||||||
import { exists, readTextFile } from "@tauri-apps/plugin-fs";
|
import { exists, readTextFile } from "@tauri-apps/plugin-fs";
|
||||||
import { alertClear, alertError, alertMd, alertWait } from "src/ts/alert";
|
import { alertClear, alertError, alertMd, alertWait } from "src/ts/alert";
|
||||||
import { get } from "svelte/store";
|
import { getDatabase } from "src/ts/storage/database.svelte";
|
||||||
import { DataBase } from "src/ts/storage/database.svelte";
|
|
||||||
let serverRunning = false;
|
let serverRunning = false;
|
||||||
|
|
||||||
export function checkLocalModel():Promise<string>{
|
export function checkLocalModel():Promise<string>{
|
||||||
@@ -130,7 +129,7 @@ export async function loadExllamaFull(){
|
|||||||
|
|
||||||
|
|
||||||
async function runLocalModelOld(prompt:string){
|
async function runLocalModelOld(prompt:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
|
|
||||||
if(!serverRunning){
|
if(!serverRunning){
|
||||||
await loadExllamaFull()
|
await loadExllamaFull()
|
||||||
@@ -273,7 +272,7 @@ export async function runGGUFModel(arg:{
|
|||||||
|
|
||||||
export async function tokenizeGGUFModel(prompt:string):Promise<number[]> {
|
export async function tokenizeGGUFModel(prompt:string):Promise<number[]> {
|
||||||
const key = await getLocalKey()
|
const key = await getLocalKey()
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const modelPath = db.aiModel.replace('local_', '')
|
const modelPath = db.aiModel.replace('local_', '')
|
||||||
const b = await fetch("http://localhost:10026/llamacpp/tokenize", {
|
const b = await fetch("http://localhost:10026/llamacpp/tokenize", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { DataBase } from "src/ts/storage/database.svelte";
|
import { getDatabase } from "src/ts/storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
|
||||||
|
|
||||||
export function getGenerationModelString(){
|
export function getGenerationModelString(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
switch (db.aiModel){
|
switch (db.aiModel){
|
||||||
case 'reverse_proxy':
|
case 'reverse_proxy':
|
||||||
return 'reverse_proxy-' + (db.reverseProxyOobaMode ? 'ooba' : db.proxyRequestModel)
|
return 'reverse_proxy-' + (db.reverseProxyOobaMode ? 'ooba' : db.proxyRequestModel)
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { DataBase, setDatabase } from "src/ts/storage/database.svelte"
|
import { getDatabase, setDatabase } from "src/ts/storage/database.svelte"
|
||||||
import type { OpenAIChat } from ".."
|
import type { OpenAIChat } from ".."
|
||||||
import { get } from "svelte/store"
|
|
||||||
import { globalFetch } from "src/ts/storage/globalApi"
|
import { globalFetch } from "src/ts/storage/globalApi"
|
||||||
import { alertError, alertInput, alertNormal, alertWait } from "src/ts/alert"
|
import { alertError, alertInput, alertNormal, alertWait } from "src/ts/alert"
|
||||||
import { getUserName, sleep } from "src/ts/util"
|
import { getUserName, sleep } from "src/ts/util"
|
||||||
|
|
||||||
export function stringlizeNAIChat(formated:OpenAIChat[], char:string, continued: boolean){
|
export function stringlizeNAIChat(formated:OpenAIChat[], char:string, continued: boolean){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let seperator = db.NAIsettings.seperator.replaceAll("\\n","\n") || '\n'
|
let seperator = db.NAIsettings.seperator.replaceAll("\\n","\n") || '\n'
|
||||||
let starter = db.NAIsettings.starter.replaceAll("\\n","\n") || '⁂'
|
let starter = db.NAIsettings.starter.replaceAll("\\n","\n") || '⁂'
|
||||||
let resultString:string[] = []
|
let resultString:string[] = []
|
||||||
@@ -109,7 +108,7 @@ export const novelLogin = async () => {
|
|||||||
|
|
||||||
const data = r.data?.accessToken
|
const data = r.data?.accessToken
|
||||||
|
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
db.novelai.token = data
|
db.novelai.token = data
|
||||||
|
|
||||||
alertNormal('Logged in to NovelAI')
|
alertNormal('Logged in to NovelAI')
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
import { alertConfirm, alertError, alertModuleSelect, alertNormal, alertStore } from "../alert"
|
import { alertConfirm, alertError, alertModuleSelect, alertNormal, alertStore } from "../alert"
|
||||||
import { DataBase, getCurrentCharacter, getCurrentChat, setCurrentCharacter, setDatabase, type customscript, type loreBook, type triggerscript } from "../storage/database.svelte"
|
import { getCurrentCharacter, getCurrentChat, getDatabase, setCurrentCharacter, setDatabase, type customscript, type loreBook, type triggerscript } from "../storage/database.svelte"
|
||||||
import { AppendableBuffer, downloadFile, isNodeServer, isTauri, readImage, saveAsset } from "../storage/globalApi"
|
import { AppendableBuffer, downloadFile, isNodeServer, isTauri, readImage, saveAsset } from "../storage/globalApi"
|
||||||
import { get } from "svelte/store"
|
|
||||||
import { selectSingleFile, sleep } from "../util"
|
import { selectSingleFile, sleep } from "../util"
|
||||||
import { v4 } from "uuid"
|
import { v4 } from "uuid"
|
||||||
import { convertExternalLorebook } from "./lorebook"
|
import { convertExternalLorebook } from "./lorebook"
|
||||||
@@ -171,7 +170,7 @@ export async function importModule(){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let fileData = f.data
|
let fileData = f.data
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(f.name.endsWith('.risum')){
|
if(f.name.endsWith('.risum')){
|
||||||
try {
|
try {
|
||||||
const buf = Buffer.from(fileData)
|
const buf = Buffer.from(fileData)
|
||||||
@@ -248,7 +247,7 @@ export async function importModule(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getModuleById(id:string){
|
function getModuleById(id:string){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
for(let i=0;i<db.modules.length;i++){
|
for(let i=0;i<db.modules.length;i++){
|
||||||
if(db.modules[i].id === id){
|
if(db.modules[i].id === id){
|
||||||
return db.modules[i]
|
return db.modules[i]
|
||||||
@@ -259,7 +258,7 @@ function getModuleById(id:string){
|
|||||||
|
|
||||||
function getModuleByIds(ids:string[]){
|
function getModuleByIds(ids:string[]){
|
||||||
let modules:RisuModule[] = []
|
let modules:RisuModule[] = []
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
for(let i=0;i<ids.length;i++){
|
for(let i=0;i<ids.length;i++){
|
||||||
const module = db.modules.find((m) => m.id === ids[i] || (m.namespace === ids[i] && m.namespace))
|
const module = db.modules.find((m) => m.id === ids[i] || (m.namespace === ids[i] && m.namespace))
|
||||||
if(module){
|
if(module){
|
||||||
@@ -273,7 +272,7 @@ let lastModules = ''
|
|||||||
let lastModuleData:RisuModule[] = []
|
let lastModuleData:RisuModule[] = []
|
||||||
export function getModules(){
|
export function getModules(){
|
||||||
const currentChat = getCurrentChat()
|
const currentChat = getCurrentChat()
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let ids = db.enabledModules ?? []
|
let ids = db.enabledModules ?? []
|
||||||
if (currentChat){
|
if (currentChat){
|
||||||
ids = ids.concat(currentChat.modules ?? [])
|
ids = ids.concat(currentChat.modules ?? [])
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { tokenizeAccurate } from "../tokenizer";
|
import { tokenizeAccurate } from "../tokenizer";
|
||||||
import { DataBase, presetTemplate, setDatabase, type Database } from "../storage/database.svelte";
|
import { getDatabase, presetTemplate, setDatabase, type Database } from "../storage/database.svelte";
|
||||||
import { alertError, alertNormal } from "../alert";
|
import { alertError, alertNormal } from "../alert";
|
||||||
import type { OobaChatCompletionRequestParams } from "../model/ooba";
|
import type { OobaChatCompletionRequestParams } from "../model/ooba";
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ export function promptConvertion(files:{ name: string, content: string, type:str
|
|||||||
if(type === 'STCHAT'){
|
if(type === 'STCHAT'){
|
||||||
preset.aiModel = 'openrouter'
|
preset.aiModel = 'openrouter'
|
||||||
preset.subModel = 'openrouter'
|
preset.subModel = 'openrouter'
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
db.botPresets.push(preset)
|
db.botPresets.push(preset)
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ export function promptConvertion(files:{ name: string, content: string, type:str
|
|||||||
preset.name ||= 'Converted from JSON'
|
preset.name ||= 'Converted from JSON'
|
||||||
|
|
||||||
|
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
db.botPresets.push(preset)
|
db.botPresets.push(preset)
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import type { MultiModal, OpenAIChat, OpenAIChatFull } from ".";
|
import type { MultiModal, OpenAIChat, OpenAIChatFull } from ".";
|
||||||
import { DataBase, type character } from "../storage/database.svelte";
|
import { getDatabase, type character } from "../storage/database.svelte";
|
||||||
import { pluginProcess } from "../plugins/plugins";
|
import { pluginProcess } from "../plugins/plugins";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { stringlizeAINChat, stringlizeChat, getStopStrings, unstringlizeAIN, unstringlizeChat } from "./stringlize";
|
import { stringlizeAINChat, stringlizeChat, getStopStrings, unstringlizeAIN, unstringlizeChat } from "./stringlize";
|
||||||
@@ -88,7 +88,7 @@ type ParameterMap = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function applyParameters(data: { [key: string]: any }, parameters: Parameter[], rename: ParameterMap = {}) {
|
function applyParameters(data: { [key: string]: any }, parameters: Parameter[], rename: ParameterMap = {}) {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
for(const parameter of parameters){
|
for(const parameter of parameters){
|
||||||
let value = 0
|
let value = 0
|
||||||
switch(parameter){
|
switch(parameter){
|
||||||
@@ -136,7 +136,7 @@ function applyParameters(data: { [key: string]: any }, parameters: Parameter[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function requestChatData(arg:requestDataArgument, model:'model'|'submodel', abortSignal:AbortSignal=null):Promise<requestDataResponse> {
|
export async function requestChatData(arg:requestDataArgument, model:'model'|'submodel', abortSignal:AbortSignal=null):Promise<requestDataResponse> {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let trys = 0
|
let trys = 0
|
||||||
while(true){
|
while(true){
|
||||||
const da = await requestChatDataMain(arg, model, abortSignal)
|
const da = await requestChatDataMain(arg, model, abortSignal)
|
||||||
@@ -178,7 +178,7 @@ export interface OpenAIChatExtra {
|
|||||||
|
|
||||||
|
|
||||||
export async function requestChatDataMain(arg:requestDataArgument, model:'model'|'submodel', abortSignal:AbortSignal=null):Promise<requestDataResponse> {
|
export async function requestChatDataMain(arg:requestDataArgument, model:'model'|'submodel', abortSignal:AbortSignal=null):Promise<requestDataResponse> {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let formated = structuredClone(arg.formated)
|
let formated = structuredClone(arg.formated)
|
||||||
let maxTokens = arg.maxTokens ??db.maxResponse
|
let maxTokens = arg.maxTokens ??db.maxResponse
|
||||||
let temperature = arg.temperature ?? (db.temperature / 100)
|
let temperature = arg.temperature ?? (db.temperature / 100)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { CharEmotion, selectedCharID } from "../stores";
|
import { CharEmotion, selectedCharID } from "../stores";
|
||||||
import { DataBase, setDatabase, type character, type customscript, type groupChat, type Database } from "../storage/database.svelte";
|
import { type character, type customscript, type groupChat, type Database, getDatabase } from "../storage/database.svelte";
|
||||||
import { downloadFile } from "../storage/globalApi";
|
import { downloadFile } from "../storage/globalApi";
|
||||||
import { alertError, alertNormal } from "../alert";
|
import { alertError, alertNormal } from "../alert";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
@@ -27,7 +27,7 @@ export async function processScript(char:character|groupChat, data:string, mode:
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function exportRegex(s?:customscript[]){
|
export function exportRegex(s?:customscript[]){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const script = s ?? db.globalscript
|
const script = s ?? db.globalscript
|
||||||
const data = Buffer.from(JSON.stringify({
|
const data = Buffer.from(JSON.stringify({
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
@@ -43,7 +43,7 @@ export async function importRegex(o?:customscript[]):Promise<customscript[]>{
|
|||||||
if(!filedata){
|
if(!filedata){
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
try {
|
try {
|
||||||
const imported= JSON.parse(Buffer.from(filedata).toString('utf-8'))
|
const imported= JSON.parse(Buffer.from(filedata).toString('utf-8'))
|
||||||
if(imported.type === 'regex' && imported.data){
|
if(imported.type === 'regex' && imported.data){
|
||||||
@@ -67,7 +67,7 @@ export async function importRegex(o?:customscript[]):Promise<customscript[]>{
|
|||||||
let bestMatchCache = new Map<string, string>()
|
let bestMatchCache = new Map<string, string>()
|
||||||
|
|
||||||
export async function processScriptFull(char:character|groupChat|simpleCharacterArgument, data:string, mode:ScriptMode, chatID = -1, cbsConditions:CbsConditions = {}){
|
export async function processScriptFull(char:character|groupChat|simpleCharacterArgument, data:string, mode:ScriptMode, chatID = -1, cbsConditions:CbsConditions = {}){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let emoChanged = false
|
let emoChanged = false
|
||||||
const scripts = (db.globalscript ?? []).concat(char.customscript).concat(getModuleRegexScripts())
|
const scripts = (db.globalscript ?? []).concat(char.customscript).concat(getModuleRegexScripts())
|
||||||
data = await runCharacterJS({
|
data = await runCharacterJS({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { DataBase, type character } from "../storage/database.svelte"
|
import { getDatabase, type character } from "../storage/database.svelte"
|
||||||
import { requestChatData } from "./request"
|
import { requestChatData } from "./request"
|
||||||
import { alertError } from "../alert"
|
import { alertError } from "../alert"
|
||||||
import { globalFetch, readImage } from "../storage/globalApi"
|
import { globalFetch, readImage } from "../storage/globalApi"
|
||||||
@@ -8,7 +8,7 @@ import type { OpenAIChat } from "."
|
|||||||
import { processZip } from "./processzip"
|
import { processZip } from "./processzip"
|
||||||
import { keiServerURL } from "../kei/kei"
|
import { keiServerURL } from "../kei/kei"
|
||||||
export async function stableDiff(currentChar:character,prompt:string){
|
export async function stableDiff(currentChar:character,prompt:string){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
|
|
||||||
if(db.sdProvider === ''){
|
if(db.sdProvider === ''){
|
||||||
alertError("Stable diffusion is not set in settings.")
|
alertError("Stable diffusion is not set in settings.")
|
||||||
@@ -56,7 +56,7 @@ export async function stableDiff(currentChar:character,prompt:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function generateAIImage(genPrompt:string, currentChar:character, neg:string, returnSdData:string):Promise<string|false>{
|
export async function generateAIImage(genPrompt:string, currentChar:character, neg:string, returnSdData:string):Promise<string|false>{
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
console.log(db.sdProvider)
|
console.log(db.sdProvider)
|
||||||
if(db.sdProvider === 'webui'){
|
if(db.sdProvider === 'webui'){
|
||||||
|
|
||||||
@@ -490,7 +490,7 @@ export async function generateAIImage(genPrompt:string, currentChar:character, n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(db.sdProvider === 'kei'){
|
if(db.sdProvider === 'kei'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let auth = db?.account?.token
|
let auth = db?.account?.token
|
||||||
if(!auth){
|
if(!auth){
|
||||||
db.account = JSON.parse(localStorage.getItem("fallbackRisuToken"))
|
db.account = JSON.parse(localStorage.getItem("fallbackRisuToken"))
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { get } from "svelte/store";
|
|
||||||
import type { OpenAIChat } from ".";
|
import type { OpenAIChat } from ".";
|
||||||
import { DataBase } from "../storage/database.svelte";
|
import { getDatabase } from "../storage/database.svelte";
|
||||||
import { getUserName } from "../util";
|
import { getUserName } from "../util";
|
||||||
|
|
||||||
export function multiChatReplacer(){
|
export function multiChatReplacer(){
|
||||||
@@ -41,7 +40,7 @@ function appendWhitespace(prefix:string, seperator:string=" ") {
|
|||||||
return prefix
|
return prefix
|
||||||
}
|
}
|
||||||
export function stringlizeChatOba(formated:OpenAIChat[], characterName:string, suggesting:boolean, continued:boolean){
|
export function stringlizeChatOba(formated:OpenAIChat[], characterName:string, suggesting:boolean, continued:boolean){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let resultString:string[] = []
|
let resultString:string[] = []
|
||||||
let { systemPrefix, userPrefix, assistantPrefix, seperator } = db.ooba.formating;
|
let { systemPrefix, userPrefix, assistantPrefix, seperator } = db.ooba.formating;
|
||||||
systemPrefix = systemPrefix ?? ""
|
systemPrefix = systemPrefix ?? ""
|
||||||
@@ -103,7 +102,7 @@ function toTitleCase(s:string){
|
|||||||
return s[0].toUpperCase() + s.slice(1).toLowerCase()
|
return s[0].toUpperCase() + s.slice(1).toLowerCase()
|
||||||
}
|
}
|
||||||
export function getStopStrings(suggesting:boolean=false){
|
export function getStopStrings(suggesting:boolean=false){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let { userPrefix, seperator } = db.ooba.formating;
|
let { userPrefix, seperator } = db.ooba.formating;
|
||||||
if(!seperator){
|
if(!seperator){
|
||||||
seperator = "\n"
|
seperator = "\n"
|
||||||
@@ -160,7 +159,7 @@ export function unstringlizeChat(text:string, formated:OpenAIChat[], char:string
|
|||||||
export function getUnstringlizerChunks(formated:OpenAIChat[], char:string, mode:'ain'|'normal' = 'normal'){
|
export function getUnstringlizerChunks(formated:OpenAIChat[], char:string, mode:'ain'|'normal' = 'normal'){
|
||||||
let chunks:string[] = ["system note:", "system:","system note:", "system:"]
|
let chunks:string[] = ["system note:", "system:","system note:", "system:"]
|
||||||
let charNames:string[] = []
|
let charNames:string[] = []
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(char){
|
if(char){
|
||||||
charNames.push(char)
|
charNames.push(char)
|
||||||
if(mode === 'ain'){
|
if(mode === 'ain'){
|
||||||
@@ -212,7 +211,7 @@ export function getUnstringlizerChunks(formated:OpenAIChat[], char:string, mode:
|
|||||||
|
|
||||||
export function stringlizeAINChat(formated:OpenAIChat[], char:string, continued: boolean){
|
export function stringlizeAINChat(formated:OpenAIChat[], char:string, continued: boolean){
|
||||||
let resultString:string[] = []
|
let resultString:string[] = []
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
|
|
||||||
for(const form of formated){
|
for(const form of formated){
|
||||||
console.log(form)
|
console.log(form)
|
||||||
@@ -292,7 +291,7 @@ function extractAINOutputStrings(inputString:string, characters:string[]) {
|
|||||||
|
|
||||||
export function unstringlizeAIN(data:string,formated:OpenAIChat[], char:string = ''){
|
export function unstringlizeAIN(data:string,formated:OpenAIChat[], char:string = ''){
|
||||||
|
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const chunksResult = getUnstringlizerChunks(formated, char ,'ain')
|
const chunksResult = getUnstringlizerChunks(formated, char ,'ain')
|
||||||
const chunks = chunksResult.chunks
|
const chunks = chunksResult.chunks
|
||||||
let result:['char'|'user',string][] = []
|
let result:['char'|'user',string][] = []
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Template } from '@huggingface/jinja';
|
import { Template } from '@huggingface/jinja';
|
||||||
import type { OpenAIChat } from '..';
|
import type { OpenAIChat } from '..';
|
||||||
import { get } from 'svelte/store';
|
import { getCurrentCharacter, getDatabase } from 'src/ts/storage/database.svelte';
|
||||||
import { DataBase, getCurrentCharacter } from 'src/ts/storage/database.svelte';
|
|
||||||
import { getUserName } from 'src/ts/util';
|
import { getUserName } from 'src/ts/util';
|
||||||
|
|
||||||
export const chatTemplates = {
|
export const chatTemplates = {
|
||||||
@@ -29,7 +28,7 @@ export const applyChatTemplate = (messages:OpenAIChat[], arg:{
|
|||||||
type?: string
|
type?: string
|
||||||
custom?: string
|
custom?: string
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const currentChar = getCurrentCharacter()
|
const currentChar = getCurrentCharacter()
|
||||||
const type = arg.type ?? db.instructChatTemplate
|
const type = arg.type ?? db.instructChatTemplate
|
||||||
if(!type){
|
if(!type){
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { DataBase, setPreset, type botPreset, setDatabase } from "src/ts/storage/database.svelte";
|
import { setPreset, type botPreset, setDatabase, getDatabase } from "src/ts/storage/database.svelte";
|
||||||
import { defaultAutoSuggestPrefixOoba, defaultAutoSuggestPrompt, defaultAutoSuggestPromptOoba } from "src/ts/storage/defaultPrompts";
|
import { defaultAutoSuggestPrefixOoba, defaultAutoSuggestPrompt, defaultAutoSuggestPromptOoba } from "src/ts/storage/defaultPrompts";
|
||||||
import { get } from "svelte/store";
|
import { prebuiltPresets } from "./templates";
|
||||||
import { prebuiltNAIpresets, prebuiltPresets } from "./templates";
|
|
||||||
import { alertConfirm, alertSelect } from "src/ts/alert";
|
import { alertConfirm, alertSelect } from "src/ts/alert";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
|
|
||||||
export async function setRecommended(model: string, ask:'ask'|'force') {
|
export async function setRecommended(model: string, ask:'ask'|'force') {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(!(recommendedPresetExist(model))){
|
if(!(recommendedPresetExist(model))){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { risuChatParser } from "src/ts/parser"
|
import { risuChatParser } from "src/ts/parser"
|
||||||
import { DataBase } from "src/ts/storage/database.svelte"
|
import { getDatabase } from "src/ts/storage/database.svelte"
|
||||||
import { get } from "svelte/store"
|
|
||||||
|
|
||||||
export function convertInterfaceToSchema(int:string){
|
export function convertInterfaceToSchema(int:string){
|
||||||
if(!int.startsWith('interface ') && !int.startsWith('export interface ')){
|
if(!int.startsWith('interface ') && !int.startsWith('export interface ')){
|
||||||
@@ -122,7 +121,7 @@ export function convertInterfaceToSchema(int:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getOpenAIJSONSchema(){
|
export function getOpenAIJSONSchema(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const schema = {
|
const schema = {
|
||||||
"name": "format",
|
"name": "format",
|
||||||
"strict": db.strictJsonSchema,
|
"strict": db.strictJsonSchema,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { parseChatML, risuChatParser } from "../parser";
|
import { parseChatML, risuChatParser } from "../parser";
|
||||||
import { DataBase, getCurrentCharacter, getCurrentChat, type Chat, type character } from "../storage/database.svelte";
|
import { getCurrentCharacter, getCurrentChat, getDatabase, type Chat, type character } from "../storage/database.svelte";
|
||||||
import { tokenize } from "../tokenizer";
|
import { tokenize } from "../tokenizer";
|
||||||
import { getModuleTriggers } from "./modules";
|
import { getModuleTriggers } from "./modules";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
@@ -167,7 +167,7 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
v.lowLevelAccess = CharacterlowLevelAccess
|
v.lowLevelAccess = CharacterlowLevelAccess
|
||||||
return v
|
return v
|
||||||
}).concat(getModuleTriggers())
|
}).concat(getModuleTriggers())
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const defaultVariables = parseKeyValue(char.defaultVariables).concat(parseKeyValue(db.templateDefaultVariables))
|
const defaultVariables = parseKeyValue(char.defaultVariables).concat(parseKeyValue(db.templateDefaultVariables))
|
||||||
let chat = structuredClone(arg.chat ?? char.chats[char.chatPage])
|
let chat = structuredClone(arg.chat ?? char.chats[char.chatPage])
|
||||||
if((!triggers) || (triggers.length === 0)){
|
if((!triggers) || (triggers.length === 0)){
|
||||||
@@ -191,7 +191,7 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
function setVar(key:string, value:string){
|
function setVar(key:string, value:string){
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const currentCharacter = getCurrentCharacter()
|
const currentCharacter = getCurrentCharacter()
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
varChanged = true
|
varChanged = true
|
||||||
chat.scriptstate ??= {}
|
chat.scriptstate ??= {}
|
||||||
chat.scriptstate['$' + key] = value
|
chat.scriptstate['$' + key] = value
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { get } from "svelte/store";
|
|
||||||
import { alertError } from "../alert";
|
import { alertError } from "../alert";
|
||||||
import { DataBase, getCurrentCharacter, type character } from "../storage/database.svelte";
|
import { getCurrentCharacter, getDatabase, type character } from "../storage/database.svelte";
|
||||||
import { runTranslator, translateVox } from "../translator/translator";
|
import { runTranslator, translateVox } from "../translator/translator";
|
||||||
import { globalFetch, loadAsset } from "../storage/globalApi";
|
import { globalFetch, loadAsset } from "../storage/globalApi";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import { sleep } from "../util";
|
import { sleep } from "../util";
|
||||||
import { registerOnnxModel, runVITS } from "./transformers";
|
import { runVITS } from "./transformers";
|
||||||
|
|
||||||
let sourceNode:AudioBufferSourceNode = null
|
let sourceNode:AudioBufferSourceNode = null
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ export async function sayTTS(character:character,text:string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
text = text.replace(/\*/g,'')
|
text = text.replace(/\*/g,'')
|
||||||
|
|
||||||
if(character.ttsReadOnlyQuoted){
|
if(character.ttsReadOnlyQuoted){
|
||||||
@@ -383,7 +382,7 @@ export function getWebSpeechTTSVoices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getElevenTTSVoices() {
|
export async function getElevenTTSVoices() {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
|
|
||||||
const data = await fetch('https://api.elevenlabs.io/v1/voices', {
|
const data = await fetch('https://api.elevenlabs.io/v1/voices', {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -397,7 +396,7 @@ export async function getElevenTTSVoices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getVOICEVOXVoices() {
|
export async function getVOICEVOXVoices() {
|
||||||
const db = get(DataBase);
|
const db = getDatabase();
|
||||||
const speakerData = await fetch(`${db.voicevoxUrl}/speakers`)
|
const speakerData = await fetch(`${db.voicevoxUrl}/speakers`)
|
||||||
const speakerList = await speakerData.json()
|
const speakerList = await speakerData.json()
|
||||||
const speakersInfo = speakerList.map((speaker) => {
|
const speakersInfo = speakerList.map((speaker) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { exportCharacterCard } from "./characterCards";
|
import { exportCharacterCard } from "./characterCards";
|
||||||
import { VirtualWriter, isTauri, openURL } from "./storage/globalApi";
|
import { VirtualWriter, isTauri, openURL } from "./storage/globalApi";
|
||||||
import { DataBase, getCurrentCharacter, type character } from "./storage/database.svelte";
|
import { getCurrentCharacter, getDatabase, type character } from "./storage/database.svelte";
|
||||||
import { alertStore } from "./alert";
|
import { alertStore } from "./alert";
|
||||||
|
|
||||||
let pong = false;
|
let pong = false;
|
||||||
@@ -15,7 +15,7 @@ window.addEventListener("message", (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: ArrayBuffer; }> {
|
export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: ArrayBuffer; }> {
|
||||||
const char = structuredClone(getCurrentCharacter()) as character
|
const char = structuredClone(getCurrentCharacter({snapshot:true})) as character
|
||||||
const trimedName = char.name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
const trimedName = char.name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
||||||
const writer = new VirtualWriter()
|
const writer = new VirtualWriter()
|
||||||
const namebuf = new TextEncoder().encode(trimedName + '.png')
|
const namebuf = new TextEncoder().encode(trimedName + '.png')
|
||||||
@@ -31,8 +31,8 @@ export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: Ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function openRealm(name:string,data:ArrayBuffer) {
|
export async function openRealm(name:string,data:ArrayBuffer) {
|
||||||
const tk = get(DataBase)?.account?.token;
|
const tk = getDatabase()?.account?.token;
|
||||||
const id = get(DataBase)?.account?.id
|
const id = getDatabase()?.account?.id
|
||||||
const trimedName = name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
const trimedName = name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
||||||
const filedata = encodeURIComponent(Buffer.from(data).toString('base64')) + `&${trimedName}.png`;
|
const filedata = encodeURIComponent(Buffer.from(data).toString('base64')) + `&${trimedName}.png`;
|
||||||
const url = `https://realm.risuai.net/upload?token=${tk}&token_id=${id}#filedata=${filedata}`
|
const url = `https://realm.risuai.net/upload?token=${tk}&token_id=${id}#filedata=${filedata}`
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { get, writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
import { DataBase } from "./database.svelte"
|
import { getDatabase } from "./database.svelte"
|
||||||
import { hubURL } from "../characterCards"
|
import { hubURL } from "../characterCards"
|
||||||
import localforage from "localforage"
|
import localforage from "localforage"
|
||||||
import { alertError, alertLogin, alertStore, alertWait } from "../alert"
|
import { alertLogin, alertStore, alertWait } from "../alert"
|
||||||
import { forageStorage, getUnpargeables, replaceDbResources } from "./globalApi"
|
import { forageStorage, getUnpargeables } from "./globalApi"
|
||||||
import { encodeRisuSave } from "./risuSave"
|
import { encodeRisuSave } from "./risuSave"
|
||||||
import { v4 } from "uuid"
|
import { v4 } from "uuid"
|
||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
@@ -99,7 +99,7 @@ export class AccountStorage{
|
|||||||
return Buffer.from(ab)
|
return Buffer.from(ab)
|
||||||
}
|
}
|
||||||
async keys():Promise<string[]>{
|
async keys():Promise<string[]>{
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
return getUnpargeables(db, 'pure')
|
return getUnpargeables(db, 'pure')
|
||||||
}
|
}
|
||||||
async removeItem(key:string){
|
async removeItem(key:string){
|
||||||
@@ -107,7 +107,7 @@ export class AccountStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private checkAuth(){
|
private checkAuth(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
this.auth = db?.account?.token
|
this.auth = db?.account?.token
|
||||||
if(!this.auth){
|
if(!this.auth){
|
||||||
db.account = JSON.parse(localStorage.getItem("fallbackRisuToken"))
|
db.account = JSON.parse(localStorage.getItem("fallbackRisuToken"))
|
||||||
@@ -122,7 +122,7 @@ export class AccountStorage{
|
|||||||
|
|
||||||
export async function unMigrationAccount() {
|
export async function unMigrationAccount() {
|
||||||
const keys = await forageStorage.keys()
|
const keys = await forageStorage.keys()
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const MigrationStorage = localforage.createInstance({name: "risuai"})
|
const MigrationStorage = localforage.createInstance({name: "risuai"})
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { isNodeServer, replaceDbResources } from "./globalApi"
|
|||||||
import { NodeStorage } from "./nodeStorage"
|
import { NodeStorage } from "./nodeStorage"
|
||||||
import { OpfsStorage } from "./opfsStorage"
|
import { OpfsStorage } from "./opfsStorage"
|
||||||
import { alertInput, alertSelect, alertStore } from "../alert"
|
import { alertInput, alertSelect, alertStore } from "../alert"
|
||||||
import { get } from "svelte/store"
|
import { getDatabase, type Database } from "./database.svelte"
|
||||||
import { DataBase, type Database } from "./database.svelte"
|
|
||||||
import { AccountStorage } from "./accountStorage"
|
import { AccountStorage } from "./accountStorage"
|
||||||
import { decodeRisuSave, encodeRisuSave } from "./risuSave";
|
import { decodeRisuSave, encodeRisuSave } from "./risuSave";
|
||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
@@ -40,7 +39,7 @@ export class AutoStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
async checkAccountSync(){
|
async checkAccountSync(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(this.isAccount){
|
if(this.isAccount){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,13 @@ import { defaultColorScheme, type ColorScheme } from '../gui/colorscheme';
|
|||||||
import type { PromptItem, PromptSettings } from '../process/prompt';
|
import type { PromptItem, PromptSettings } from '../process/prompt';
|
||||||
import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
||||||
|
|
||||||
export const DataBase = writable({} as any as Database)
|
|
||||||
export const DBState = $state({
|
export const DBState = $state({
|
||||||
db: get(DataBase)
|
db: {} as any as Database
|
||||||
})
|
})
|
||||||
export const loadedStore = writable(false)
|
export const loadedStore = writable(false)
|
||||||
export let appVer = "137.1.0"
|
export let appVer = "137.1.0"
|
||||||
export let webAppSubVer = '-svelte5-exp'
|
export let webAppSubVer = '-svelte5-exp'
|
||||||
|
|
||||||
DataBase.subscribe(data => {
|
|
||||||
//check it is pointing to the right object
|
|
||||||
if(DBState.db !== data){
|
|
||||||
//if not, update it
|
|
||||||
DBState.db = data
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
//same as above, but for the other way around
|
|
||||||
if(DBState.db !== get(DataBase)){
|
|
||||||
DataBase.set(DBState.db)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export function setDatabase(data:Database){
|
export function setDatabase(data:Database){
|
||||||
if(checkNullish(data.characters)){
|
if(checkNullish(data.characters)){
|
||||||
@@ -464,21 +449,36 @@ export function setDatabase(data:Database){
|
|||||||
data.groupOtherBotRole ??= 'user'
|
data.groupOtherBotRole ??= 'user'
|
||||||
data.customGUI ??= ''
|
data.customGUI ??= ''
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
DataBase.set(data)
|
setDatabaseLite(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentCharacter(){
|
export function setDatabaseLite(data:Database){
|
||||||
const db = get(DataBase)
|
DBState.db = data
|
||||||
|
}
|
||||||
|
|
||||||
|
interface getDatabaseOptions{
|
||||||
|
snapshot?:boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDatabase(options:getDatabaseOptions = {}):Database{
|
||||||
|
if(options.snapshot){
|
||||||
|
return $state.snapshot(DBState.db) as Database
|
||||||
|
}
|
||||||
|
return DBState.db as Database
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCurrentCharacter(options:getDatabaseOptions = {}):character|groupChat{
|
||||||
|
const db = getDatabase(options)
|
||||||
db.characters ??= []
|
db.characters ??= []
|
||||||
const char = db.characters?.[get(selectedCharID)]
|
const char = db.characters?.[get(selectedCharID)]
|
||||||
return char
|
return char
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setCurrentCharacter(char:character|groupChat){
|
export function setCurrentCharacter(char:character|groupChat){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
db.characters ??= []
|
db.characters ??= []
|
||||||
db.characters[get(selectedCharID)] = char
|
db.characters[get(selectedCharID)] = char
|
||||||
DataBase.set(db)
|
setDatabaseLite(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentChat(){
|
export function getCurrentChat(){
|
||||||
@@ -1328,7 +1328,7 @@ export const defaultSdDataFunc = () =>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function saveCurrentPreset(){
|
export function saveCurrentPreset(){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let pres = db.botPresets
|
let pres = db.botPresets
|
||||||
pres[db.botPresetsId] = {
|
pres[db.botPresetsId] = {
|
||||||
name: pres[db.botPresetsId].name,
|
name: pres[db.botPresetsId].name,
|
||||||
@@ -1392,7 +1392,7 @@ export function saveCurrentPreset(){
|
|||||||
|
|
||||||
export function copyPreset(id:number){
|
export function copyPreset(id:number){
|
||||||
saveCurrentPreset()
|
saveCurrentPreset()
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let pres = db.botPresets
|
let pres = db.botPresets
|
||||||
const newPres = structuredClone(pres[id])
|
const newPres = structuredClone(pres[id])
|
||||||
newPres.name += " Copy"
|
newPres.name += " Copy"
|
||||||
@@ -1404,7 +1404,7 @@ export function changeToPreset(id =0, savecurrent = true){
|
|||||||
if(savecurrent){
|
if(savecurrent){
|
||||||
saveCurrentPreset()
|
saveCurrentPreset()
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let pres = db.botPresets
|
let pres = db.botPresets
|
||||||
const newPres = pres[id]
|
const newPres = pres[id]
|
||||||
db.botPresetsId = id
|
db.botPresetsId = id
|
||||||
@@ -1492,7 +1492,7 @@ import { selectedCharID } from '../stores';
|
|||||||
|
|
||||||
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){
|
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){
|
||||||
saveCurrentPreset()
|
saveCurrentPreset()
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let pres = structuredClone(db.botPresets[id])
|
let pres = structuredClone(db.botPresets[id])
|
||||||
console.log(pres)
|
console.log(pres)
|
||||||
pres.openAIKey = ''
|
pres.openAIKey = ''
|
||||||
@@ -1563,7 +1563,7 @@ export async function importPreset(f:{
|
|||||||
pre = {...presetTemplate,...(JSON.parse(Buffer.from(f.data).toString('utf-8')))}
|
pre = {...presetTemplate,...(JSON.parse(Buffer.from(f.data).toString('utf-8')))}
|
||||||
console.log(pre)
|
console.log(pre)
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(pre.presetVersion && pre.presetVersion >= 3){
|
if(pre.presetVersion && pre.presetVersion >= 3){
|
||||||
//NAI preset
|
//NAI preset
|
||||||
const pr = structuredClone(prebuiltPresets.NAI2)
|
const pr = structuredClone(prebuiltPresets.NAI2)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { DataBase } from "./database.svelte";
|
import { getDatabase } from "./database.svelte";
|
||||||
import { downloadFile } from "./globalApi";
|
import { downloadFile } from "./globalApi";
|
||||||
import { alertNormal } from "../alert";
|
import { alertNormal } from "../alert";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
|
|
||||||
export async function exportAsDataset(){
|
export async function exportAsDataset(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
|
|
||||||
let dataset = []
|
let dataset = []
|
||||||
for(const char of db.characters){
|
for(const char of db.characters){
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { v4 as uuidv4, v4 } from 'uuid';
|
|||||||
import { appDataDir, join } from "@tauri-apps/api/path";
|
import { appDataDir, join } from "@tauri-apps/api/path";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import {open} from '@tauri-apps/plugin-shell'
|
import {open} from '@tauri-apps/plugin-shell'
|
||||||
import { DataBase, loadedStore, setDatabase, type Database, defaultSdDataFunc } from "./database.svelte";
|
import { loadedStore, setDatabase, type Database, defaultSdDataFunc, getDatabase } from "./database.svelte";
|
||||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import { checkRisuUpdate } from "../update";
|
import { checkRisuUpdate } from "../update";
|
||||||
import { MobileGUI, botMakerMode, selectedCharID } from "../stores";
|
import { MobileGUI, botMakerMode, selectedCharID } from "../stores";
|
||||||
@@ -310,12 +310,9 @@ let lastSave = ''
|
|||||||
* @returns {Promise<void>} - A promise that resolves when the database has been saved.
|
* @returns {Promise<void>} - A promise that resolves when the database has been saved.
|
||||||
*/
|
*/
|
||||||
export async function saveDb(){
|
export async function saveDb(){
|
||||||
lastSave = JSON.stringify(get(DataBase))
|
lastSave = JSON.stringify(getDatabase())
|
||||||
let changed = false
|
let changed = true
|
||||||
syncDrive()
|
syncDrive()
|
||||||
DataBase.subscribe(() => {
|
|
||||||
changed = true
|
|
||||||
})
|
|
||||||
let gotChannel = false
|
let gotChannel = false
|
||||||
const sessionID = v4()
|
const sessionID = v4()
|
||||||
let channel:BroadcastChannel
|
let channel:BroadcastChannel
|
||||||
@@ -346,8 +343,11 @@ export async function saveDb(){
|
|||||||
if(channel){
|
if(channel){
|
||||||
channel.postMessage(sessionID)
|
channel.postMessage(sessionID)
|
||||||
}
|
}
|
||||||
changed = false
|
let db = getDatabase()
|
||||||
let db = get(DataBase)
|
if(!db.characters){
|
||||||
|
await sleep(1000)
|
||||||
|
continue
|
||||||
|
}
|
||||||
db.saveTime = Math.floor(Date.now() / 1000)
|
db.saveTime = Math.floor(Date.now() / 1000)
|
||||||
if(isTauri){
|
if(isTauri){
|
||||||
const dbData = encodeRisuSave(db)
|
const dbData = encodeRisuSave(db)
|
||||||
@@ -393,7 +393,7 @@ export async function saveDb(){
|
|||||||
* @returns {Promise<number[]>} - A promise that resolves to an array of backup timestamps.
|
* @returns {Promise<number[]>} - A promise that resolves to an array of backup timestamps.
|
||||||
*/
|
*/
|
||||||
async function getDbBackups() {
|
async function getDbBackups() {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db?.account?.useSync){
|
if(db?.account?.useSync){
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -547,7 +547,7 @@ export async function loadData() {
|
|||||||
else{
|
else{
|
||||||
usingSw = false
|
usingSw = false
|
||||||
}
|
}
|
||||||
if(get(DataBase).didFirstSetup){
|
if(getDatabase().didFirstSetup){
|
||||||
characterURLImport()
|
characterURLImport()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +557,7 @@ export async function loadData() {
|
|||||||
try {
|
try {
|
||||||
await loadPlugins()
|
await loadPlugins()
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
if(get(DataBase).account){
|
if(getDatabase().account){
|
||||||
try {
|
try {
|
||||||
await loadRisuAccountData()
|
await loadRisuAccountData()
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@@ -572,7 +572,7 @@ export async function loadData() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
await checkNewFormat()
|
await checkNewFormat()
|
||||||
const db = get(DataBase);
|
const db = getDatabase();
|
||||||
updateColorScheme()
|
updateColorScheme()
|
||||||
updateTextThemeAndCSS()
|
updateTextThemeAndCSS()
|
||||||
updateAnimationSpeed()
|
updateAnimationSpeed()
|
||||||
@@ -720,7 +720,7 @@ export function addFetchLog(arg: {
|
|||||||
*/
|
*/
|
||||||
export async function globalFetch(url: string, arg: GlobalFetchArgs = {}): Promise<GlobalFetchResult> {
|
export async function globalFetch(url: string, arg: GlobalFetchArgs = {}): Promise<GlobalFetchResult> {
|
||||||
try {
|
try {
|
||||||
const db = get(DataBase);
|
const db = getDatabase();
|
||||||
const method = arg.method ?? "POST";
|
const method = arg.method ?? "POST";
|
||||||
db.requestmet = "normal";
|
db.requestmet = "normal";
|
||||||
|
|
||||||
@@ -1056,7 +1056,7 @@ export function replaceDbResources(db: Database, replacer: { [key: string]: stri
|
|||||||
* @returns {Promise<void>} - A promise that resolves when the database format check and update is complete.
|
* @returns {Promise<void>} - A promise that resolves when the database format check and update is complete.
|
||||||
*/
|
*/
|
||||||
async function checkNewFormat(): Promise<void> {
|
async function checkNewFormat(): Promise<void> {
|
||||||
let db = get(DataBase);
|
let db = getDatabase();
|
||||||
|
|
||||||
// Check data integrity
|
// Check data integrity
|
||||||
db.characters = db.characters.map((v) => {
|
db.characters = db.characters.map((v) => {
|
||||||
@@ -1147,40 +1147,7 @@ async function checkNewFormat(): Promise<void> {
|
|||||||
db.formatversion = 3;
|
db.formatversion = 3;
|
||||||
}
|
}
|
||||||
if (db.formatversion < 4) {
|
if (db.formatversion < 4) {
|
||||||
db.modules ??= [];
|
//migration removed due to issues
|
||||||
db.enabledModules ??= [];
|
|
||||||
// Convert global lore and global regex to modules
|
|
||||||
if (db.globalscript && db.globalscript.length > 0) {
|
|
||||||
const id = v4();
|
|
||||||
let regexModule: RisuModule = {
|
|
||||||
name: "Global Regex",
|
|
||||||
description: "Converted from legacy global regex",
|
|
||||||
id: id,
|
|
||||||
regex: structuredClone(db.globalscript)
|
|
||||||
};
|
|
||||||
db.modules.push(regexModule);
|
|
||||||
db.enabledModules.push(id);
|
|
||||||
db.globalscript = [];
|
|
||||||
}
|
|
||||||
if (db.loreBook && db.loreBook.length > 0) {
|
|
||||||
const selIndex = db.loreBookPage;
|
|
||||||
for (let i = 0; i < db.loreBook.length; i++) {
|
|
||||||
const id = v4();
|
|
||||||
let lbModule: RisuModule = {
|
|
||||||
name: db.loreBook[i].name || "Unnamed Global Lorebook",
|
|
||||||
description: "Converted from legacy global lorebook",
|
|
||||||
id: id,
|
|
||||||
lorebook: structuredClone(db.loreBook[i].data)
|
|
||||||
};
|
|
||||||
db.modules.push(lbModule);
|
|
||||||
if (i === selIndex) {
|
|
||||||
db.enabledModules.push(id);
|
|
||||||
}
|
|
||||||
db.globalscript = [];
|
|
||||||
}
|
|
||||||
db.loreBook = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
db.formatversion = 4;
|
db.formatversion = 4;
|
||||||
}
|
}
|
||||||
if (!db.characterOrder) {
|
if (!db.characterOrder) {
|
||||||
@@ -1209,9 +1176,9 @@ async function checkNewFormat(): Promise<void> {
|
|||||||
* Ensures that all characters are properly ordered and removes any invalid entries.
|
* Ensures that all characters are properly ordered and removes any invalid entries.
|
||||||
*/
|
*/
|
||||||
export function checkCharOrder() {
|
export function checkCharOrder() {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
db.characterOrder = db.characterOrder ?? []
|
db.characterOrder = db.characterOrder ?? []
|
||||||
let ordered = structuredClone(db.characterOrder ?? [])
|
let ordered = []
|
||||||
for(let i=0;i<db.characterOrder.length;i++){
|
for(let i=0;i<db.characterOrder.length;i++){
|
||||||
const folder =db.characterOrder[i]
|
const folder =db.characterOrder[i]
|
||||||
if(typeof(folder) !== 'string' && folder){
|
if(typeof(folder) !== 'string' && folder){
|
||||||
@@ -1219,6 +1186,9 @@ export function checkCharOrder() {
|
|||||||
ordered.push(f)
|
ordered.push(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(typeof(folder) === 'string'){
|
||||||
|
ordered.push(folder)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let charIdList:string[] = []
|
let charIdList:string[] = []
|
||||||
@@ -1276,7 +1246,7 @@ export function checkCharOrder() {
|
|||||||
* Removes files from the assets directory that are not in the list of unpargeable items.
|
* Removes files from the assets directory that are not in the list of unpargeable items.
|
||||||
*/
|
*/
|
||||||
async function pargeChunks(){
|
async function pargeChunks(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(db.account?.useSync){
|
if(db.account?.useSync){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1797,7 +1767,7 @@ export async function fetchNative(url:string, arg:{
|
|||||||
chatId?:string
|
chatId?:string
|
||||||
}):Promise<{ body: ReadableStream<Uint8Array>; headers: Headers; status: number }> {
|
}):Promise<{ body: ReadableStream<Uint8Array>; headers: Headers; status: number }> {
|
||||||
let headers = arg.headers ?? {}
|
let headers = arg.headers ?? {}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let throughProxy = (!isTauri) && (!isNodeServer) && (!db.usePlainFetch)
|
let throughProxy = (!isTauri) && (!isNodeServer) && (!db.usePlainFetch)
|
||||||
let fetchLogIndex = addFetchLog({
|
let fetchLogIndex = addFetchLog({
|
||||||
body: arg.body,
|
body: arg.body,
|
||||||
@@ -1977,7 +1947,7 @@ export function trimNonLatin(data:string){
|
|||||||
* The corresponding CSS variable '--risu-height-size' is set accordingly.
|
* The corresponding CSS variable '--risu-height-size' is set accordingly.
|
||||||
*/
|
*/
|
||||||
export function updateHeightMode(){
|
export function updateHeightMode(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const root = document.querySelector(':root') as HTMLElement;
|
const root = document.querySelector(':root') as HTMLElement;
|
||||||
switch(db.heightMode){
|
switch(db.heightMode){
|
||||||
case 'auto':
|
case 'auto':
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { DataBase } from "./database.svelte";
|
import { getDatabase } from "./database.svelte";
|
||||||
import { alertNormal } from "../alert";
|
import { alertNormal } from "../alert";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import { isNodeServer, isTauri } from "./globalApi";
|
import { isNodeServer, isTauri } from "./globalApi";
|
||||||
@@ -38,7 +38,7 @@ async function requestPersistantStorageMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function persistantStorageRecommended() {
|
export async function persistantStorageRecommended() {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(navigator.storage && navigator.storage.persist && (!isTauri) && (!isNodeServer)) {
|
if(navigator.storage && navigator.storage.persist && (!isTauri) && (!isNodeServer)) {
|
||||||
if(await navigator.storage.persisted()) {
|
if(await navigator.storage.persisted()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { get, writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from "svelte/store";
|
||||||
import { DataBase, getCurrentCharacter, type Chat, type character, type groupChat } from "./storage/database.svelte";
|
import { getDatabase, type Chat, type character, type groupChat } from "./storage/database.svelte";
|
||||||
import { isEqual } from "lodash";
|
|
||||||
import type { simpleCharacterArgument } from "./parser";
|
import type { simpleCharacterArgument } from "./parser";
|
||||||
import { getUserIcon, getUserIconProtrait, getUserName, sleep } from "./util";
|
import { sleep } from "./util";
|
||||||
import { getModules } from "./process/modules";
|
import { getModules } from "./process/modules";
|
||||||
|
|
||||||
function updateSize(){
|
function updateSize(){
|
||||||
@@ -75,7 +74,7 @@ export function createSimpleCharacter(char:character|groupChat){
|
|||||||
|
|
||||||
const simpleChar:simpleCharacterArgument = {
|
const simpleChar:simpleCharacterArgument = {
|
||||||
type: "simple",
|
type: "simple",
|
||||||
customscript: structuredClone(char.customscript),
|
customscript: char.customscript,
|
||||||
chaId: char.chaId,
|
chaId: char.chaId,
|
||||||
additionalAssets: char.additionalAssets,
|
additionalAssets: char.additionalAssets,
|
||||||
virtualscript: char.virtualscript,
|
virtualscript: char.virtualscript,
|
||||||
@@ -89,7 +88,7 @@ export function createSimpleCharacter(char:character|groupChat){
|
|||||||
|
|
||||||
function trySync(){
|
function trySync(){
|
||||||
try {
|
try {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
CurrentShowMemoryLimit.set(db.showMemoryLimit)
|
CurrentShowMemoryLimit.set(db.showMemoryLimit)
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import { alertError, alertInput, alertNormal, alertStore, alertWait } from '../alert';
|
import { alertError, alertInput, alertNormal, alertStore, alertWait } from '../alert';
|
||||||
import { get, writable } from 'svelte/store';
|
import { get, writable } from 'svelte/store';
|
||||||
import { DataBase, setDatabase, type character, saveImage, type Chat, getCurrentChat, setCurrentChat } from '../storage/database.svelte';
|
import { setDatabase, type character, saveImage, type Chat, getCurrentChat, setCurrentChat, getDatabase } from '../storage/database.svelte';
|
||||||
import { selectedCharID } from '../stores';
|
import { selectedCharID } from '../stores';
|
||||||
import { findCharacterIndexbyId, sleep } from '../util';
|
import { findCharacterIndexbyId, sleep } from '../util';
|
||||||
import type { DataConnection, Peer } from 'peerjs';
|
import type { DataConnection, Peer } from 'peerjs';
|
||||||
@@ -79,7 +79,9 @@ export async function createMultiuserRoom(){
|
|||||||
console.log("new connection", conn)
|
console.log("new connection", conn)
|
||||||
|
|
||||||
async function requestChar(excludeAssets:string[]|null = null){
|
async function requestChar(excludeAssets:string[]|null = null){
|
||||||
const db = get(DataBase)
|
const db = getDatabase({
|
||||||
|
snapshot: true
|
||||||
|
})
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = structuredClone(db.characters[selectedCharId])
|
const char = structuredClone(db.characters[selectedCharId])
|
||||||
if(char.type === 'group'){
|
if(char.type === 'group'){
|
||||||
@@ -127,7 +129,9 @@ export async function createMultiuserRoom(){
|
|||||||
requestChar()
|
requestChar()
|
||||||
}
|
}
|
||||||
if(data.type === 'receive-char'){
|
if(data.type === 'receive-char'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase({
|
||||||
|
snapshot: true
|
||||||
|
})
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = structuredClone(db.characters[selectedCharId])
|
const char = structuredClone(db.characters[selectedCharId])
|
||||||
const recivedChar = data.data
|
const recivedChar = data.data
|
||||||
@@ -137,7 +141,7 @@ export async function createMultiuserRoom(){
|
|||||||
char.chats[char.chatPage] = recivedChar.chats[0]
|
char.chats[char.chatPage] = recivedChar.chats[0]
|
||||||
}
|
}
|
||||||
if(data.type === 'request-chat-sync'){
|
if(data.type === 'request-chat-sync'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = db.characters[selectedCharId]
|
const char = db.characters[selectedCharId]
|
||||||
char.chats[char.chatPage] = data.data
|
char.chats[char.chatPage] = data.data
|
||||||
@@ -157,7 +161,7 @@ export async function createMultiuserRoom(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data.type === 'request-chat'){
|
if(data.type === 'request-chat'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = db.characters[selectedCharId]
|
const char = db.characters[selectedCharId]
|
||||||
const chat = char.chats[char.chatPage]
|
const chat = char.chats[char.chatPage]
|
||||||
@@ -285,7 +289,7 @@ export async function joinMultiuserRoom(){
|
|||||||
switch(data.type){
|
switch(data.type){
|
||||||
case 'receive-char':{
|
case 'receive-char':{
|
||||||
//create temp character
|
//create temp character
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const cha = data.data
|
const cha = data.data
|
||||||
cha.chaId = '§temp'
|
cha.chaId = '§temp'
|
||||||
cha.chatPage = 0
|
cha.chatPage = 0
|
||||||
@@ -309,7 +313,9 @@ export async function joinMultiuserRoom(){
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'receive-chat':{
|
case 'receive-chat':{
|
||||||
const db = get(DataBase)
|
const db = getDatabase({
|
||||||
|
snapshot: true
|
||||||
|
})
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = structuredClone(db.characters[selectedCharId])
|
const char = structuredClone(db.characters[selectedCharId])
|
||||||
char.chats[char.chatPage] = data.data
|
char.chats[char.chatPage] = data.data
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { Tiktoken } from "@dqbd/tiktoken";
|
import type { Tiktoken } from "@dqbd/tiktoken";
|
||||||
import type { Tokenizer } from "@mlc-ai/web-tokenizers";
|
import type { Tokenizer } from "@mlc-ai/web-tokenizers";
|
||||||
import { DataBase, type groupChat, type character, type Chat, getCurrentCharacter } from "./storage/database.svelte";
|
import { type groupChat, type character, type Chat, getCurrentCharacter, getDatabase } from "./storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
|
||||||
import type { MultiModal, OpenAIChat } from "./process";
|
import type { MultiModal, OpenAIChat } from "./process";
|
||||||
import { supportsInlayImage } from "./process/files/image";
|
import { supportsInlayImage } from "./process/files/image";
|
||||||
import { risuChatParser } from "./parser";
|
import { risuChatParser } from "./parser";
|
||||||
@@ -22,7 +21,7 @@ export const tokenizerList = [
|
|||||||
] as const
|
] as const
|
||||||
|
|
||||||
export async function encode(data:string):Promise<(number[]|Uint32Array|Int32Array)>{
|
export async function encode(data:string):Promise<(number[]|Uint32Array|Int32Array)>{
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db.aiModel === 'openrouter' || db.aiModel === 'reverse_proxy'){
|
if(db.aiModel === 'openrouter' || db.aiModel === 'reverse_proxy'){
|
||||||
switch(db.customTokenizer){
|
switch(db.customTokenizer){
|
||||||
case 'mistral':
|
case 'mistral':
|
||||||
@@ -130,7 +129,7 @@ async function tikJS(text:string, model='cl100k_base') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function geminiTokenizer(text:string) {
|
async function geminiTokenizer(text:string) {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const fetchResult = await globalFetch(`https://generativelanguage.googleapis.com/v1beta/${db.aiModel}:countTextTokens`, {
|
const fetchResult = await globalFetch(`https://generativelanguage.googleapis.com/v1beta/${db.aiModel}:countTextTokens`, {
|
||||||
"headers": {
|
"headers": {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
@@ -249,7 +248,7 @@ export class ChatTokenizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async tokenizeMultiModal(data:MultiModal){
|
async tokenizeMultiModal(data:MultiModal){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
if(!supportsInlayImage()){
|
if(!supportsInlayImage()){
|
||||||
return this.chatAdditonalTokens
|
return this.chatAdditonalTokens
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { translatorPlugin } from "../plugins/plugins"
|
import { translatorPlugin } from "../plugins/plugins"
|
||||||
import { DataBase, type character, type customscript, type groupChat } from "../storage/database.svelte"
|
import { getDatabase, type character, type customscript, type groupChat } from "../storage/database.svelte"
|
||||||
import { globalFetch, isTauri } from "../storage/globalApi"
|
import { globalFetch, isTauri } from "../storage/globalApi"
|
||||||
import { alertError } from "../alert"
|
import { alertError } from "../alert"
|
||||||
import { requestChatData } from "../process/request"
|
import { requestChatData } from "../process/request"
|
||||||
@@ -10,7 +10,6 @@ import { selectedCharID } from "../stores"
|
|||||||
import { getModuleRegexScripts } from "../process/modules"
|
import { getModuleRegexScripts } from "../process/modules"
|
||||||
import { getNodetextToSentence, sleep } from "../util"
|
import { getNodetextToSentence, sleep } from "../util"
|
||||||
import { processScriptFull } from "../process/scripts"
|
import { processScriptFull } from "../process/scripts"
|
||||||
import { Capacitor } from "@capacitor/core"
|
|
||||||
|
|
||||||
let cache={
|
let cache={
|
||||||
origin: [''],
|
origin: [''],
|
||||||
@@ -20,7 +19,7 @@ let cache={
|
|||||||
let waitTrans = 0
|
let waitTrans = 0
|
||||||
|
|
||||||
export async function translate(text:string, reverse:boolean) {
|
export async function translate(text:string, reverse:boolean) {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const plug = await translatorPlugin(text, reverse ? db.translator: 'en', reverse ? 'en' : db.translator)
|
const plug = await translatorPlugin(text, reverse ? db.translator: 'en', reverse ? 'en' : db.translator)
|
||||||
if(plug){
|
if(plug){
|
||||||
return plug.content
|
return plug.content
|
||||||
@@ -105,7 +104,7 @@ export async function runTranslator(text:string, reverse:boolean, from:string,ta
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function translateMain(text:string, arg:{from:string, to:string, host:string}){
|
async function translateMain(text:string, arg:{from:string, to:string, host:string}){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
if(db.translatorType === 'llm'){
|
if(db.translatorType === 'llm'){
|
||||||
const tr = db.translator || 'en'
|
const tr = db.translator || 'en'
|
||||||
return translateLLM(text, {to: tr})
|
return translateLLM(text, {to: tr})
|
||||||
@@ -208,7 +207,7 @@ async function jaTrans(text:string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isExpTranslator(){
|
export function isExpTranslator(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.translatorType === 'llm' || db.translatorType === 'deepl' || db.translatorType === 'deeplX'
|
return db.translatorType === 'llm' || db.translatorType === 'deepl' || db.translatorType === 'deeplX'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +215,7 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
|
|||||||
let alwaysExistChar: character | groupChat | simpleCharacterArgument;
|
let alwaysExistChar: character | groupChat | simpleCharacterArgument;
|
||||||
if(charArg !== ''){
|
if(charArg !== ''){
|
||||||
if(typeof(charArg) === 'string'){
|
if(typeof(charArg) === 'string'){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const charId = get(selectedCharID)
|
const charId = get(selectedCharID)
|
||||||
alwaysExistChar = db.characters[charId]
|
alwaysExistChar = db.characters[charId]
|
||||||
}
|
}
|
||||||
@@ -232,7 +231,7 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
|
|||||||
chaId: 'simple'
|
chaId: 'simple'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let DoingChat = get(doingChat)
|
let DoingChat = get(doingChat)
|
||||||
if(DoingChat){
|
if(DoingChat){
|
||||||
if(isExpTranslator()){
|
if(isExpTranslator()){
|
||||||
@@ -440,7 +439,7 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
function needSuperChunkedTranslate(){
|
function needSuperChunkedTranslate(){
|
||||||
return get(DataBase).translatorType === 'deeplX'
|
return getDatabase().translatorType === 'deeplX'
|
||||||
}
|
}
|
||||||
|
|
||||||
let llmCache = new Map<string, string>()
|
let llmCache = new Map<string, string>()
|
||||||
@@ -455,7 +454,7 @@ async function translateLLM(text:string, arg:{to:string}){
|
|||||||
return `<style-data style-index="${styleDecodes.length-1}"></style-data>`
|
return `<style-data style-index="${styleDecodes.length-1}"></style-data>`
|
||||||
})
|
})
|
||||||
|
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const charIndex = get(selectedCharID)
|
const charIndex = get(selectedCharID)
|
||||||
const currentChar = db.characters[charIndex]
|
const currentChar = db.characters[charIndex]
|
||||||
let translatorNote
|
let translatorNote
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get, writable, type Writable } from "svelte/store"
|
import { get, writable, type Writable } from "svelte/store"
|
||||||
import type { Database, Message } from "./storage/database.svelte"
|
import type { Database, Message } from "./storage/database.svelte"
|
||||||
import { DataBase } from "./storage/database.svelte"
|
import { getDatabase } from "./storage/database.svelte"
|
||||||
import { selectedCharID } from "./stores"
|
import { selectedCharID } from "./stores"
|
||||||
import {open} from '@tauri-apps/plugin-dialog'
|
import {open} from '@tauri-apps/plugin-dialog'
|
||||||
import { readFile } from "@tauri-apps/plugin-fs"
|
import { readFile } from "@tauri-apps/plugin-fs"
|
||||||
@@ -17,7 +17,7 @@ export interface Messagec extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function messageForm(arg:Message[], loadPages:number){
|
export function messageForm(arg:Message[], loadPages:number){
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let selectedChar = get(selectedCharID)
|
let selectedChar = get(selectedCharID)
|
||||||
function reformatContent(data:string){
|
function reformatContent(data:string){
|
||||||
return data.trim()
|
return data.trim()
|
||||||
@@ -100,7 +100,7 @@ export async function selectMultipleFile(ext:string[]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const replacePlaceholders = (msg:string, name:string) => {
|
export const replacePlaceholders = (msg:string, name:string) => {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
let selectedChar = get(selectedCharID)
|
let selectedChar = get(selectedCharID)
|
||||||
let currentChar = db.characters[selectedChar]
|
let currentChar = db.characters[selectedChar]
|
||||||
return msg .replace(/({{char}})|({{Char}})|(<Char>)|(<char>)/gi, currentChar.name)
|
return msg .replace(/({{char}})|({{Char}})|(<Char>)|(<char>)/gi, currentChar.name)
|
||||||
@@ -110,7 +110,7 @@ export const replacePlaceholders = (msg:string, name:string) => {
|
|||||||
|
|
||||||
function checkPersonaBinded(){
|
function checkPersonaBinded(){
|
||||||
try {
|
try {
|
||||||
let db = get(DataBase)
|
let db = getDatabase()
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const character = db.characters[selectedChar]
|
const character = db.characters[selectedChar]
|
||||||
const chat = character.chats[character.chatPage]
|
const chat = character.chats[character.chatPage]
|
||||||
@@ -129,7 +129,7 @@ export function getUserName(){
|
|||||||
if(bindedPersona){
|
if(bindedPersona){
|
||||||
return bindedPersona.name
|
return bindedPersona.name
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.username ?? 'User'
|
return db.username ?? 'User'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ export function getUserIcon(){
|
|||||||
if(bindedPersona){
|
if(bindedPersona){
|
||||||
return bindedPersona.icon
|
return bindedPersona.icon
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.userIcon ?? ''
|
return db.userIcon ?? ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ export function getPersonaPrompt(){
|
|||||||
if(bindedPersona){
|
if(bindedPersona){
|
||||||
return bindedPersona.personaPrompt
|
return bindedPersona.personaPrompt
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.personaPrompt ?? ''
|
return db.personaPrompt ?? ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ export function getUserIconProtrait(){
|
|||||||
if(bindedPersona){
|
if(bindedPersona){
|
||||||
return bindedPersona.largePortrait
|
return bindedPersona.largePortrait
|
||||||
}
|
}
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
return db.personas[db.selectedPersona].largePortrait
|
return db.personas[db.selectedPersona].largePortrait
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false
|
return false
|
||||||
@@ -172,7 +172,7 @@ export function selectFileByDom(allowedExtensions:string[], multiple:'multiple'|
|
|||||||
const fileInput = document.createElement('input');
|
const fileInput = document.createElement('input');
|
||||||
fileInput.type = 'file';
|
fileInput.type = 'file';
|
||||||
fileInput.multiple = multiple === 'multiple';
|
fileInput.multiple = multiple === 'multiple';
|
||||||
const acceptAll = (get(DataBase).allowAllExtentionFiles || checkIsIos() || allowedExtensions[0] === '*')
|
const acceptAll = (getDatabase().allowAllExtentionFiles || checkIsIos() || allowedExtensions[0] === '*')
|
||||||
if(!acceptAll){
|
if(!acceptAll){
|
||||||
if (allowedExtensions && allowedExtensions.length) {
|
if (allowedExtensions && allowedExtensions.length) {
|
||||||
fileInput.accept = allowedExtensions.map(ext => `.${ext}`).join(',');
|
fileInput.accept = allowedExtensions.map(ext => `.${ext}`).join(',');
|
||||||
@@ -223,7 +223,7 @@ function readFileAsUint8Array(file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function changeFullscreen(){
|
export async function changeFullscreen(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const isFull = await appWindow.isFullscreen()
|
const isFull = await appWindow.isFullscreen()
|
||||||
if(db.fullScreen && (!isFull)){
|
if(db.fullScreen && (!isFull)){
|
||||||
await appWindow.setFullscreen(true)
|
await appWindow.setFullscreen(true)
|
||||||
@@ -244,7 +244,7 @@ export async function getCustomBackground(db:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function findCharacterbyId(id:string) {
|
export function findCharacterbyId(id:string) {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
for(const char of db.characters){
|
for(const char of db.characters){
|
||||||
if(char.type !== 'group'){
|
if(char.type !== 'group'){
|
||||||
if(char.chaId === id){
|
if(char.chaId === id){
|
||||||
@@ -258,7 +258,7 @@ export function findCharacterbyId(id:string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function findCharacterIndexbyId(id:string) {
|
export function findCharacterIndexbyId(id:string) {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let i=0;
|
let i=0;
|
||||||
for(const char of db.characters){
|
for(const char of db.characters){
|
||||||
if(char.chaId === id){
|
if(char.chaId === id){
|
||||||
@@ -270,7 +270,7 @@ export function findCharacterIndexbyId(id:string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getCharacterIndexObject() {
|
export function getCharacterIndexObject() {
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
let i=0;
|
let i=0;
|
||||||
let result:{[key:string]:number} = {}
|
let result:{[key:string]:number} = {}
|
||||||
for(const char of db.characters){
|
for(const char of db.characters){
|
||||||
@@ -364,7 +364,7 @@ export async function getEmotion(db:Database,chaEmotion:{[key:string]: [string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getAuthorNoteDefaultText(){
|
export function getAuthorNoteDefaultText(){
|
||||||
const db = get(DataBase)
|
const db = getDatabase()
|
||||||
const template = db.promptTemplate
|
const template = db.promptTemplate
|
||||||
if(!template){
|
if(!template){
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
Reference in New Issue
Block a user