Solved hypav2 not implemented as expected
The github isn't updating codebase correctly!!!
This commit is contained in:
@@ -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 === 'hypaV2'}
|
{#if $DataBase.supaMemoryType !== '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()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -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 === 'hypaV2'){
|
else if(db.supaMemoryType !== 'none' && 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)
|
||||||
|
|||||||
@@ -18,9 +18,14 @@ export interface HypaV2Data {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function summarize(stringlizedChat: string): Promise<{ success: boolean; data: string }> {
|
async function summary(stringlizedChat: string): Promise<{ success: boolean; data: string }> {
|
||||||
const db = get(DataBase);
|
const db = get(DataBase);
|
||||||
|
/**
|
||||||
|
* Generates a summary of a given chat by using either the OpenAI API or a submodel or distilbart summarizer.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
if (db.supaMemoryType === 'distilbart') {
|
if (db.supaMemoryType === 'distilbart') {
|
||||||
try {
|
try {
|
||||||
const sum = await runSummarizer(stringlizedChat);
|
const sum = await runSummarizer(stringlizedChat);
|
||||||
@@ -36,12 +41,10 @@ async function summarize(stringlizedChat: string): Promise<{ success: boolean; d
|
|||||||
const supaPrompt = db.supaMemoryPrompt === '' ?
|
const supaPrompt = db.supaMemoryPrompt === '' ?
|
||||||
"[Summarize the ongoing role story, It must also remove redundancy and unnecessary text and content from the output to reduce tokens for gpt3 and other sublanguage models]\n"
|
"[Summarize the ongoing role story, It must also remove redundancy and unnecessary text and content from the output to reduce tokens for gpt3 and other sublanguage models]\n"
|
||||||
: db.supaMemoryPrompt;
|
: db.supaMemoryPrompt;
|
||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
|
|
||||||
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 globalFetch("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",
|
||||||
@@ -57,6 +60,7 @@ async function summarize(stringlizedChat: string): Promise<{ success: boolean; d
|
|||||||
"temperature": 0
|
"temperature": 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log("Using openAI instruct 3.5 for SupaMemory")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!da.ok) {
|
if (!da.ok) {
|
||||||
@@ -93,6 +97,7 @@ async function summarize(stringlizedChat: string): Promise<{ success: boolean; d
|
|||||||
content: supaPrompt
|
content: supaPrompt
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
console.log("Using submodel: ", db.subModel, "for supaMemory model")
|
||||||
const da = await requestChatData({
|
const da = await requestChatData({
|
||||||
formated: promptbody,
|
formated: promptbody,
|
||||||
bias: {},
|
bias: {},
|
||||||
@@ -171,7 +176,7 @@ export async function hypaMemoryV2(
|
|||||||
|
|
||||||
const stringlizedChat = halfData.map(e => `${e.role}: ${e.content}`).join('\n');
|
const stringlizedChat = halfData.map(e => `${e.role}: ${e.content}`).join('\n');
|
||||||
|
|
||||||
const summaryData = await summarize(stringlizedChat);
|
const summaryData = await summary(stringlizedChat);
|
||||||
|
|
||||||
if (!summaryData.success) {
|
if (!summaryData.success) {
|
||||||
return {
|
return {
|
||||||
@@ -192,7 +197,7 @@ export async function hypaMemoryV2(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (allocatedTokens < 1500) {
|
if (allocatedTokens < 1500) {
|
||||||
const summarizedMp = await summarize(mainPrompt);
|
const summarizedMp = await summary(mainPrompt);
|
||||||
const mpToken = await tokenizer.tokenizeChat({ role: 'system', content: mainPrompt });
|
const mpToken = await tokenizer.tokenizeChat({ role: 'system', content: mainPrompt });
|
||||||
const summaryToken = await tokenizer.tokenizeChat({ role: 'system', content: summarizedMp.data });
|
const summaryToken = await tokenizer.tokenizeChat({ role: 'system', content: summarizedMp.data });
|
||||||
|
|
||||||
@@ -215,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();
|
return "search_document: " + v.text.trim();hy
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let scoredResults: { [key: string]: number } = {};
|
let scoredResults: { [key: string]: number } = {};
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ export interface Database{
|
|||||||
useAdditionalAssetsPreview:boolean,
|
useAdditionalAssetsPreview:boolean,
|
||||||
usePlainFetch:boolean
|
usePlainFetch:boolean
|
||||||
hypaMemory:boolean
|
hypaMemory:boolean
|
||||||
hypav2:boolean
|
hypav2:boolean // Why this is not appended?
|
||||||
proxyRequestModel:string
|
proxyRequestModel:string
|
||||||
ooba:OobaSettings
|
ooba:OobaSettings
|
||||||
ainconfig: AINsettings
|
ainconfig: AINsettings
|
||||||
|
|||||||
Reference in New Issue
Block a user