Skip to content

Commit cbc7069

Browse files
feat(community): replace vectordb package with new @lancedb/lancedb (#7202)
Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
1 parent 074d1e1 commit cbc7069

7 files changed

Lines changed: 70 additions & 75 deletions

File tree

docs/core_docs/docs/integrations/vectorstores/lancedb.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ LanceDB datasets are persisted to disk and can be shared between Node.js and Pyt
1212

1313
## Setup
1414

15-
Install the [LanceDB](https://github.com/lancedb/lancedb) [Node.js bindings](https://www.npmjs.com/package/vectordb):
15+
Install the [LanceDB](https://github.com/lancedb/lancedb) [Node.js bindings](https://www.npmjs.com/package/@lancedb/lancedb):
1616

1717
```bash npm2yarn
18-
npm install -S vectordb
18+
npm install -S @lancedb/lancedb
1919
```
2020

2121
import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@getzep/zep-js": "^0.9.0",
3434
"@gomomento/sdk": "^1.51.1",
3535
"@google/generative-ai": "^0.7.0",
36+
"@lancedb/lancedb": "^0.13.0",
3637
"@langchain/anthropic": "workspace:*",
3738
"@langchain/aws": "workspace:*",
3839
"@langchain/azure-cosmosdb": "workspace:*",
@@ -102,7 +103,6 @@
102103
"typeorm": "^0.3.20",
103104
"typesense": "^1.5.3",
104105
"uuid": "^10.0.0",
105-
"vectordb": "^0.9.0",
106106
"voy-search": "0.6.2",
107107
"weaviate-ts-client": "^2.0.0",
108108
"zod": "^3.22.4",

examples/src/indexes/vector_stores/lancedb/load.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LanceDB } from "@langchain/community/vectorstores/lancedb";
22
import { OpenAIEmbeddings } from "@langchain/openai";
3-
import { connect } from "vectordb";
3+
import { connect } from "@lancedb/lancedb";
44
import * as fs from "node:fs/promises";
55
import * as path from "node:path";
66
import os from "node:os";

libs/langchain-community/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"@huggingface/inference": "^2.6.4",
8080
"@ibm-cloud/watsonx-ai": "^1.1.0",
8181
"@jest/globals": "^29.5.0",
82+
"@lancedb/lancedb": "^0.13.0",
8283
"@langchain/core": "workspace:*",
8384
"@langchain/scripts": ">=0.1.0 <0.2.0",
8485
"@langchain/standard-tests": "0.0.0",
@@ -210,7 +211,6 @@
210211
"typescript": "~5.1.6",
211212
"typesense": "^1.5.3",
212213
"usearch": "^1.1.1",
213-
"vectordb": "^0.9.0",
214214
"voy-search": "0.6.2",
215215
"weaviate-ts-client": "^1.4.0",
216216
"web-auth-library": "^1.0.3",
@@ -246,6 +246,7 @@
246246
"@gradientai/nodejs-sdk": "^1.2.0",
247247
"@huggingface/inference": "^2.6.4",
248248
"@ibm-cloud/watsonx-ai": "*",
249+
"@lancedb/lancedb": "^0.12.0",
249250
"@langchain/core": ">=0.2.21 <0.4.0",
250251
"@layerup/layerup-security": "^1.5.12",
251252
"@libsql/client": "^0.14.0",
@@ -334,7 +335,6 @@
334335
"typeorm": "^0.3.20",
335336
"typesense": "^1.5.3",
336337
"usearch": "^1.1.1",
337-
"vectordb": "^0.1.4",
338338
"voy-search": "0.6.2",
339339
"weaviate-ts-client": "*",
340340
"web-auth-library": "^1.0.3",
@@ -424,6 +424,9 @@
424424
"@huggingface/inference": {
425425
"optional": true
426426
},
427+
"@lancedb/lancedb": {
428+
"optional": true
429+
},
427430
"@layerup/layerup-security": {
428431
"optional": true
429432
},
@@ -682,9 +685,6 @@
682685
"usearch": {
683686
"optional": true
684687
},
685-
"vectordb": {
686-
"optional": true
687-
},
688688
"voy-search": {
689689
"optional": true
690690
},

libs/langchain-community/src/vectorstores/lancedb.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { connect, Table, Connection, WriteMode } from "vectordb";
1+
import { connect, Table, Connection } from "@lancedb/lancedb";
22
import type { EmbeddingsInterface } from "@langchain/core/embeddings";
33
import { VectorStore } from "@langchain/core/vectorstores";
44
import { Document } from "@langchain/core/documents";
@@ -12,7 +12,7 @@ export type LanceDBArgs = {
1212
textKey?: string;
1313
uri?: string;
1414
tableName?: string;
15-
mode?: WriteMode;
15+
mode?: "create" | "overwrite";
1616
};
1717

1818
/**
@@ -29,7 +29,7 @@ export class LanceDB extends VectorStore {
2929

3030
private tableName: string;
3131

32-
private mode?: WriteMode;
32+
private mode?: "create" | "overwrite";
3333

3434
constructor(embeddings: EmbeddingsInterface, args?: LanceDBArgs) {
3535
super(embeddings, args || {});
@@ -38,7 +38,7 @@ export class LanceDB extends VectorStore {
3838
this.textKey = args?.textKey || "text";
3939
this.uri = args?.uri || "~/lancedb";
4040
this.tableName = args?.tableName || "langchain";
41-
this.mode = args?.mode || WriteMode.Overwrite;
41+
this.mode = args?.mode || "overwrite";
4242
}
4343

4444
/**
@@ -86,7 +86,7 @@ export class LanceDB extends VectorStore {
8686
if (!this.table) {
8787
const db: Connection = await connect(this.uri);
8888
this.table = await db.createTable(this.tableName, data, {
89-
writeMode: this.mode,
89+
mode: this.mode,
9090
});
9191

9292
return;
@@ -110,7 +110,11 @@ export class LanceDB extends VectorStore {
110110
"Table not found. Please add vectors to the table first."
111111
);
112112
}
113-
const results = await this.table.search(query).limit(k).execute();
113+
const results = await this.table
114+
.query()
115+
.nearestTo(query)
116+
.limit(k)
117+
.toArray();
114118

115119
const docsAndScore: [Document, number][] = [];
116120
results.forEach((item) => {

libs/langchain-community/src/vectorstores/tests/lancedb.int.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, test } from "@jest/globals";
22
import * as fs from "node:fs/promises";
33
import * as path from "node:path";
44
import * as os from "node:os";
5-
import { connect, Table } from "vectordb";
5+
import { connect, Table } from "@lancedb/lancedb";
66

77
import { OpenAIEmbeddings } from "@langchain/openai";
88
import { Document } from "@langchain/core/documents";

yarn.lock

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11126,41 +11126,68 @@ __metadata:
1112611126
languageName: node
1112711127
linkType: hard
1112811128

11129-
"@lancedb/vectordb-darwin-arm64@npm:0.4.20":
11130-
version: 0.4.20
11131-
resolution: "@lancedb/vectordb-darwin-arm64@npm:0.4.20"
11129+
"@lancedb/lancedb-darwin-arm64@npm:0.13.0":
11130+
version: 0.13.0
11131+
resolution: "@lancedb/lancedb-darwin-arm64@npm:0.13.0"
1113211132
conditions: os=darwin & cpu=arm64
1113311133
languageName: node
1113411134
linkType: hard
1113511135

11136-
"@lancedb/vectordb-darwin-x64@npm:0.4.20":
11137-
version: 0.4.20
11138-
resolution: "@lancedb/vectordb-darwin-x64@npm:0.4.20"
11136+
"@lancedb/lancedb-darwin-x64@npm:0.13.0":
11137+
version: 0.13.0
11138+
resolution: "@lancedb/lancedb-darwin-x64@npm:0.13.0"
1113911139
conditions: os=darwin & cpu=x64
1114011140
languageName: node
1114111141
linkType: hard
1114211142

11143-
"@lancedb/vectordb-linux-arm64-gnu@npm:0.4.20":
11144-
version: 0.4.20
11145-
resolution: "@lancedb/vectordb-linux-arm64-gnu@npm:0.4.20"
11146-
conditions: os=linux & cpu=arm64
11143+
"@lancedb/lancedb-linux-arm64-gnu@npm:0.13.0":
11144+
version: 0.13.0
11145+
resolution: "@lancedb/lancedb-linux-arm64-gnu@npm:0.13.0"
11146+
conditions: os=linux & cpu=arm64 & libc=glibc
1114711147
languageName: node
1114811148
linkType: hard
1114911149

11150-
"@lancedb/vectordb-linux-x64-gnu@npm:0.4.20":
11151-
version: 0.4.20
11152-
resolution: "@lancedb/vectordb-linux-x64-gnu@npm:0.4.20"
11153-
conditions: os=linux & cpu=x64
11150+
"@lancedb/lancedb-linux-x64-gnu@npm:0.13.0":
11151+
version: 0.13.0
11152+
resolution: "@lancedb/lancedb-linux-x64-gnu@npm:0.13.0"
11153+
conditions: os=linux & cpu=x64 & libc=glibc
1115411154
languageName: node
1115511155
linkType: hard
1115611156

11157-
"@lancedb/vectordb-win32-x64-msvc@npm:0.4.20":
11158-
version: 0.4.20
11159-
resolution: "@lancedb/vectordb-win32-x64-msvc@npm:0.4.20"
11157+
"@lancedb/lancedb-win32-x64-msvc@npm:0.13.0":
11158+
version: 0.13.0
11159+
resolution: "@lancedb/lancedb-win32-x64-msvc@npm:0.13.0"
1116011160
conditions: os=win32 & cpu=x64
1116111161
languageName: node
1116211162
linkType: hard
1116311163

11164+
"@lancedb/lancedb@npm:^0.13.0":
11165+
version: 0.13.0
11166+
resolution: "@lancedb/lancedb@npm:0.13.0"
11167+
dependencies:
11168+
"@lancedb/lancedb-darwin-arm64": 0.13.0
11169+
"@lancedb/lancedb-darwin-x64": 0.13.0
11170+
"@lancedb/lancedb-linux-arm64-gnu": 0.13.0
11171+
"@lancedb/lancedb-linux-x64-gnu": 0.13.0
11172+
"@lancedb/lancedb-win32-x64-msvc": 0.13.0
11173+
reflect-metadata: ^0.2.2
11174+
peerDependencies:
11175+
apache-arrow: ">=13.0.0 <=17.0.0"
11176+
dependenciesMeta:
11177+
"@lancedb/lancedb-darwin-arm64":
11178+
optional: true
11179+
"@lancedb/lancedb-darwin-x64":
11180+
optional: true
11181+
"@lancedb/lancedb-linux-arm64-gnu":
11182+
optional: true
11183+
"@lancedb/lancedb-linux-x64-gnu":
11184+
optional: true
11185+
"@lancedb/lancedb-win32-x64-msvc":
11186+
optional: true
11187+
conditions: (os=darwin | os=linux | os=win32) & (cpu=x64 | cpu=arm64)
11188+
languageName: node
11189+
linkType: hard
11190+
1116411191
"@langchain/anthropic@*, @langchain/anthropic@workspace:*, @langchain/anthropic@workspace:libs/langchain-anthropic":
1116511192
version: 0.0.0-use.local
1116611193
resolution: "@langchain/anthropic@workspace:libs/langchain-anthropic"
@@ -11490,6 +11517,7 @@ __metadata:
1149011517
"@huggingface/inference": ^2.6.4
1149111518
"@ibm-cloud/watsonx-ai": ^1.1.0
1149211519
"@jest/globals": ^29.5.0
11520+
"@lancedb/lancedb": ^0.13.0
1149311521
"@langchain/core": "workspace:*"
1149411522
"@langchain/openai": ">=0.2.0 <0.4.0"
1149511523
"@langchain/scripts": ">=0.1.0 <0.2.0"
@@ -11629,7 +11657,6 @@ __metadata:
1162911657
typesense: ^1.5.3
1163011658
usearch: ^1.1.1
1163111659
uuid: ^10.0.0
11632-
vectordb: ^0.9.0
1163311660
voy-search: 0.6.2
1163411661
weaviate-ts-client: ^1.4.0
1163511662
web-auth-library: ^1.0.3
@@ -11666,6 +11693,7 @@ __metadata:
1166611693
"@gradientai/nodejs-sdk": ^1.2.0
1166711694
"@huggingface/inference": ^2.6.4
1166811695
"@ibm-cloud/watsonx-ai": "*"
11696+
"@lancedb/lancedb": ^0.12.0
1166911697
"@langchain/core": ">=0.2.21 <0.4.0"
1167011698
"@layerup/layerup-security": ^1.5.12
1167111699
"@libsql/client": ^0.14.0
@@ -11754,7 +11782,6 @@ __metadata:
1175411782
typeorm: ^0.3.20
1175511783
typesense: ^1.5.3
1175611784
usearch: ^1.1.1
11757-
vectordb: ^0.1.4
1175811785
voy-search: 0.6.2
1175911786
weaviate-ts-client: "*"
1176011787
web-auth-library: ^1.0.3
@@ -11816,6 +11843,8 @@ __metadata:
1181611843
optional: true
1181711844
"@huggingface/inference":
1181811845
optional: true
11846+
"@lancedb/lancedb":
11847+
optional: true
1181911848
"@layerup/layerup-security":
1182011849
optional: true
1182111850
"@libsql/client":
@@ -11988,8 +12017,6 @@ __metadata:
1198812017
optional: true
1198912018
usearch:
1199012019
optional: true
11991-
vectordb:
11992-
optional: true
1199312020
voy-search:
1199412021
optional: true
1199512022
weaviate-ts-client:
@@ -13234,13 +13261,6 @@ __metadata:
1323413261
languageName: node
1323513262
linkType: hard
1323613263

13237-
"@neon-rs/load@npm:^0.0.74":
13238-
version: 0.0.74
13239-
resolution: "@neon-rs/load@npm:0.0.74"
13240-
checksum: d26ec9b08cdf1a7c5aeefe98f77112d205d11b4005a7934b21fe8fd27528847e08e4749e7e6c3fc05ae9f701175a58c11a095ae6af449634df3991a2c82e1dfa
13241-
languageName: node
13242-
linkType: hard
13243-
1324413264
"@neondatabase/serverless@npm:0.6.0":
1324513265
version: 0.6.0
1324613266
resolution: "@neondatabase/serverless@npm:0.6.0"
@@ -27373,6 +27393,7 @@ __metadata:
2737327393
"@getzep/zep-js": ^0.9.0
2737427394
"@gomomento/sdk": ^1.51.1
2737527395
"@google/generative-ai": ^0.7.0
27396+
"@lancedb/lancedb": ^0.13.0
2737627397
"@langchain/anthropic": "workspace:*"
2737727398
"@langchain/aws": "workspace:*"
2737827399
"@langchain/azure-cosmosdb": "workspace:*"
@@ -27457,7 +27478,6 @@ __metadata:
2745727478
typescript: ~5.1.6
2745827479
typesense: ^1.5.3
2745927480
uuid: ^10.0.0
27460-
vectordb: ^0.9.0
2746127481
voy-search: 0.6.2
2746227482
weaviate-ts-client: ^2.0.0
2746327483
zod: ^3.22.4
@@ -38701,7 +38721,7 @@ __metadata:
3870138721
languageName: node
3870238722
linkType: hard
3870338723

38704-
"reflect-metadata@npm:^0.2.1":
38724+
"reflect-metadata@npm:^0.2.1, reflect-metadata@npm:^0.2.2":
3870538725
version: 0.2.2
3870638726
resolution: "reflect-metadata@npm:0.2.2"
3870738727
checksum: a66c7b583e4efdd8f3c3124fbff33da2d0c86d8280617516308b32b2159af7a3698c961db3246387f56f6316b1d33a608f39bb2b49d813316dfc58f6d3bf3210
@@ -43229,35 +43249,6 @@ __metadata:
4322943249
languageName: node
4323043250
linkType: hard
4323143251

43232-
"vectordb@npm:^0.9.0":
43233-
version: 0.9.0
43234-
resolution: "vectordb@npm:0.9.0"
43235-
dependencies:
43236-
"@lancedb/vectordb-darwin-arm64": 0.4.20
43237-
"@lancedb/vectordb-darwin-x64": 0.4.20
43238-
"@lancedb/vectordb-linux-arm64-gnu": 0.4.20
43239-
"@lancedb/vectordb-linux-x64-gnu": 0.4.20
43240-
"@lancedb/vectordb-win32-x64-msvc": 0.4.20
43241-
"@neon-rs/load": ^0.0.74
43242-
axios: ^1.4.0
43243-
peerDependencies:
43244-
"@apache-arrow/ts": ^14.0.2
43245-
apache-arrow: ^14.0.2
43246-
dependenciesMeta:
43247-
"@lancedb/vectordb-darwin-arm64":
43248-
optional: true
43249-
"@lancedb/vectordb-darwin-x64":
43250-
optional: true
43251-
"@lancedb/vectordb-linux-arm64-gnu":
43252-
optional: true
43253-
"@lancedb/vectordb-linux-x64-gnu":
43254-
optional: true
43255-
"@lancedb/vectordb-win32-x64-msvc":
43256-
optional: true
43257-
conditions: (os=darwin | os=linux | os=win32) & (cpu=x64 | cpu=arm64)
43258-
languageName: node
43259-
linkType: hard
43260-
4326143252
"vfile-location@npm:^3.0.0, vfile-location@npm:^3.2.0":
4326243253
version: 3.2.0
4326343254
resolution: "vfile-location@npm:3.2.0"

0 commit comments

Comments
 (0)