[feat] added memory limit line
This commit is contained in:
@@ -245,5 +245,6 @@ export const languageEnglish = {
|
|||||||
Speech: "Speech",
|
Speech: "Speech",
|
||||||
ToggleSuperMemory: "Toggle SupaMemory",
|
ToggleSuperMemory: "Toggle SupaMemory",
|
||||||
SuperMemory:"SupaMemory",
|
SuperMemory:"SupaMemory",
|
||||||
useExperimental: "Able Experimental Features"
|
useExperimental: "Able Experimental Features",
|
||||||
|
showMemoryLimit: "Show Memory Limit"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import { replacePlaceholders } from "../../ts/util";
|
import { replacePlaceholders } from "../../ts/util";
|
||||||
export let message = ''
|
export let message = ''
|
||||||
export let name = ''
|
export let name = ''
|
||||||
|
export let isLastMemory:boolean
|
||||||
export let img:string|Promise<string> = ''
|
export let img:string|Promise<string> = ''
|
||||||
export let idx = -1
|
export let idx = -1
|
||||||
export let rerollIcon = false
|
export let rerollIcon = false
|
||||||
@@ -61,8 +62,8 @@
|
|||||||
|
|
||||||
$: displaya(message)
|
$: displaya(message)
|
||||||
</script>
|
</script>
|
||||||
<div class="flex max-w-full">
|
<div class="flex max-w-full justify-center" class:bgc={isLastMemory}>
|
||||||
<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="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}
|
{#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="rounded-md shadow-lg bg-gray-500 mt-2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`} />
|
||||||
{:then m}
|
{:then m}
|
||||||
@@ -142,7 +143,7 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
.chat{
|
.chat{
|
||||||
max-width: calc(95% - 0.5rem);
|
max-width: calc(100% - 0.5rem);
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,6 +246,7 @@
|
|||||||
rerollIcon={i === 0}
|
rerollIcon={i === 0}
|
||||||
onReroll={reroll}
|
onReroll={reroll}
|
||||||
unReroll={unReroll}
|
unReroll={unReroll}
|
||||||
|
isLastMemory={$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $DataBase.showMemoryLimit}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Chat
|
<Chat
|
||||||
@@ -256,6 +257,7 @@
|
|||||||
onReroll={reroll}
|
onReroll={reroll}
|
||||||
unReroll={unReroll}
|
unReroll={unReroll}
|
||||||
img={getCharImage(findCharacterbyId(chat.saying).image, 'css')}
|
img={getCharImage(findCharacterbyId(chat.saying).image, 'css')}
|
||||||
|
isLastMemory={$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $DataBase.showMemoryLimit}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
@@ -264,6 +266,7 @@
|
|||||||
name={$DataBase.username}
|
name={$DataBase.username}
|
||||||
message={chat.data}
|
message={chat.data}
|
||||||
img={getCharImage($DataBase.userIcon, 'css')}
|
img={getCharImage($DataBase.userIcon, 'css')}
|
||||||
|
isLastMemory={$DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $DataBase.showMemoryLimit}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
@@ -300,6 +303,8 @@
|
|||||||
}
|
}
|
||||||
$DataBase.characters[$selectedCharID] = cha
|
$DataBase.characters[$selectedCharID] = cha
|
||||||
}}
|
}}
|
||||||
|
isLastMemory={false}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
{#if !$DataBase.characters[$selectedCharID].removedQuotes && $DataBase.characters[$selectedCharID].creatorNotes.length >= 2}
|
{#if !$DataBase.characters[$selectedCharID].removedQuotes && $DataBase.characters[$selectedCharID].creatorNotes.length >= 2}
|
||||||
<CreatorQuote quote={$DataBase.characters[$selectedCharID].creatorNotes} onRemove={() => {
|
<CreatorQuote quote={$DataBase.characters[$selectedCharID].creatorNotes} onRemove={() => {
|
||||||
|
|||||||
@@ -363,6 +363,11 @@
|
|||||||
<span>{language.fullscreen}</span>
|
<span>{language.fullscreen}</span>
|
||||||
</div>
|
</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">
|
<div class="flex items-center mt-2">
|
||||||
<Check check={$DataBase.customBackground !== ''} onChange={async (check) => {
|
<Check check={$DataBase.customBackground !== ''} onChange={async (check) => {
|
||||||
if(check){
|
if(check){
|
||||||
|
|||||||
@@ -108,3 +108,7 @@ html, body{
|
|||||||
outline: 0;
|
outline: 0;
|
||||||
border-bottom: 1px solid #6272a4;
|
border-bottom: 1px solid #6272a4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bgc{
|
||||||
|
border-top: 1px solid rgba(98, 114, 164, 0.3);
|
||||||
|
}
|
||||||
@@ -80,6 +80,9 @@ export function setDatabase(data:Database){
|
|||||||
if(checkNullish(data.language)){
|
if(checkNullish(data.language)){
|
||||||
data.language = 'en'
|
data.language = 'en'
|
||||||
}
|
}
|
||||||
|
if(checkNullish(data.swipe)){
|
||||||
|
data.swipe = true
|
||||||
|
}
|
||||||
if(checkNullish(data.translator)){
|
if(checkNullish(data.translator)){
|
||||||
data.translator = ''
|
data.translator = ''
|
||||||
}
|
}
|
||||||
@@ -187,6 +190,9 @@ export function setDatabase(data:Database){
|
|||||||
if(checkNullish(data.supaMemoryPrompt)){
|
if(checkNullish(data.supaMemoryPrompt)){
|
||||||
data.supaMemoryPrompt = ''
|
data.supaMemoryPrompt = ''
|
||||||
}
|
}
|
||||||
|
if(checkNullish(data.showMemoryLimit)){
|
||||||
|
data.showMemoryLimit = false
|
||||||
|
}
|
||||||
if(checkNullish(data.sdConfig)){
|
if(checkNullish(data.sdConfig)){
|
||||||
data.sdConfig = {
|
data.sdConfig = {
|
||||||
width:512,
|
width:512,
|
||||||
@@ -399,6 +405,7 @@ export interface Database{
|
|||||||
showUnrecommended:boolean
|
showUnrecommended:boolean
|
||||||
elevenLabKey:string
|
elevenLabKey:string
|
||||||
useExperimental:boolean
|
useExperimental:boolean
|
||||||
|
showMemoryLimit:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -422,6 +429,7 @@ export interface Chat{
|
|||||||
localLore: loreBook[]
|
localLore: loreBook[]
|
||||||
sdData?:string
|
sdData?:string
|
||||||
supaMemoryData?:string
|
supaMemoryData?:string
|
||||||
|
lastMemory?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Message{
|
export interface Message{
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
|||||||
chats = sp.chats
|
chats = sp.chats
|
||||||
currentTokens = sp.currentTokens
|
currentTokens = sp.currentTokens
|
||||||
currentChat.supaMemoryData = sp.memory ?? currentChat.supaMemoryData
|
currentChat.supaMemoryData = sp.memory ?? currentChat.supaMemoryData
|
||||||
|
currentChat.lastMemory = sp.lastId ?? currentChat.lastMemory
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
while(currentTokens > maxContextTokens){
|
while(currentTokens > maxContextTokens){
|
||||||
@@ -250,6 +251,8 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
|||||||
currentTokens -= (await tokenize(chats[0].content) + 1)
|
currentTokens -= (await tokenize(chats[0].content) + 1)
|
||||||
chats.splice(0, 1)
|
chats.splice(0, 1)
|
||||||
}
|
}
|
||||||
|
currentChat.lastMemory = chats[0].memo
|
||||||
|
console.log(currentChat.lastMemory)
|
||||||
}
|
}
|
||||||
let bias:{[key:number]:number} = {}
|
let bias:{[key:number]:number} = {}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { tokenize } from "../tokenizer";
|
|||||||
import { findCharacterbyId } from "../util";
|
import { findCharacterbyId } from "../util";
|
||||||
import { requestChatData } from "./request";
|
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)
|
const db = get(DataBase)
|
||||||
console.log("Memory: " + currentTokens)
|
console.log("Memory: " + currentTokens)
|
||||||
|
|
||||||
@@ -147,7 +147,8 @@ export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxCont
|
|||||||
return {
|
return {
|
||||||
currentTokens: currentTokens,
|
currentTokens: currentTokens,
|
||||||
chats: chats,
|
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,
|
role: m.role,
|
||||||
data: reformatContent(m.data),
|
data: reformatContent(m.data),
|
||||||
index: i,
|
index: i,
|
||||||
saying: m.saying
|
saying: m.saying,
|
||||||
|
chatId: m.chatId ?? 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return a.slice(0, loadPages)
|
return a.slice(0, loadPages)
|
||||||
|
|||||||
Reference in New Issue
Block a user