mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
examples + fmt
This commit is contained in:
parent
356f75cca7
commit
dd972f6ffe
16 changed files with 1064 additions and 25 deletions
|
|
@ -6,7 +6,7 @@ sqliteVec.load(db);
|
|||
|
||||
const { sqlite_version, vec_version } = db
|
||||
.prepare(
|
||||
"select sqlite_version() as sqlite_version, vec_version() as vec_version;"
|
||||
"select sqlite_version() as sqlite_version, vec_version() as vec_version;",
|
||||
)
|
||||
.get();
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ const query = [0.3, 0.3, 0.3, 0.3];
|
|||
db.exec("CREATE VIRTUAL TABLE vec_items USING vec0(embedding float[4])");
|
||||
|
||||
const insertStmt = db.prepare(
|
||||
"INSERT INTO vec_items(rowid, embedding) VALUES (?, ?)"
|
||||
"INSERT INTO vec_items(rowid, embedding) VALUES (?, ?)",
|
||||
);
|
||||
|
||||
const insertVectors = db.transaction((items) => {
|
||||
|
|
@ -45,7 +45,7 @@ const rows = db
|
|||
WHERE embedding MATCH ?
|
||||
ORDER BY distance
|
||||
LIMIT 3
|
||||
`
|
||||
`,
|
||||
)
|
||||
.all(new Float32Array(query));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue