fix: add custom embedding model name as suffix to hypaVector storage keys
- Add custom embedding model name as suffix to hypaVector storage keys when using custom embedding models to prevent vector dimension mismatch errors.
This commit is contained in:
@@ -133,9 +133,11 @@ export class HypaProcesser{
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addText(texts:string[]) {
|
async addText(texts:string[]) {
|
||||||
|
const db = getDatabase()
|
||||||
|
const suffix = (this.model === 'custom' && db.hypaCustomSettings.model) ? `-${db.hypaCustomSettings.model}` : ""
|
||||||
|
|
||||||
for(let i=0;i<texts.length;i++){
|
for(let i=0;i<texts.length;i++){
|
||||||
const itm:memoryVector = await this.forage.getItem(texts[i] + '|' + this.model)
|
const itm:memoryVector = await this.forage.getItem(texts[i] + '|' + this.model + suffix)
|
||||||
if(itm){
|
if(itm){
|
||||||
itm.alreadySaved = true
|
itm.alreadySaved = true
|
||||||
this.vectors.push(itm)
|
this.vectors.push(itm)
|
||||||
@@ -164,7 +166,7 @@ export class HypaProcesser{
|
|||||||
for(let i=0;i<memoryVectors.length;i++){
|
for(let i=0;i<memoryVectors.length;i++){
|
||||||
const vec = memoryVectors[i]
|
const vec = memoryVectors[i]
|
||||||
if(!vec.alreadySaved){
|
if(!vec.alreadySaved){
|
||||||
await this.forage.setItem(texts[i] + '|' + this.model, vec)
|
await this.forage.setItem(texts[i] + '|' + this.model + suffix, vec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user