diff --git a/README.md b/README.md index c2af493..f94e09c 100644 --- a/README.md +++ b/README.md @@ -31,16 +31,16 @@ Insert vectors ```nim import std/json -let embedding1 = @[1, 1, 1]; -let embedding2 = @[1, 1, 2]; -let embedding3 = @[2, 2, 2]; +let embedding1 = @[1, 1, 1] +let embedding2 = @[1, 1, 2] +let embedding3 = @[2, 2, 2] db.exec(sql"INSERT INTO items (embedding) VALUES (?), (?), (?)", %* embedding1, %* embedding2, %* embedding3) ``` Get the nearest neighbors ```nim -let embedding = @[1, 1, 1]; +let embedding = @[1, 1, 1] let rows = db.getAllRows(sql"SELECT * FROM items ORDER BY embedding <-> ? LIMIT 5", %* embedding) for row in rows: echo row diff --git a/example.nim b/example.nim index de6469c..2911afb 100644 --- a/example.nim +++ b/example.nim @@ -8,12 +8,12 @@ db.exec(sql"DROP TABLE IF EXISTS items") db.exec(sql"CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))") -let embedding1 = @[1, 1, 1]; -let embedding2 = @[1, 1, 2]; -let embedding3 = @[2, 2, 2]; +let embedding1 = @[1, 1, 1] +let embedding2 = @[1, 1, 2] +let embedding3 = @[2, 2, 2] db.exec(sql"INSERT INTO items (embedding) VALUES (?), (?), (?)", %* embedding1, %* embedding2, %* embedding3) -let embedding = @[1, 1, 1]; +let embedding = @[1, 1, 1] let rows = db.getAllRows(sql"SELECT * FROM items ORDER BY embedding <-> ? LIMIT 5", %* embedding) for row in rows: echo row[0], ": ", parseJson(row[1])