Merge branch 'main' into main
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<img alt="text" src="https://github.com/kwaroran/RisuAI/assets/116663078/bc28e5a3-c6da-4a42-bfc1-f3ab3debdf65">
|
||||
</picture>
|
||||
|
||||
RisuAI, or Risu for short, is an AI chat software / web application with powerful features such as multiple API support, assets in the chat, regex functions and much more.
|
||||
RisuAI, or Risu for short, is an AI chatting software / web application with powerful features such as multiple API support, assets in the chat, regex functions and much more.
|
||||
|
||||
# Screenshots
|
||||
| |  |
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "RisuAI",
|
||||
"version": "1.76.1"
|
||||
"version": "1.76.3"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
@@ -23,6 +23,7 @@ export const languageEnglish = {
|
||||
alreadyCharInGroup: "There is already a character with the same name in the group.",
|
||||
noUserIcon: "You must set your icon first.",
|
||||
emptyText: "Text is empty.",
|
||||
wrongPassword: "Wrong Password",
|
||||
},
|
||||
showHelp: "Show Help",
|
||||
help:{
|
||||
@@ -507,4 +508,11 @@ export const languageEnglish = {
|
||||
geminiApiKey: "Gemini API Key",
|
||||
removePunctuationHypa: "Memory Punctuation Removal",
|
||||
memoryLimitThickness: "Memory Limit Thickness",
|
||||
inputCardPassword: "Input Card Password",
|
||||
ccv2Desc: 'Character Card V2 is is a format widely used in chatbot programs.',
|
||||
rccDesc: 'Risu Refined Character Card is a format with additional features like password, integrity check and etc.',
|
||||
password: "Password",
|
||||
license: "License",
|
||||
licenseDesc: "You can choose license for the downloaders to limit the usages of your card's prompt.",
|
||||
passwordDesc: "You can set a password to protect your card from unauthorized access.",
|
||||
}
|
||||
@@ -7,12 +7,19 @@
|
||||
import BarIcon from '../SideBars/BarIcon.svelte';
|
||||
import { User } from 'lucide-svelte';
|
||||
import { hubURL } from 'src/ts/characterCards';
|
||||
import TextInput from '../UI/GUI/TextInput.svelte';
|
||||
import { openURL } from 'src/ts/storage/globalApi';
|
||||
import Button from '../UI/GUI/Button.svelte';
|
||||
import TextInput from '../UI/GUI/TextInput.svelte';
|
||||
import { openURL } from 'src/ts/storage/globalApi';
|
||||
import Button from '../UI/GUI/Button.svelte';
|
||||
import { XIcon } from "lucide-svelte";
|
||||
import SelectInput from "../UI/GUI/SelectInput.svelte";
|
||||
import { CCLicenseData } from "src/ts/creation/license";
|
||||
import OptionInput from "../UI/GUI/OptionInput.svelte";
|
||||
import { language } from 'src/lang';
|
||||
let btn
|
||||
let input = ''
|
||||
|
||||
let cardExportType = ''
|
||||
let cardExportPassword = ''
|
||||
let cardLicense = ''
|
||||
$: (() => {
|
||||
if(btn){
|
||||
btn.focus()
|
||||
@@ -40,7 +47,7 @@
|
||||
}
|
||||
}}></svelte:window>
|
||||
|
||||
{#if $alertStore.type !== 'none' && $alertStore.type !== 'toast'}
|
||||
{#if $alertStore.type !== 'none' && $alertStore.type !== 'toast' && $alertStore.type !== 'cardexport'}
|
||||
<div class="absolute w-full h-full z-50 bg-black bg-opacity-50 flex justify-center items-center" class:vis={ $alertStore.type === 'wait2'}>
|
||||
<div class="bg-darkbg p-4 break-any rounded-md flex flex-col max-w-3xl max-h-full overflow-y-auto">
|
||||
{#if $alertStore.type === 'error'}
|
||||
@@ -160,6 +167,63 @@
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{:else if $alertStore.type === 'cardexport'}
|
||||
<div class="fixed top-0 left-0 h-full w-full bg-black bg-opacity-50 flex flex-col z-50 items-center justify-center" on:click={close}>
|
||||
<div class="bg-darkbg rounded-md p-4 max-w-full flex flex-col w-2xl" on:click|stopPropagation>
|
||||
<h1 class="font-bold text-2xl w-full">
|
||||
<span>
|
||||
Export Character
|
||||
</span>
|
||||
<button class="float-right text-textcolor2 hover:text-green-500" on:click={() => {
|
||||
alertStore.set({
|
||||
type: 'none',
|
||||
msg: JSON.stringify({
|
||||
type: 'cancel',
|
||||
password: cardExportPassword,
|
||||
license: cardLicense
|
||||
})
|
||||
})
|
||||
}}>
|
||||
<XIcon />
|
||||
</button>
|
||||
</h1>
|
||||
<span class="text-textcolor mt-4">Type</span>
|
||||
{#if cardExportType === ''}
|
||||
<span class="text-textcolor2 text-sm">{language.ccv2Desc}</span>
|
||||
{:else}
|
||||
<span class="text-textcolor2 text-sm">{language.rccDesc}</span>
|
||||
{/if}
|
||||
<div class="flex items-center flex-wrap mt-2">
|
||||
<button class="bg-bgcolor px-2 py-4 rounded-lg flex-1" class:ring-1={cardExportType === ''} on:click={() => {cardExportType = ''}}>Character Card V2</button>
|
||||
<button class="bg-bgcolor px-2 py-4 rounded-lg ml-2 flex-1" class:ring-1={cardExportType === 'rcc'} on:click={() => {cardExportType = 'rcc'}}>Risu RCC</button>
|
||||
</div>
|
||||
{#if cardExportType === 'rcc'}
|
||||
<span class="text-textcolor mt-4">{language.password}</span>
|
||||
<span class="text-textcolor2 text-sm">{language.passwordDesc}</span>
|
||||
<TextInput placeholder="" bind:value={cardExportPassword} />
|
||||
<span class="text-textcolor mt-4">{language.license}</span>
|
||||
<span class="text-textcolor2 text-sm">{language.licenseDesc}</span>
|
||||
<SelectInput bind:value={cardLicense}>
|
||||
<OptionInput value="">None</OptionInput>
|
||||
{#each Object.keys(CCLicenseData) as ccl}
|
||||
<OptionInput value={ccl}>{CCLicenseData[ccl][2]} ({CCLicenseData[ccl][1]})</OptionInput>
|
||||
{/each}
|
||||
</SelectInput>
|
||||
{/if}
|
||||
<Button className="mt-4" on:click={() => {
|
||||
alertStore.set({
|
||||
type: 'none',
|
||||
msg: JSON.stringify({
|
||||
type: cardExportType,
|
||||
password: cardExportPassword,
|
||||
license: cardLicense
|
||||
})
|
||||
})
|
||||
}}>{language.export}</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{:else if $alertStore.type === 'toast'}
|
||||
<div class="toast-anime absolute right-0 bottom-0 bg-darkbg p-4 break-any rounded-md flex flex-col max-w-3xl max-h-11/12 overflow-y-auto z-50 text-textcolor"
|
||||
on:animationend={() => {
|
||||
|
||||
@@ -122,13 +122,14 @@
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('instructgpt35')}}>GPT-3.5 Instruct</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4')}}>GPT-4</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_32k')}}>GPT-4 32K</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_1106')}}>GPT-4 Turbo 1106</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_0125')}}>GPT-4 Turbo 0125</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gptvi4_1106')}}>GPT-4 Turbo 1106 Vision</button>
|
||||
{#if showUnrec}
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt35_16k')}}>GPT-3.5 Turbo 16K</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_0301')}}>GPT-4 0301</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_0613')}}>GPT-4 0613</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_32k_0613')}}>GPT-4 32K 0613</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt4_1106')}}>GPT-4 Turbo 1106</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt35_1106')}}>GPT-3.5 Turbo 1106</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt35_0613')}}>GPT-3.5 Turbo 0613</button>
|
||||
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('gpt35_16k_0613')}}>GPT-3.5 Turbo 16K 0613</button>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { sleep } from "./util"
|
||||
import { language } from "../lang"
|
||||
|
||||
interface alertData{
|
||||
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'
|
||||
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'
|
||||
msg: string
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ export function alertWait(msg:string){
|
||||
|
||||
}
|
||||
|
||||
|
||||
export function alertClear(){
|
||||
alertStore.set({
|
||||
'type': 'none',
|
||||
@@ -140,6 +141,27 @@ export async function alertConfirm(msg:string){
|
||||
return get(alertStore).msg === 'yes'
|
||||
}
|
||||
|
||||
export async function alertCardExport(){
|
||||
|
||||
alertStore.set({
|
||||
'type': 'cardexport',
|
||||
'msg': ''
|
||||
})
|
||||
|
||||
while(true){
|
||||
if (get(alertStore).type === 'none'){
|
||||
break
|
||||
}
|
||||
await sleep(10)
|
||||
}
|
||||
|
||||
return JSON.parse(get(alertStore).msg) as {
|
||||
type: string,
|
||||
password: string,
|
||||
license: string
|
||||
}
|
||||
}
|
||||
|
||||
export async function alertTOS(){
|
||||
|
||||
// if(localStorage.getItem('tos') === 'true'){
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { get, writable, type Writable } from "svelte/store"
|
||||
import { alertConfirm, alertError, 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 } from "./storage/database"
|
||||
import { checkNullish, selectMultipleFile, sleep } from "./util"
|
||||
import { checkNullish, decryptBuffer, encryptBuffer, selectMultipleFile, sleep } from "./util"
|
||||
import { language } from "src/lang"
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { characterFormatUpdate } from "./characters"
|
||||
import { checkCharOrder, downloadFile, loadAsset, LocalWriter, readImage, saveAsset } from "./storage/globalApi"
|
||||
import { cloneDeep } from "lodash"
|
||||
import { selectedCharID } from "./stores"
|
||||
import { convertImage } from "./parser"
|
||||
import { convertImage, hasher } from "./parser"
|
||||
|
||||
import { reencodeImage } from "./image"
|
||||
import { PngChunk } from "./pngChunk"
|
||||
@@ -71,7 +71,10 @@ async function importCharacterProcess(f:{
|
||||
break
|
||||
}
|
||||
if(chunk.key === 'chara'){
|
||||
readedChara = chunk.value
|
||||
//For memory reason, limit to 2MB
|
||||
if(readedChara.length < 2 * 1024 * 1024){
|
||||
readedChara = chunk.value.replaceAll('\0', '')
|
||||
}
|
||||
break
|
||||
}
|
||||
if(chunk.key.startsWith('chara-ext-asset_')){
|
||||
@@ -86,7 +89,63 @@ async function importCharacterProcess(f:{
|
||||
alertError(language.errors.noData)
|
||||
return
|
||||
}
|
||||
{
|
||||
|
||||
if(readedChara.startsWith('rcc||')){
|
||||
const parts = readedChara.split('||')
|
||||
const type = parts[1]
|
||||
if(type === 'rccv1'){
|
||||
if(parts.length !== 5){
|
||||
alertError(language.errors.noData)
|
||||
return
|
||||
}
|
||||
const encrypted = Buffer.from(parts[2], 'base64')
|
||||
const hashed = await hasher(encrypted)
|
||||
if(hashed !== parts[3]){
|
||||
alertError(language.errors.noData)
|
||||
return
|
||||
}
|
||||
console.log(parts[4])
|
||||
const metaData:RccCardMetaData = JSON.parse(Buffer.from(parts[4], 'base64').toString('utf-8'))
|
||||
console.log(metaData)
|
||||
if(metaData.usePassword){
|
||||
const password = await alertInput(language.inputCardPassword)
|
||||
if(!password){
|
||||
return
|
||||
}
|
||||
else{
|
||||
try {
|
||||
const decrypted = await decryptBuffer(encrypted, password)
|
||||
const charaData:CharacterCardV2 = JSON.parse(Buffer.from(decrypted).toString('utf-8'))
|
||||
if(await importSpecv2(charaData, img, "normal", assets)){
|
||||
let db = get(DataBase)
|
||||
return db.characters.length - 1
|
||||
}
|
||||
else{
|
||||
throw new Error('Error while importing')
|
||||
}
|
||||
} catch (error) {
|
||||
alertError(language.errors.wrongPassword)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
const decrypted = await decryptBuffer(encrypted, 'RISU_NONE')
|
||||
try {
|
||||
const charaData:CharacterCardV2 = JSON.parse(Buffer.from(decrypted).toString('utf-8'))
|
||||
if(await importSpecv2(charaData, img, "normal", assets)){
|
||||
let db = get(DataBase)
|
||||
return db.characters.length - 1
|
||||
}
|
||||
} catch (error) {
|
||||
alertError(language.errors.noData)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
const charaData:CharacterCardV2 = JSON.parse(Buffer.from(readedChara, 'base64').toString('utf-8'))
|
||||
if(await importSpecv2(charaData, img, "normal", assets)){
|
||||
let db = get(DataBase)
|
||||
@@ -217,8 +276,17 @@ export async function exportChar(charaID:number) {
|
||||
return
|
||||
}
|
||||
|
||||
const sel = await alertSelect(['Export as PNG', 'Export as JSON'])
|
||||
exportSpecV2(char, sel === '1' ? 'json' : 'png')
|
||||
const option = await alertCardExport()
|
||||
if(option.type === 'cancel'){
|
||||
return
|
||||
}
|
||||
else if(option.type === 'rcc'){
|
||||
char.license = option.license
|
||||
exportSpecV2(char, 'rcc', {password:option.password})
|
||||
}
|
||||
else{
|
||||
exportSpecV2(char,'png')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -535,7 +603,7 @@ async function createBaseV2(char:character) {
|
||||
}
|
||||
|
||||
|
||||
export async function exportSpecV2(char:character, type:'png'|'json' = 'png') {
|
||||
export async function exportSpecV2(char:character, type:'png'|'json'|'rcc' = 'png', rcc:{password?:string} = {}) {
|
||||
let img = await readImage(char.image)
|
||||
|
||||
try{
|
||||
@@ -605,7 +673,22 @@ export async function exportSpecV2(char:character, type:'png'|'json' = 'png') {
|
||||
type: 'wait',
|
||||
msg: 'Loading... (Writing)'
|
||||
})
|
||||
await writer.write("chara", Buffer.from(JSON.stringify(card)).toString('base64'))
|
||||
|
||||
if(type === 'rcc'){
|
||||
const password = rcc.password || 'RISU_NONE'
|
||||
const json = JSON.stringify(card)
|
||||
const encrypted = Buffer.from(await encryptBuffer(Buffer.from(json, 'utf-8'), password))
|
||||
const hashed = await hasher(encrypted)
|
||||
const metaData:RccCardMetaData = {}
|
||||
if(password !== 'RISU_NONE'){
|
||||
metaData.usePassword = true
|
||||
}
|
||||
const rccString = 'rcc||rccv1||' + encrypted.toString('base64') + '||' + hashed + '||' + Buffer.from(JSON.stringify(metaData)).toString('base64')
|
||||
await writer.write("chara", rccString)
|
||||
}
|
||||
else{
|
||||
await writer.write("chara", Buffer.from(JSON.stringify(card)).toString('base64'))
|
||||
}
|
||||
|
||||
await writer.end()
|
||||
|
||||
@@ -880,3 +963,7 @@ interface charBookEntry{
|
||||
position?: 'before_char' | 'after_char' // whether the entry is placed before or after the character defs
|
||||
case_sensitive?:boolean
|
||||
}
|
||||
|
||||
interface RccCardMetaData{
|
||||
usePassword?: boolean
|
||||
}
|
||||
@@ -151,6 +151,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
case 'gpt4_0613':
|
||||
case 'gpt4_32k_0613':
|
||||
case 'gpt4_1106':
|
||||
case 'gpt4_0125':
|
||||
case 'gpt35_1106':
|
||||
case 'gpt35_0301':
|
||||
case 'gpt4_0301':
|
||||
@@ -402,6 +403,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
: requestModel === "gpt4_0613" ? 'gpt-4-0613'
|
||||
: requestModel === "gpt4_32k_0613" ? 'gpt-4-32k-0613'
|
||||
: requestModel === "gpt4_1106" ? 'gpt-4-1106-preview'
|
||||
: requestModel === 'gpt4_0125' ? 'gpt-4-0125-preview'
|
||||
: requestModel === "gptvi4_1106" ? 'gpt-4-vision-preview'
|
||||
: requestModel === "gpt35_1106" ? 'gpt-3.5-turbo-1106'
|
||||
: requestModel === 'gpt35_0301' ? 'gpt-3.5-turbo-0301'
|
||||
|
||||
@@ -15,7 +15,7 @@ import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = "1.76.1"
|
||||
export let appVer = "1.76.3"
|
||||
export let webAppSubVer = ''
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":"1.76.1"}
|
||||
{"version":"1.76.3"}
|
||||
Reference in New Issue
Block a user