Elffuss BraidHub

kikocis/lancedb public

main · 1.7 KiBRenderedRawPermalink
1# LanceDB JavaScript SDK
2
3A JavaScript library for [LanceDB](https://github.com/lancedb/lancedb).
4
5## Installation
6
7```bash
8npm install @lancedb/lancedb
9```
10
11This will download the appropriate native library for your platform. We currently
12support:
13
14- Linux (x86_64 and aarch64)
15- MacOS (Intel and ARM/M1/M2)
16- Windows (x86_64 only)
17
18We do not yet support musl-based Linux (such as Alpine Linux) or aarch64 Windows.
19
20## Usage
21
22### Basic Example
23
24```javascript
25import * as lancedb from "@lancedb/lancedb";
26const db = await lancedb.connect("data/sample-lancedb");
27const table = await db.createTable("my_table", [
28 { id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
29 { id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 },
30]);
31const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
32console.log(results);
33```
34
35The [quickstart](../basic.md) contains a more complete example.
36
37## Development
38
39```sh
40npm run build
41npm run test
42```
43
44### Running lint / format
45
46LanceDb uses [biome](https://biomejs.dev/) for linting and formatting. if you are using VSCode you will need to install the official [Biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) extension.
47To manually lint your code you can run:
48
49```sh
50npm run lint
51```
52
53to automatically fix all fixable issues:
54
55```sh
56npm run lint-fix
57```
58
59If you do not have your workspace root set to the `nodejs` directory, unfortunately the extension will not work. You can still run the linting and formatting commands manually.
60
61### Generating docs
62
63```sh
64npm run docs
65
66cd ../docs
67# Asssume the virtual environment was created
68# python3 -m venv venv
69# pip install -r requirements.txt
70. ./venv/bin/activate
71mkdocs build
72```