Update to 1.10.0 (#65)
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "RisuAI",
|
||||
"version": "0.9.6"
|
||||
"version": "1.10.0"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
@@ -245,5 +245,8 @@ export const languageEnglish = {
|
||||
Speech: "Speech",
|
||||
ToggleSuperMemory: "Toggle SupaMemory",
|
||||
SuperMemory:"SupaMemory",
|
||||
useExperimental: "Able Experimental Features"
|
||||
useExperimental: "Able Experimental Features",
|
||||
showMemoryLimit: "Show Memory Limit",
|
||||
roundIcons: "Round Icons",
|
||||
useStreaming: "Use Streaming"
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { replacePlaceholders } from "../../ts/util";
|
||||
export let message = ''
|
||||
export let name = ''
|
||||
export let isLastMemory:boolean
|
||||
export let img:string|Promise<string> = ''
|
||||
export let idx = -1
|
||||
export let rerollIcon = false
|
||||
@@ -61,12 +62,14 @@
|
||||
|
||||
$: displaya(message)
|
||||
</script>
|
||||
<div class="flex max-w-full">
|
||||
<div class="text-neutral-200 mt-2 p-2 bg-transparent flex-grow ml-4 mr-4 border-t-gray-900 border-opacity-30 border-transparent flexium items-start">
|
||||
<div class="flex max-w-full justify-center" class:bgc={isLastMemory}>
|
||||
<div class="text-neutral-200 mt-1 mb-1 p-2 bg-transparent flex-grow ml-4 mr-4 border-t-gray-900 border-opacity-30 border-transparent flexium items-start">
|
||||
{#await img}
|
||||
<div class="rounded-md shadow-lg bg-gray-500 mt-2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`} />
|
||||
<div class="shadow-lg bg-gray-500 mt-2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`}
|
||||
class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons} />
|
||||
{:then m}
|
||||
<div class="rounded-md shadow-lg bg-gray-500 mt-2" style={m + `height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`} />
|
||||
<div class="shadow-lg bg-gray-500 mt-2" style={m + `height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`}
|
||||
class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons} />
|
||||
{/await}
|
||||
<span class="flex flex-col ml-4 w-full">
|
||||
<div class="flexium items-center chat">
|
||||
@@ -142,7 +145,7 @@
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.chat{
|
||||
max-width: calc(95% - 0.5rem);
|
||||
max-width: calc(100% - 0.5rem);
|
||||
word-break: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
rerollIcon={i === 0}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
isLastMemory={$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $DataBase.showMemoryLimit}
|
||||
/>
|
||||
{:else}
|
||||
<Chat
|
||||
@@ -256,6 +257,7 @@
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
img={getCharImage(findCharacterbyId(chat.saying).image, 'css')}
|
||||
isLastMemory={$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $DataBase.showMemoryLimit}
|
||||
/>
|
||||
{/if}
|
||||
{:else}
|
||||
@@ -264,6 +266,7 @@
|
||||
name={$DataBase.username}
|
||||
message={chat.data}
|
||||
img={getCharImage($DataBase.userIcon, 'css')}
|
||||
isLastMemory={$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $DataBase.showMemoryLimit}
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
@@ -300,6 +303,8 @@
|
||||
}
|
||||
$DataBase.characters[$selectedCharID] = cha
|
||||
}}
|
||||
isLastMemory={false}
|
||||
|
||||
/>
|
||||
{#if !$DataBase.characters[$selectedCharID].removedQuotes && $DataBase.characters[$selectedCharID].creatorNotes.length >= 2}
|
||||
<CreatorQuote quote={$DataBase.characters[$selectedCharID].creatorNotes} onRemove={() => {
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
<option value="gpt35" class="bg-darkbg appearance-none">OpenAI GPT-3.5</option>
|
||||
<option value="gpt4" class="bg-darkbg appearance-none">OpenAI GPT-4</option>
|
||||
<option value="textgen_webui" class="bg-darkbg appearance-none">Text Generation WebUI</option>
|
||||
<option value="palm2" class="bg-darkbg appearance-none">Google Palm2</option>
|
||||
{#if $DataBase.plugins.length > 0}
|
||||
<option value="custom" class="bg-darkbg appearance-none">Plugin</option>
|
||||
{/if}
|
||||
@@ -107,12 +108,17 @@
|
||||
<select class="bg-transparent input-text mt-2 mb-4 text-gray-200 appearance-none text-sm" bind:value={$DataBase.subModel}>
|
||||
<option value="gpt35" class="bg-darkbg appearance-none">OpenAI GPT-3.5</option>
|
||||
<option value="gpt4" class="bg-darkbg appearance-none">OpenAI GPT-4</option>
|
||||
<option value="palm2" class="bg-darkbg appearance-none">Google Palm2</option>
|
||||
<option value="textgen_webui" class="bg-darkbg appearance-none">Text Generation WebUI</option>
|
||||
{#if $customProviderStore.length > 0}
|
||||
<option value="custom" class="bg-darkbg appearance-none">Plugin</option>
|
||||
{/if}
|
||||
</select>
|
||||
|
||||
{#if $DataBase.aiModel === 'palm2' || $DataBase.subModel === 'palm2'}
|
||||
<span class="text-neutral-200">Palm2 {language.apiKey}</span>
|
||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" placeholder="..." bind:value={$DataBase.palmAPI}>
|
||||
{/if}
|
||||
{#if $DataBase.aiModel === 'gpt35' || $DataBase.aiModel === 'gpt4' || $DataBase.subModel === 'gpt4' || $DataBase.subModel === 'gpt35'}
|
||||
<span class="text-neutral-200">OpenAI {language.apiKey} <Help key="oaiapikey"/></span>
|
||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" placeholder="sk-XXXXXXXXXXXXXXXXXXXX" bind:value={$DataBase.openAIKey}>
|
||||
@@ -363,6 +369,11 @@
|
||||
<span>{language.fullscreen}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={$DataBase.showMemoryLimit}/>
|
||||
<span>{language.showMemoryLimit}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check check={$DataBase.customBackground !== ''} onChange={async (check) => {
|
||||
if(check){
|
||||
@@ -392,6 +403,11 @@
|
||||
<span>{language.SwipeRegenerate}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={$DataBase.roundIcons}/>
|
||||
<span>{language.roundIcons}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={$DataBase.instantRemove}/>
|
||||
<span>{language.instantRemove}</span>
|
||||
@@ -401,7 +417,7 @@
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.plugin}</h2>
|
||||
<span class="text-draculared text-xs mb-4">{language.pluginWarn}</span>
|
||||
|
||||
|
||||
|
||||
<div class="border-solid border-borderc p-2 flex flex-col border-1">
|
||||
{#if $DataBase.plugins.length === 0}
|
||||
<span class="text-gray-500">No Plugins</span>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { DataBase } from "src/ts/database";
|
||||
|
||||
export let src:string|Promise<string>;
|
||||
export let size = "22";
|
||||
</script>
|
||||
@@ -11,6 +13,7 @@
|
||||
style:width={size + "px"}
|
||||
style:height={size + "px"}
|
||||
style:minWidth={size + "px"}
|
||||
class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons}
|
||||
/>
|
||||
{:then img}
|
||||
<img
|
||||
@@ -19,6 +22,7 @@
|
||||
style:width={size + "px"}
|
||||
style:height={size + "px"}
|
||||
style:minWidth={size + "px"}
|
||||
class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons}
|
||||
alt="avatar"
|
||||
/>
|
||||
{/await}
|
||||
@@ -28,6 +32,7 @@
|
||||
style:width={size + "px"}
|
||||
style:height={size + "px"}
|
||||
style:minWidth={size + "px"}
|
||||
class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons}
|
||||
/>
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
@@ -107,4 +107,8 @@ html, body{
|
||||
border: none;
|
||||
outline: 0;
|
||||
border-bottom: 1px solid #6272a4;
|
||||
}
|
||||
|
||||
.bgc{
|
||||
border-top: 1px solid rgba(98, 114, 164, 0.3);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { cloneDeep } from 'lodash';
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = '0.9.6'
|
||||
export let appVer = '1.10.0'
|
||||
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
@@ -80,6 +80,9 @@ export function setDatabase(data:Database){
|
||||
if(checkNullish(data.language)){
|
||||
data.language = 'en'
|
||||
}
|
||||
if(checkNullish(data.swipe)){
|
||||
data.swipe = true
|
||||
}
|
||||
if(checkNullish(data.translator)){
|
||||
data.translator = ''
|
||||
}
|
||||
@@ -187,6 +190,9 @@ export function setDatabase(data:Database){
|
||||
if(checkNullish(data.supaMemoryPrompt)){
|
||||
data.supaMemoryPrompt = ''
|
||||
}
|
||||
if(checkNullish(data.showMemoryLimit)){
|
||||
data.showMemoryLimit = false
|
||||
}
|
||||
if(checkNullish(data.sdConfig)){
|
||||
data.sdConfig = {
|
||||
width:512,
|
||||
@@ -399,6 +405,10 @@ export interface Database{
|
||||
showUnrecommended:boolean
|
||||
elevenLabKey:string
|
||||
useExperimental:boolean
|
||||
showMemoryLimit:boolean
|
||||
roundIcons:boolean
|
||||
useStreaming:boolean
|
||||
palmAPI:string
|
||||
}
|
||||
|
||||
|
||||
@@ -422,6 +432,7 @@ export interface Chat{
|
||||
localLore: loreBook[]
|
||||
sdData?:string
|
||||
supaMemoryData?:string
|
||||
lastMemory?:string
|
||||
}
|
||||
|
||||
export interface Message{
|
||||
|
||||
@@ -238,18 +238,21 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
chats = sp.chats
|
||||
currentTokens = sp.currentTokens
|
||||
currentChat.supaMemoryData = sp.memory ?? currentChat.supaMemoryData
|
||||
currentChat.lastMemory = sp.lastId ?? currentChat.lastMemory
|
||||
}
|
||||
else{
|
||||
while(currentTokens > maxContextTokens){
|
||||
if(chats.length <= 1){
|
||||
alertError(language.errors.toomuchtoken)
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
currentTokens -= (await tokenize(chats[0].content) + 1)
|
||||
chats.splice(0, 1)
|
||||
}
|
||||
}
|
||||
currentChat.lastMemory = chats[0].memo
|
||||
console.log(currentChat.lastMemory)
|
||||
}
|
||||
let bias:{[key:number]:number} = {}
|
||||
|
||||
@@ -334,6 +337,9 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
if(req.type === 'fail'){
|
||||
alertError(req.result)
|
||||
return false
|
||||
}
|
||||
else if(req.type === 'streaming'){
|
||||
|
||||
}
|
||||
else{
|
||||
const result2 = processScriptFull(currentChar, reformatContent(req.result), 'editoutput')
|
||||
@@ -426,8 +432,8 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
maxTokens: 30,
|
||||
}, 'submodel')
|
||||
|
||||
if(rq.type === 'fail'){
|
||||
alertError(rq.result)
|
||||
if(rq.type === 'fail' || rq.type === 'streaming'){
|
||||
alertError(`${rq.result}`)
|
||||
return true
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -19,6 +19,9 @@ interface requestDataArgument{
|
||||
type requestDataResponse = {
|
||||
type: 'success'|'fail'
|
||||
result: string
|
||||
}|{
|
||||
type: "streaming",
|
||||
result: ReadableStreamDefaultReader<Uint8Array>
|
||||
}
|
||||
|
||||
export async function requestChatData(arg:requestDataArgument, model:'model'|'submodel'):Promise<requestDataResponse> {
|
||||
@@ -68,6 +71,22 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
replacerURL += 'chat/completions'
|
||||
}
|
||||
|
||||
if(db.useStreaming){
|
||||
const da = await fetch(replacerURL, {
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
"Authorization": "Bearer " + db.openAIKey
|
||||
},
|
||||
})
|
||||
|
||||
const reader = da.body.getReader()
|
||||
|
||||
return {
|
||||
type: 'streaming',
|
||||
result: reader
|
||||
}
|
||||
}
|
||||
|
||||
const res = await globalFetch(replacerURL, {
|
||||
body: body,
|
||||
headers: {
|
||||
@@ -233,6 +252,78 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'palm2':{
|
||||
const body = {
|
||||
"prompt": {
|
||||
"text": stringlizeChat(formated, currentChar?.name ?? '')
|
||||
},
|
||||
"safetySettings":[
|
||||
{
|
||||
"category": "HARM_CATEGORY_UNSPECIFIED",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_DEROGATORY",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_TOXICITY",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_VIOLENCE",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_SEXUAL",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_MEDICAL",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_DANGEROUS",
|
||||
"threshold": "BLOCK_NONE"
|
||||
}
|
||||
],
|
||||
"temperature": arg.temperature,
|
||||
"maxOutputTokens": arg.maxTokens,
|
||||
"candidate_count": 1
|
||||
}
|
||||
const res = await globalFetch(`https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText?key=${db.palmAPI}`, {
|
||||
body: body,
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
})
|
||||
|
||||
if(res.ok){
|
||||
if(res.data.candidates){
|
||||
let output:string = res.data.candidates[0].output
|
||||
const ind = output.search(/(system note)|(user)|(assistant):/gi)
|
||||
if(ind >= 0){
|
||||
output = output.substring(0, ind)
|
||||
}
|
||||
return {
|
||||
type: 'success',
|
||||
result: output
|
||||
}
|
||||
}
|
||||
else{
|
||||
return {
|
||||
type: 'fail',
|
||||
result: `${JSON.stringify(res.data)}`
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
return {
|
||||
type: 'fail',
|
||||
result: `${JSON.stringify(res.data)}`
|
||||
}
|
||||
}
|
||||
}
|
||||
default:{
|
||||
return {
|
||||
type: 'fail',
|
||||
|
||||
@@ -80,8 +80,8 @@ export async function stableDiff(currentChar:character,prompt:string){
|
||||
}, 'submodel')
|
||||
|
||||
|
||||
if(rq.type === 'fail'){
|
||||
alertError(rq.result)
|
||||
if(rq.type === 'fail' || rq.type === 'streaming'){
|
||||
alertError(`${rq.result}`)
|
||||
return false
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -5,8 +5,10 @@ import { tokenize } from "../tokenizer";
|
||||
import { findCharacterbyId } from "../util";
|
||||
import { requestChatData } from "./request";
|
||||
|
||||
export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxContextTokens:number,room:Chat,char:character|groupChat): Promise<{ currentTokens: number; chats: OpenAIChat[]; error?:string; memory?:string}>{
|
||||
export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxContextTokens:number,room:Chat,char:character|groupChat): Promise<{ currentTokens: number; chats: OpenAIChat[]; error?:string; memory?:string;lastId?:string}>{
|
||||
const db = get(DataBase)
|
||||
console.log("Memory: " + currentTokens)
|
||||
|
||||
if(currentTokens > maxContextTokens){
|
||||
let coIndex = -1
|
||||
for(let i=0;i<chats.length;i++){
|
||||
@@ -29,26 +31,28 @@ export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxCont
|
||||
const id = splited.splice(0,1)[0]
|
||||
const data = splited.join('\n')
|
||||
|
||||
for(let i=0;i<chats.length;i++){
|
||||
let i =0;
|
||||
while(true){
|
||||
if(chats.length === 0){
|
||||
return {
|
||||
currentTokens: currentTokens,
|
||||
chats: chats,
|
||||
error: "SupaMemory: chat ID not found"
|
||||
}
|
||||
}
|
||||
if(chats[0].memo === id){
|
||||
break
|
||||
}
|
||||
currentTokens -= (await tokenize(chats[0].content) + 1)
|
||||
chats.splice(0, 1)
|
||||
}
|
||||
|
||||
if(chats.length === 0){
|
||||
return {
|
||||
currentTokens: currentTokens,
|
||||
chats: chats,
|
||||
error: "SupaMemory: chat ID not found"
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
|
||||
supaMemory = data
|
||||
currentTokens += await tokenize(supaMemory) + 1
|
||||
}
|
||||
|
||||
|
||||
if(currentTokens < maxContextTokens){
|
||||
chats.unshift({
|
||||
role: "system",
|
||||
@@ -134,7 +138,6 @@ export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxCont
|
||||
const tokenz = await tokenize(result + '\n\n') + 5
|
||||
currentTokens += tokenz
|
||||
supaMemory += result + '\n\n'
|
||||
console.log(tokenz)
|
||||
}
|
||||
|
||||
chats.unshift({
|
||||
@@ -144,7 +147,8 @@ export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxCont
|
||||
return {
|
||||
currentTokens: currentTokens,
|
||||
chats: chats,
|
||||
memory: lastId + '\n' + supaMemory
|
||||
memory: lastId + '\n' + supaMemory,
|
||||
lastId: lastId
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ export function messageForm(arg:Message[], loadPages:number){
|
||||
role: m.role,
|
||||
data: reformatContent(m.data),
|
||||
index: i,
|
||||
saying: m.saying
|
||||
saying: m.saying,
|
||||
chatId: m.chatId ?? 'none'
|
||||
})
|
||||
}
|
||||
return a.slice(0, loadPages)
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":"0.9.6"}
|
||||
{"version":"1.10.0"}
|
||||
Reference in New Issue
Block a user