[fix] hypamemory vector saving fix
This commit is contained in:
@@ -38,7 +38,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadTokenize(chara){
|
async function loadTokenize(chara){
|
||||||
console.log('tokenize')
|
|
||||||
const cha = chara
|
const cha = chara
|
||||||
if(cha.type !== 'group'){
|
if(cha.type !== 'group'){
|
||||||
if(lasttokens.desc !== cha.desc){
|
if(lasttokens.desc !== cha.desc){
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export class HypaProcesser{
|
|||||||
this.forage = localforage.createInstance({
|
this.forage = localforage.createInstance({
|
||||||
name: "hypaVector"
|
name: "hypaVector"
|
||||||
})
|
})
|
||||||
|
this.vectors = []
|
||||||
}
|
}
|
||||||
|
|
||||||
async embedDocuments(texts: string[]): Promise<number[][]> {
|
async embedDocuments(texts: string[]): Promise<number[][]> {
|
||||||
@@ -69,7 +70,7 @@ export class HypaProcesser{
|
|||||||
}
|
}
|
||||||
|
|
||||||
texts = texts.filter((v) => {
|
texts = texts.filter((v) => {
|
||||||
for(let i=0;i<vectors.length;i++){
|
for(let i=0;i<this.vectors.length;i++){
|
||||||
if(this.vectors[i].content === v){
|
if(this.vectors[i].content === v){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -100,6 +101,7 @@ export class HypaProcesser{
|
|||||||
async similaritySearch(query: string) {
|
async similaritySearch(query: string) {
|
||||||
const results = await this.similaritySearchVectorWithScore((await this.getEmbeds(query))[0],);
|
const results = await this.similaritySearchVectorWithScore((await this.getEmbeds(query))[0],);
|
||||||
|
|
||||||
|
console.log(results)
|
||||||
return results.map((result) => result[0]);
|
return results.map((result) => result[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,10 +205,12 @@ export async function supaMemory(
|
|||||||
const hypa = new HypaProcesser()
|
const hypa = new HypaProcesser()
|
||||||
hypa.oaikey = db.supaMemoryKey
|
hypa.oaikey = db.supaMemoryKey
|
||||||
hypa.vectors = []
|
hypa.vectors = []
|
||||||
await hypa.addText(hypaChunks)
|
await hypa.addText(hypaChunks.filter((value, index, self) => {
|
||||||
|
return self.indexOf(value) === index;
|
||||||
|
}))
|
||||||
const filteredChat = chats.filter((r) => r.role !== 'system' && r.role !== 'function')
|
const filteredChat = chats.filter((r) => r.role !== 'system' && r.role !== 'function')
|
||||||
const s = await hypa.similaritySearch(stringlizeChat(filteredChat.slice(0, 4)))
|
const s = await hypa.similaritySearch(stringlizeChat(filteredChat.slice(0, 4)))
|
||||||
hypaResult = s.slice(0,3).join("\n\n")
|
hypaResult = "past events: " + s.slice(0,3).join("\n")
|
||||||
currentTokens += await tokenizer.tokenizeChat({
|
currentTokens += await tokenizer.tokenizeChat({
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
content: hypaResult
|
content: hypaResult
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export let appVer = '1.29.2'
|
|||||||
export let webAppSubVer = ''
|
export let webAppSubVer = ''
|
||||||
|
|
||||||
export function setDatabase(data:Database){
|
export function setDatabase(data:Database){
|
||||||
console.log(data)
|
|
||||||
if(checkNullish(data.characters)){
|
if(checkNullish(data.characters)){
|
||||||
data.characters = []
|
data.characters = []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user