[feat] added hypamemory toggle
This commit is contained in:
@@ -75,4 +75,9 @@
|
|||||||
{#if $DataBase.supaMemoryType !== 'none'}
|
{#if $DataBase.supaMemoryType !== 'none'}
|
||||||
<span class="text-neutral-200">{language.SuperMemory} Prompt</span>
|
<span class="text-neutral-200">{language.SuperMemory} Prompt</span>
|
||||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm"bind:value={$DataBase.supaMemoryPrompt} placeholder="recommended to leave it blank to use default">
|
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm"bind:value={$DataBase.supaMemoryPrompt} placeholder="recommended to leave it blank to use default">
|
||||||
|
{/if}
|
||||||
|
{#if ($DataBase.supaMemoryType === 'davinci' || $DataBase.supaMemoryType === 'curie') && $DataBase.useExperimental}
|
||||||
|
<div class="flex">
|
||||||
|
<Check bind:check={$DataBase.hypaMemory} name='Able HypaMemory'/> <Help key="experimental" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -296,7 +296,9 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(nowChatroom.supaMemory && db.supaMemoryType !== 'none'){
|
if(nowChatroom.supaMemory && db.supaMemoryType !== 'none'){
|
||||||
const sp = await supaMemory(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer)
|
const sp = await supaMemory(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer, {
|
||||||
|
asHyper: db.hypaMemory
|
||||||
|
})
|
||||||
if(sp.error){
|
if(sp.error){
|
||||||
alertError(sp.error)
|
alertError(sp.error)
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { requestChatData } from "../request";
|
|||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { HypaProcesser } from "./hypamemory";
|
import { HypaProcesser } from "./hypamemory";
|
||||||
import { stringlizeChat } from "../stringlize";
|
import { stringlizeChat } from "../stringlize";
|
||||||
|
import { globalFetch } from "src/ts/storage/globalApi";
|
||||||
|
|
||||||
export async function supaMemory(
|
export async function supaMemory(
|
||||||
chats:OpenAIChat[],
|
chats:OpenAIChat[],
|
||||||
@@ -154,28 +155,21 @@ export async function supaMemory(
|
|||||||
if(db.supaMemoryType !== 'subModel'){
|
if(db.supaMemoryType !== 'subModel'){
|
||||||
const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:"
|
const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:"
|
||||||
|
|
||||||
const da = await fetch("https://api.openai.com/v1/completions",{
|
const da = await globalFetch("https://api.openai.com/v1/completions",{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": "Bearer " + db.supaMemoryKey
|
"Authorization": "Bearer " + db.supaMemoryKey
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: {
|
||||||
"model": db.supaMemoryType === 'curie' ? "text-curie-001" : "text-davinci-003",
|
"model": db.supaMemoryType === 'curie' ? "text-curie-001" : "text-davinci-003",
|
||||||
"prompt": promptbody,
|
"prompt": promptbody,
|
||||||
"max_tokens": 600,
|
"max_tokens": 600,
|
||||||
"temperature": 0
|
"temperature": 0
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if(da.status < 200 || da.status >= 300){
|
result = (await da.data).choices[0].text.trim()
|
||||||
return {
|
|
||||||
currentTokens: currentTokens,
|
|
||||||
chats: chats,
|
|
||||||
error: "SupaMemory: HTTP: " + await da.text()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = (await da.json()).choices[0].text.trim()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const promptbody:OpenAIChat[] = [
|
const promptbody:OpenAIChat[] = [
|
||||||
|
|||||||
@@ -529,6 +529,7 @@ export interface Database{
|
|||||||
useChatSticker:boolean,
|
useChatSticker:boolean,
|
||||||
useAdditionalAssetsPreview:boolean,
|
useAdditionalAssetsPreview:boolean,
|
||||||
usePlainFetch:boolean
|
usePlainFetch:boolean
|
||||||
|
hypaMemory:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface hordeConfig{
|
interface hordeConfig{
|
||||||
|
|||||||
Reference in New Issue
Block a user