Enha (RAG): raw text as primary key in vector db

This commit is contained in:
Grail Finder
2025-01-07 11:11:44 +03:00
parent b822b3a161
commit 7bbedd93cf
9 changed files with 21 additions and 23 deletions

View File

@@ -68,7 +68,6 @@ func (p ProviderSQL) WriteVector(row *models.VectorRow) error {
}
err = stmt.Exec()
if err != nil {
p.logger.Error("failed exec a stmt", "error", err)
return err
}
return nil
@@ -85,7 +84,6 @@ func (p ProviderSQL) SearchClosest(q []float32) ([]models.VectorRow, error) {
}
stmt, _, err := p.s3Conn.Prepare(
fmt.Sprintf(`SELECT
id,
distance,
embedding,
slug,
@@ -109,12 +107,11 @@ func (p ProviderSQL) SearchClosest(q []float32) ([]models.VectorRow, error) {
resp := []models.VectorRow{}
for stmt.Step() {
res := models.VectorRow{}
res.ID = uint32(stmt.ColumnInt64(0))
res.Distance = float32(stmt.ColumnFloat(1))
emb := stmt.ColumnRawText(2)
res.Distance = float32(stmt.ColumnFloat(0))
emb := stmt.ColumnRawText(1)
res.Embeddings = decodeUnsafe(emb)
res.Slug = stmt.ColumnText(3)
res.RawText = stmt.ColumnText(4)
res.Slug = stmt.ColumnText(2)
res.RawText = stmt.ColumnText(3)
resp = append(resp, res)
}
if err := stmt.Err(); err != nil {