Experimental settings updated

regular push for saving
This commit is contained in:
LightningHyperBlaze45654
2024-06-12 20:58:30 -07:00
parent 0e70869b88
commit 9e77b46936
7 changed files with 35 additions and 30 deletions

View File

@@ -277,25 +277,29 @@
<SelectInput value={ <SelectInput value={
$DataBase.hypav2 ? 'hypaV2' : $DataBase.hypav2 ? 'hypaV2' :
$DataBase.supaMemoryType !== 'none' ? 'supaMemory' : $DataBase.supaModelType !== 'none' ? 'supaMemory' :
$DataBase.hanuraiEnable ? 'hanuraiMemory' : 'none' $DataBase.hanuraiEnable ? 'hanuraiMemory' : 'none'
} on:change={(v) => { } on:change={(v) => {
//@ts-ignore //@ts-ignore
const value = v.target.value const value = v.target.value
if (value === 'supaMemory'){ if (value === 'supaMemory'){
$DataBase.supaMemoryType = 'distilbart' $DataBase.supaModelType = 'distilbart'
$DataBase.memoryAlgorithmType = 'supaMemory'
$DataBase.hypav2 = false $DataBase.hypav2 = false
$DataBase.hanuraiEnable = false $DataBase.hanuraiEnable = false
} else if (value === 'hanuraiMemory'){ } else if (value === 'hanuraiMemory'){
$DataBase.supaMemoryType = 'none' $DataBase.supaModelType = 'none'
$DataBase.memoryAlgorithmType = 'hanuraiMemory'
$DataBase.hypav2 = false $DataBase.hypav2 = false
$DataBase.hanuraiEnable = true $DataBase.hanuraiEnable = true
} else if (value === 'hypaV2') { } else if (value === 'hypaV2') {
$DataBase.supaMemoryType = 'hypaV2' $DataBase.supaModelType = 'hypaV2'
$DataBase.memoryAlgorithmType = 'hypaMemoryV2'
$DataBase.hypav2= true $DataBase.hypav2= true
$DataBase.hanuraiEnable = false $DataBase.hanuraiEnable = false
} else { } else {
$DataBase.supaMemoryType = 'none' $DataBase.supaModelType = 'none'
$DataBase.memoryAlgorithmType = 'none'
$DataBase.hypav2 = false $DataBase.hypav2 = false
$DataBase.hanuraiEnable = false $DataBase.hanuraiEnable = false
} }
@@ -316,12 +320,12 @@
{:else if $DataBase.hypav2} {:else if $DataBase.hypav2}
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.hypaV2Desc}</span> <span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.hypaV2Desc}</span>
<span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span> <span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span>
<SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaMemoryType}> <SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaModelType}>
<OptionInput value="distilbart">distilbart-cnn-6-6 (Free/Local)</OptionInput> <OptionInput value="distilbart">distilbart-cnn-6-6 (Free/Local)</OptionInput>
<OptionInput value="instruct35">OpenAI 3.5 Turbo Instruct</OptionInput> <OptionInput value="instruct35">OpenAI 3.5 Turbo Instruct</OptionInput>
<OptionInput value="subModel">{language.submodel}</OptionInput> <OptionInput value="subModel">{language.submodel}</OptionInput>
</SelectInput> </SelectInput>
{#if $DataBase.supaMemoryType === 'davinci' || $DataBase.supaMemoryType === 'curie' || $DataBase.supaMemoryType === 'instruct35'} {#if $DataBase.supaModelType === 'davinci' || $DataBase.supaModelType === 'curie' || $DataBase.supaModelType === 'instruct35'}
<span class="text-textcolor">{language.SuperMemory} OpenAI Key</span> <span class="text-textcolor">{language.SuperMemory} OpenAI Key</span>
<TextInput size="sm" marginBottom bind:value={$DataBase.supaMemoryKey}/> <TextInput size="sm" marginBottom bind:value={$DataBase.supaMemoryKey}/>
{/if} {/if}
@@ -337,21 +341,21 @@
<NumberInput size="sm" marginBottom bind:value={$DataBase.hypaChunkSize} min={100} /> <NumberInput size="sm" marginBottom bind:value={$DataBase.hypaChunkSize} min={100} />
<span class="text-textcolor">{language.hypaAllocatedTokens}</span> <span class="text-textcolor">{language.hypaAllocatedTokens}</span>
<NumberInput size="sm" marginBottom bind:value={$DataBase.hypaAllocatedTokens} min={100} /> <NumberInput size="sm" marginBottom bind:value={$DataBase.hypaAllocatedTokens} min={100} />
{:else if ($DataBase.supaMemoryType !== 'none' && $DataBase.hypav2 === false)} {:else if ($DataBase.supaModelType !== 'none' && $DataBase.hypav2 === false)}
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.supaDesc}</span> <span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.supaDesc}</span>
<span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span> <span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span>
<SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaMemoryType}> <SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaModelType}>
<OptionInput value="distilbart" >distilbart-cnn-6-6 (Free/Local)</OptionInput> <OptionInput value="distilbart" >distilbart-cnn-6-6 (Free/Local)</OptionInput>
<OptionInput value="instruct35" >OpenAI 3.5 Turbo Instruct</OptionInput> <OptionInput value="instruct35" >OpenAI 3.5 Turbo Instruct</OptionInput>
<OptionInput value="subModel" >{language.submodel}</OptionInput> <OptionInput value="subModel" >{language.submodel}</OptionInput>
</SelectInput> </SelectInput>
<span class="text-textcolor">{language.maxSupaChunkSize}</span> <span class="text-textcolor">{language.maxSupaChunkSize}</span>
<NumberInput size="sm" marginBottom bind:value={$DataBase.maxSupaChunkSize} min={100} /> <NumberInput size="sm" marginBottom bind:value={$DataBase.maxSupaChunkSize} min={100} />
{#if $DataBase.supaMemoryType === 'davinci' || $DataBase.supaMemoryType === 'curie' || $DataBase.supaMemoryType === 'instruct35'} {#if $DataBase.supaModelType === 'davinci' || $DataBase.supaModelType === 'curie' || $DataBase.supaModelType === 'instruct35'}
<span class="text-textcolor">{language.SuperMemory} OpenAI Key</span> <span class="text-textcolor">{language.SuperMemory} OpenAI Key</span>
<TextInput size="sm" marginBottom bind:value={$DataBase.supaMemoryKey}/> <TextInput size="sm" marginBottom bind:value={$DataBase.supaMemoryKey}/>
{/if} {/if}
{#if $DataBase.supaMemoryType !== 'none'} {#if $DataBase.supaModelType !== 'none'}
<span class="text-textcolor">{language.SuperMemory} Prompt</span> <span class="text-textcolor">{language.SuperMemory} Prompt</span>
<TextInput size="sm" marginBottom bind:value={$DataBase.supaMemoryPrompt} placeholder="Leave it blank to use default"/> <TextInput size="sm" marginBottom bind:value={$DataBase.supaMemoryPrompt} placeholder="Leave it blank to use default"/>
{/if} {/if}

View File

@@ -257,7 +257,7 @@
{/each} {/each}
{#if $DataBase.supaMemoryType !== 'none' || $DataBase.hanuraiEnable} {#if $DataBase.supaModelType !== 'none' || $DataBase.hanuraiEnable}
{#if $DataBase.hanuraiEnable} {#if $DataBase.hanuraiEnable}
<div class="flex mt-2 items-center"> <div class="flex mt-2 items-center">
<Check bind:check={currentChar.data.supaMemory} name={ language.hanuraiMemory}/> <Check bind:check={currentChar.data.supaMemory} name={ language.hanuraiMemory}/>
@@ -904,12 +904,12 @@
<span> <Help key="utilityBot" name={language.utilityBot}/></span> <span> <Help key="utilityBot" name={language.utilityBot}/></span>
</div> </div>
{#if $DataBase.supaMemoryType !== 'none' && $DataBase.hypav2} {#if $DataBase.supaModelType !== 'none' && $DataBase.hypav2}
<Button <Button
on:click={() => { on:click={() => {
currentChar.data.chats[currentChar.data.chatPage].hypaV2Data ??= { currentChar.data.chats[currentChar.data.chatPage].hypaV2Data ??= {
chunks: [], chunks: [],
mainChunks: [] mainChunks: []
} }
showHypaV2Alert() showHypaV2Alert()
}} }}

View File

@@ -165,7 +165,7 @@
</div> </div>
{/each} {/each}
{#if $DataBase.supaMemoryType !== 'none' || $DataBase.hanuraiEnable} {#if $DataBase.supaModelType !== 'none' || $DataBase.hanuraiEnable}
{#if $DataBase.hanuraiEnable} {#if $DataBase.hanuraiEnable}
<div class="flex mt-2 items-center"> <div class="flex mt-2 items-center">
<CheckInput bind:check={chara.supaMemory} name={ language.hanuraiMemory}/> <CheckInput bind:check={chara.supaMemory} name={ language.hanuraiMemory}/>

View File

@@ -714,7 +714,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
currentTokens += await tokenizer.tokenizeChat(chat) currentTokens += await tokenizer.tokenizeChat(chat)
} }
if(nowChatroom.supaMemory && (db.supaMemoryType !== 'none' || db.hanuraiEnable)){ if(nowChatroom.supaMemory && (db.supaModelType !== 'none' || db.hanuraiEnable)){
chatProcessStage.set(2) chatProcessStage.set(2)
if(db.hanuraiEnable){ if(db.hanuraiEnable){
const hn = await hanuraiMemory(chats, { const hn = await hanuraiMemory(chats, {
@@ -730,7 +730,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
chats = hn.chats chats = hn.chats
currentTokens = hn.tokens currentTokens = hn.tokens
} }
else if(db.supaMemoryType !== 'none' && db.hypav2){ //HypaV2 support needs to be changed like this. else if(db.hypav2){ //HypaV2 support needs to be changed like this.
const sp = await hypaMemoryV2(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer) const sp = await hypaMemoryV2(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer)
if(sp.error){ if(sp.error){
alertError(sp.error) alertError(sp.error)

View File

@@ -26,7 +26,7 @@ async function summary(stringlizedChat: string): Promise<{ success: boolean; dat
* @param {string} stringlizedChat - The chat to be summarized, represented as a string. * @param {string} stringlizedChat - The chat to be summarized, represented as a string.
* @return {Promise<{ success: boolean; data: string }>} A promise that resolves to an object containing the success status and the generated summary. * @return {Promise<{ success: boolean; data: string }>} A promise that resolves to an object containing the success status and the generated summary.
*/ */
if (db.supaMemoryType === 'distilbart') { if (db.supaModelType === 'distilbart') {
try { try {
const sum = await runSummarizer(stringlizedChat); const sum = await runSummarizer(stringlizedChat);
return { success: true, data: sum }; return { success: true, data: sum };
@@ -43,7 +43,7 @@ async function summary(stringlizedChat: string): Promise<{ success: boolean; dat
: db.supaMemoryPrompt; : db.supaMemoryPrompt;
let result = ''; let result = '';
if (db.supaMemoryType !== 'subModel') { if (db.supaModelType !== 'subModel') {
const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:"; const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:";
const da = await globalFetch("https://api.openai.com/v1/completions", { const da = await globalFetch("https://api.openai.com/v1/completions", {
headers: { headers: {
@@ -52,8 +52,8 @@ async function summary(stringlizedChat: string): Promise<{ success: boolean; dat
}, },
method: "POST", method: "POST",
body: { body: {
"model": db.supaMemoryType === 'curie' ? "text-curie-001" "model": db.supaModelType === 'curie' ? "text-curie-001"
: db.supaMemoryType === 'instruct35' ? 'gpt-3.5-turbo-instruct' : db.supaModelType === 'instruct35' ? 'gpt-3.5-turbo-instruct'
: "text-davinci-003", : "text-davinci-003",
"prompt": promptbody, "prompt": promptbody,
"max_tokens": 600, "max_tokens": 600,
@@ -220,7 +220,7 @@ export async function hypaMemoryV2(
await processor.addText(data.chunks.filter(v => { await processor.addText(data.chunks.filter(v => {
return v.text.trim().length > 0; return v.text.trim().length > 0;
}).map((v) => { }).map((v) => {
return "search_document: " + v.text.trim();hy return "search_document: " + v.text.trim();
})); }));
let scoredResults: { [key: string]: number } = {}; let scoredResults: { [key: string]: number } = {};

View File

@@ -183,7 +183,7 @@ export async function supaMemory(
async function summarize(stringlizedChat:string){ async function summarize(stringlizedChat:string){
if(db.supaMemoryType === 'distilbart'){ if(db.supaModelType === 'distilbart'){
try { try {
const sum = await runSummarizer(stringlizedChat) const sum = await runSummarizer(stringlizedChat)
return sum return sum
@@ -204,7 +204,7 @@ export async function supaMemory(
let result = '' let result = ''
if(db.supaMemoryType !== 'subModel'){ if(db.supaModelType !== 'subModel'){
const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:" const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:"
const da = await globalFetch("https://api.openai.com/v1/completions",{ const da = await globalFetch("https://api.openai.com/v1/completions",{
@@ -214,8 +214,8 @@ export async function supaMemory(
}, },
method: "POST", method: "POST",
body: { body: {
"model": db.supaMemoryType === 'curie' ? "text-curie-001" "model": db.supaModelType === 'curie' ? "text-curie-001"
: db.supaMemoryType === 'instruct35' ? 'gpt-3.5-turbo-instruct' : db.supaModelType === 'instruct35' ? 'gpt-3.5-turbo-instruct'
: "text-davinci-003", : "text-davinci-003",
"prompt": promptbody, "prompt": promptbody,
"max_tokens": 600, "max_tokens": 600,

View File

@@ -230,8 +230,8 @@ export function setDatabase(data:Database){
if(checkNullish(data.supaMemoryKey)){ if(checkNullish(data.supaMemoryKey)){
data.supaMemoryKey = "" data.supaMemoryKey = ""
} }
if(checkNullish(data.supaMemoryType)){ if(checkNullish(data.supaModelType)){
data.supaMemoryType = "none" data.supaModelType = "none"
} }
if(checkNullish(data.askRemoval)){ if(checkNullish(data.askRemoval)){
data.askRemoval = true data.askRemoval = true
@@ -526,7 +526,7 @@ export interface Database{
useStreaming:boolean useStreaming:boolean
palmAPI:string, palmAPI:string,
supaMemoryKey:string supaMemoryKey:string
supaMemoryType:string supaModelType:string
textScreenColor?:string textScreenColor?:string
textBorder?:boolean textBorder?:boolean
textScreenRounded?:boolean textScreenRounded?:boolean
@@ -568,7 +568,8 @@ export interface Database{
useAdditionalAssetsPreview:boolean, useAdditionalAssetsPreview:boolean,
usePlainFetch:boolean usePlainFetch:boolean
hypaMemory:boolean hypaMemory:boolean
hypav2:boolean // Why this is not appended? hypav2:boolean
memoryAlgorithmType:string // To enable new memory module/algorithms
proxyRequestModel:string proxyRequestModel:string
ooba:OobaSettings ooba:OobaSettings
ainconfig: AINsettings ainconfig: AINsettings