Web-optimized vector database (written in Rust).
npm install victor-db
```ts import { Db } from "victor";
const db = await Db.new();
const content = "My content!"; const tags = ["these", "are", "tags"]; const embedding = new Float64Array(/* your embedding here */);
// write to victor await db.insert(content, embedding, tags);
// read from victor const result = await db.search(embedding, ["tags"]); assert(result == content);
// clear database await db.clear(); ```
See www/
for a more complete example, including fetching embeddings from OpenAI.
Victor is written in Rust, and compiled to wasm with wasm-pack.
Install wasm pack with cargo install wasm-pack
or npm i -g wasm-pack
(https://rustwasm.github.io/wasm-pack/installer/)
Build Victor with wasm-pack build
Set up the example project, which is in www/
.
If you use nvm, you can just run cd www/ && nvm use
Then, npm i
.
From www/
, start the example project with npm run start
.
Relevant code at src/packed_vector.rs
.