0.0.2 • Published 1 year ago

@polymath-ai/db v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Lightweight vector store for Poylmath.

To use:

import { VectorStore } from "@polymath-ai/db";

// A directory where the database will reside.
// The store will create the directory and populate it with two files:
// - `database.db` -- the duckdb database that stores useful metadata.
// - `vector.idx` -- the hnswlib index that stores the vector index.
const path = "/path/to/store";
// The number of dimensions in the vector.
const dimensions = 1536;
const store = new VectorStore(path, dimensions);

To write bits into it:

const bits = ["array", "of", "bits"];
const writer = await store.createWriter();
await writer.write(bits);

To query:

const query = []; // the vector as an array of numbers
const resultCount = 5; // number of results to return
const reader = await store.createReader();
const results = await reader.search(query, resultCount);