mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-23 05:19:58 +00:00
Compare commits
504 Commits
docs_march
...
python-v0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe89a373a2 | ||
|
|
3d3915edef | ||
|
|
e2e8b6aee4 | ||
|
|
12dbca5248 | ||
|
|
a6babfa651 | ||
|
|
75ede86fab | ||
|
|
becd649130 | ||
|
|
9d2fb7d602 | ||
|
|
fdb5d6fdf1 | ||
|
|
2f13fa225f | ||
|
|
e933de003d | ||
|
|
05fd387425 | ||
|
|
82a1da554c | ||
|
|
a7c0d80b9e | ||
|
|
71323a064a | ||
|
|
df48454b70 | ||
|
|
6603414885 | ||
|
|
c256f6c502 | ||
|
|
cc03f90379 | ||
|
|
975da09b02 | ||
|
|
c32e17b497 | ||
|
|
0528abdf97 | ||
|
|
1090c311e8 | ||
|
|
e767cbb374 | ||
|
|
3d7c48feca | ||
|
|
08d62550bb | ||
|
|
b272408b05 | ||
|
|
46ffa87cd4 | ||
|
|
cd9fc37b95 | ||
|
|
431f94e564 | ||
|
|
c1a7d65473 | ||
|
|
1e5ccb1614 | ||
|
|
2e7ab373dc | ||
|
|
c7fbc4aaee | ||
|
|
7e023c1ef2 | ||
|
|
1d0dd9a8b8 | ||
|
|
deb947ddbd | ||
|
|
b039765d50 | ||
|
|
d155e82723 | ||
|
|
5d8c91256c | ||
|
|
44c03ebef3 | ||
|
|
8ea06fe7f3 | ||
|
|
cf06b653d4 | ||
|
|
09cfab6d00 | ||
|
|
e4945abb1a | ||
|
|
a6aa67baed | ||
|
|
1d23af213b | ||
|
|
25dea4e859 | ||
|
|
8a1227030a | ||
|
|
9fee384d2c | ||
|
|
b2952acca7 | ||
|
|
2b132a0bef | ||
|
|
ba56208a34 | ||
|
|
2d2042d59e | ||
|
|
1c41a00d87 | ||
|
|
ac63d4066b | ||
|
|
be2074b90d | ||
|
|
6c452f29e9 | ||
|
|
8a7ded23b2 | ||
|
|
871500db70 | ||
|
|
a900bc0827 | ||
|
|
47cff963c5 | ||
|
|
e6ff3d848b | ||
|
|
44d799ebb8 | ||
|
|
1d3325dcc5 | ||
|
|
ff45f25cf2 | ||
|
|
a34cc770c5 | ||
|
|
f749b8808f | ||
|
|
7e5a54b76a | ||
|
|
3f14938392 | ||
|
|
3bd16e1b14 | ||
|
|
2f89fc26f1 | ||
|
|
e5bfec4318 | ||
|
|
e0f50013ea | ||
|
|
e4e64f9d6b | ||
|
|
6c9f4c4304 | ||
|
|
e21b56293c | ||
|
|
1b0aaf9ec3 | ||
|
|
01239da082 | ||
|
|
6060c0cd36 | ||
|
|
bb179981dd | ||
|
|
2e1f1c6d5d | ||
|
|
b916f5f132 | ||
|
|
f97c7dad8c | ||
|
|
ccf13f15d4 | ||
|
|
287c5ca2f9 | ||
|
|
479289dd38 | ||
|
|
1e41232f28 | ||
|
|
db2631c2ad | ||
|
|
473ef7e426 | ||
|
|
d32dc84653 | ||
|
|
1aaaeff511 | ||
|
|
bdd07a5dfa | ||
|
|
63db51c90d | ||
|
|
0838e12b30 | ||
|
|
968c62cb8f | ||
|
|
f6e9f8e3f4 | ||
|
|
4466cfa958 | ||
|
|
42fad84ec8 | ||
|
|
b36c750cc7 | ||
|
|
a23b856410 | ||
|
|
0fe0976a0e | ||
|
|
abde77eafb | ||
|
|
85a9ef472f | ||
|
|
4180b44472 | ||
|
|
2db257ca29 | ||
|
|
1f816d597a | ||
|
|
c1e3dc48af | ||
|
|
b9afc01cfd | ||
|
|
8bb983bc3d | ||
|
|
1ea0c33545 | ||
|
|
765569425c | ||
|
|
377832e532 | ||
|
|
723defbe7e | ||
|
|
c33110397e | ||
|
|
b6a522d483 | ||
|
|
9031ec6878 | ||
|
|
f0c5f5ba62 | ||
|
|
47daf9b7b0 | ||
|
|
f822255683 | ||
|
|
90af5cf028 | ||
|
|
fec6f92184 | ||
|
|
35bc4f3078 | ||
|
|
89ce417452 | ||
|
|
d4502add44 | ||
|
|
334857a8cb | ||
|
|
386d5da22f | ||
|
|
77ba97416d | ||
|
|
5120bf262b | ||
|
|
f27167017b | ||
|
|
73c69a6b9a | ||
|
|
05f9a77baf | ||
|
|
10089481c0 | ||
|
|
b5326d31e9 | ||
|
|
c60a193767 | ||
|
|
785ecfa037 | ||
|
|
8033a44d68 | ||
|
|
3bbcaba65b | ||
|
|
e60fde73ba | ||
|
|
a7dbe933dc | ||
|
|
4f34a01020 | ||
|
|
f9c244e608 | ||
|
|
7f9ef0d329 | ||
|
|
a3761f4209 | ||
|
|
4b40dad963 | ||
|
|
b32b69c993 | ||
|
|
4299f719ec | ||
|
|
accf31fa92 | ||
|
|
b8eb5d4bfe | ||
|
|
629c622d15 | ||
|
|
45b5b66c82 | ||
|
|
5896541bb8 | ||
|
|
e29e4cc36d | ||
|
|
f3de3d990d | ||
|
|
0a8e258247 | ||
|
|
2cec2a8937 | ||
|
|
464a36ad38 | ||
|
|
ad1e81a1d1 | ||
|
|
562d1af1ed | ||
|
|
2163502b31 | ||
|
|
c5b0934bfb | ||
|
|
ef54bd5ba2 | ||
|
|
80e4d14c02 | ||
|
|
fdabf31984 | ||
|
|
538d0320f7 | ||
|
|
cbc0c439ef | ||
|
|
69492586f0 | ||
|
|
f5627dac14 | ||
|
|
32bfb68ac3 | ||
|
|
bc871169f0 | ||
|
|
3fc835e124 | ||
|
|
484a121866 | ||
|
|
bc850e6add | ||
|
|
26eec4bef4 | ||
|
|
f84a4855ca | ||
|
|
aecafa6479 | ||
|
|
efa846b6e5 | ||
|
|
cf3dbcf684 | ||
|
|
c425d3759d | ||
|
|
fded15c9fe | ||
|
|
e888cb5b48 | ||
|
|
9241f47f0e | ||
|
|
b014c24e66 | ||
|
|
68115f1369 | ||
|
|
f78fe721db | ||
|
|
510e8378bc | ||
|
|
1045af6c09 | ||
|
|
7afcfca10d | ||
|
|
88205aba64 | ||
|
|
da47938a43 | ||
|
|
03e705c14c | ||
|
|
a7e60a4c3f | ||
|
|
e12bdc78bb | ||
|
|
41ccb48160 | ||
|
|
069ad267bd | ||
|
|
138fc3f66b | ||
|
|
2c3f982f4f | ||
|
|
d07817a562 | ||
|
|
39cc2fd62b | ||
|
|
0f00cd0097 | ||
|
|
84edf56995 | ||
|
|
b2efd0da53 | ||
|
|
c101e9deed | ||
|
|
a24e16f753 | ||
|
|
eb1f02919a | ||
|
|
c8f92c2987 | ||
|
|
9d115bd507 | ||
|
|
18f7bad3dd | ||
|
|
2e75b16403 | ||
|
|
3c544582f6 | ||
|
|
f602e07f99 | ||
|
|
4eb819072a | ||
|
|
bd2d187538 | ||
|
|
f308a0ffdb | ||
|
|
1f2eafca75 | ||
|
|
567c5f6d01 | ||
|
|
8e139012e2 | ||
|
|
d5be6c7a05 | ||
|
|
5a12224a02 | ||
|
|
a617ad35ff | ||
|
|
61bf688e5b | ||
|
|
a41f7be88d | ||
|
|
ecbbe185c7 | ||
|
|
b326bf2ef6 | ||
|
|
472344fcb3 | ||
|
|
bca80939c2 | ||
|
|
911d063237 | ||
|
|
12e776821a | ||
|
|
c6e5eb0398 | ||
|
|
1d0578ce25 | ||
|
|
e7fdb931de | ||
|
|
d811b89de2 | ||
|
|
545a03d7f9 | ||
|
|
f2e29eb004 | ||
|
|
36dbf47d60 | ||
|
|
fd2fd94862 | ||
|
|
faa5912c3f | ||
|
|
334e423464 | ||
|
|
7274c913a8 | ||
|
|
a192c1a9b1 | ||
|
|
cef0293985 | ||
|
|
0be4fd2aa6 | ||
|
|
0664eee38d | ||
|
|
f3dd5c89dc | ||
|
|
8b04d8fef6 | ||
|
|
68e2bb0b2d | ||
|
|
db4a979278 | ||
|
|
7d82e56f76 | ||
|
|
dfabbe9081 | ||
|
|
d1f9722bfb | ||
|
|
efcaa433fe | ||
|
|
7b8188bcd5 | ||
|
|
65c1d8bc4c | ||
|
|
5ecbf971e2 | ||
|
|
a78e07907c | ||
|
|
a409000c6f | ||
|
|
d8befeeea2 | ||
|
|
b699b5c42b | ||
|
|
49de13c65a | ||
|
|
97d033dfd6 | ||
|
|
0c580abd70 | ||
|
|
d19bf80375 | ||
|
|
5b2c602fb3 | ||
|
|
7bdca7a092 | ||
|
|
5f6d13e958 | ||
|
|
4243eaee93 | ||
|
|
e6bb907d81 | ||
|
|
4d5d748acd | ||
|
|
33ab68c790 | ||
|
|
dbc3515d96 | ||
|
|
ac3d95ec34 | ||
|
|
72b39432e8 | ||
|
|
340fd98b42 | ||
|
|
dc0b11a86a | ||
|
|
17dcb70076 | ||
|
|
8daed93a91 | ||
|
|
2f72d5138e | ||
|
|
f1aad1afc7 | ||
|
|
fa13fb9392 | ||
|
|
d39145c7e4 | ||
|
|
3463248eba | ||
|
|
3191966ffb | ||
|
|
3b119420b2 | ||
|
|
6f7cb75b07 | ||
|
|
118a11c9b3 | ||
|
|
70ca6d8ea5 | ||
|
|
556e01d9d9 | ||
|
|
1060dde858 | ||
|
|
950e05da81 | ||
|
|
2b7754f929 | ||
|
|
d0bff7b78e | ||
|
|
85f3f8793c | ||
|
|
a758876a65 | ||
|
|
073a2a1b28 | ||
|
|
195c106242 | ||
|
|
f0a654036e | ||
|
|
792830ccb5 | ||
|
|
162f8536d1 | ||
|
|
5d198327bb | ||
|
|
55cc3ed5a2 | ||
|
|
b11428dddb | ||
|
|
1387dc6e48 | ||
|
|
84c6c8f08c | ||
|
|
63e273606e | ||
|
|
35f83694be | ||
|
|
45b006d68c | ||
|
|
20208b9efb | ||
|
|
c00af75d63 | ||
|
|
21245dfb9d | ||
|
|
81487f10fe | ||
|
|
3aa233f38a | ||
|
|
3278fa75d1 | ||
|
|
549f2bf396 | ||
|
|
138760bc6e | ||
|
|
0bddf77a73 | ||
|
|
154dc508ba | ||
|
|
0b8fe76590 | ||
|
|
c22eacb8b6 | ||
|
|
75d575ef4e | ||
|
|
bc83bc9838 | ||
|
|
a76b5755ff | ||
|
|
9a192426d3 | ||
|
|
ab794ba237 | ||
|
|
81e9df57c0 | ||
|
|
8705784cea | ||
|
|
b3fbca4aee | ||
|
|
5948f11641 | ||
|
|
9efc3fa6d8 | ||
|
|
453bf113ae | ||
|
|
4b243c5ff8 | ||
|
|
4aa7f58a07 | ||
|
|
7581cbb38f | ||
|
|
881dfa022b | ||
|
|
f17d16f935 | ||
|
|
f3a905af63 | ||
|
|
a07c6c465a | ||
|
|
1dd663fc8a | ||
|
|
175ad9223b | ||
|
|
4c8690549a | ||
|
|
3100f0d861 | ||
|
|
c34aa09166 | ||
|
|
328aa2247b | ||
|
|
43662705ad | ||
|
|
8a48b32689 | ||
|
|
5bb128a24d | ||
|
|
6698376f02 | ||
|
|
94e81ff84b | ||
|
|
2fd829296e | ||
|
|
b4ae3f3097 | ||
|
|
a25d10279c | ||
|
|
5376970e87 | ||
|
|
e929491187 | ||
|
|
e3ba5b2402 | ||
|
|
25d1c62c3f | ||
|
|
cd791a366b | ||
|
|
24afea8c56 | ||
|
|
0d2dbf7d09 | ||
|
|
c629080d60 | ||
|
|
918a2a4405 | ||
|
|
56db257ea9 | ||
|
|
a63262cfda | ||
|
|
98af0ceec6 | ||
|
|
7778031b26 | ||
|
|
c97ae6b787 | ||
|
|
7bac1131fb | ||
|
|
a0afa84786 | ||
|
|
e74c203e6f | ||
|
|
46bf5a1ed1 | ||
|
|
4891a7ae14 | ||
|
|
d1f24ba1dd | ||
|
|
b56c54c990 | ||
|
|
3ab4b335c3 | ||
|
|
009297e900 | ||
|
|
3f3acb48c6 | ||
|
|
c3cda2c5d0 | ||
|
|
a975cc0a94 | ||
|
|
48a12e780c | ||
|
|
b60a2177ae | ||
|
|
cc9d74e7a7 | ||
|
|
3232b55218 | ||
|
|
ee2034db23 | ||
|
|
1dac34d2fa | ||
|
|
78b457f230 | ||
|
|
884ce655fe | ||
|
|
acbcbe6496 | ||
|
|
1d79e9168e | ||
|
|
f46931228b | ||
|
|
811e604077 | ||
|
|
072be50cb3 | ||
|
|
aca1b43d5e | ||
|
|
0b9c8ef88a | ||
|
|
eb62ddfb0c | ||
|
|
32515ace74 | ||
|
|
82946f3623 | ||
|
|
374a6f7e78 | ||
|
|
e52f691420 | ||
|
|
79aeb6bea6 | ||
|
|
7d70c9940c | ||
|
|
fc32f98c34 | ||
|
|
9356c3b86a | ||
|
|
b02370cacd | ||
|
|
e479acc1bd | ||
|
|
3413e79b0f | ||
|
|
91ff324c70 | ||
|
|
480a630e19 | ||
|
|
07e33c2b2d | ||
|
|
fb1de97e83 | ||
|
|
bda0135cfc | ||
|
|
287d85a3aa | ||
|
|
7b92e796bb | ||
|
|
608e502de6 | ||
|
|
328880f057 | ||
|
|
93ade53515 | ||
|
|
d74e188f80 | ||
|
|
59c25574f0 | ||
|
|
c1c3083b74 | ||
|
|
a94a033553 | ||
|
|
bbf34ae7f4 | ||
|
|
57dda15f49 | ||
|
|
8f82e4897c | ||
|
|
8bd77d3c72 | ||
|
|
0273df4e04 | ||
|
|
6d76fe80b8 | ||
|
|
78ab9068a8 | ||
|
|
088792c821 | ||
|
|
955c2a751a | ||
|
|
775bee576c | ||
|
|
f59af4df76 | ||
|
|
15cc5227c4 | ||
|
|
c008faddfd | ||
|
|
22fc0eaaf6 | ||
|
|
32cb1b9ea4 | ||
|
|
49a366bc74 | ||
|
|
d59dbf8230 | ||
|
|
c0a49a9a5b | ||
|
|
2f2964a645 | ||
|
|
3d50c9cdfe | ||
|
|
bdb3b46f7e | ||
|
|
49306a99ba | ||
|
|
86efd36689 | ||
|
|
20ab85171b | ||
|
|
159ecbac5a | ||
|
|
148f6d7283 | ||
|
|
c604912139 | ||
|
|
178af0c2b8 | ||
|
|
c1b037f0a5 | ||
|
|
3855bdf986 | ||
|
|
07ab4cd14c | ||
|
|
531c947fc1 | ||
|
|
4e9aab9e8b | ||
|
|
cd7a4dd251 | ||
|
|
3c139c2ee5 | ||
|
|
166b281d66 | ||
|
|
c9fee0faed | ||
|
|
301e08f30e | ||
|
|
b5e57ebce3 | ||
|
|
87364532bf | ||
|
|
c275ec006f | ||
|
|
53b0375e6d | ||
|
|
6881c50866 | ||
|
|
a174832d61 | ||
|
|
722cede32b | ||
|
|
4d086d63eb | ||
|
|
f5e9c073f0 | ||
|
|
178e016ff2 | ||
|
|
3c998b020f | ||
|
|
a3c955070e | ||
|
|
edeecd3d9f | ||
|
|
2861f33982 | ||
|
|
0036ca9de7 | ||
|
|
2826bc7f1a | ||
|
|
e37a0566e0 | ||
|
|
48999ffc27 | ||
|
|
0dc893993f | ||
|
|
12de39612e | ||
|
|
05509bfb03 | ||
|
|
fa702f992e | ||
|
|
7f707205de | ||
|
|
2394ff14d0 | ||
|
|
31334b05df | ||
|
|
942976f49f | ||
|
|
507f6087c2 | ||
|
|
39c1cb87ad | ||
|
|
6b0d1d6ec1 | ||
|
|
d38e3d496f | ||
|
|
f4ac47e1b5 | ||
|
|
c94e428252 | ||
|
|
a09389459c | ||
|
|
4f62fb5ae8 | ||
|
|
c14ccbd334 | ||
|
|
b10afbeedc | ||
|
|
8dc10180b0 | ||
|
|
377a564904 | ||
|
|
7b5bfadab2 | ||
|
|
1c42894918 | ||
|
|
2b341f3482 | ||
|
|
5027529663 | ||
|
|
3ed509f20c | ||
|
|
87c69e74fc | ||
|
|
0e9a7f0dc7 | ||
|
|
c07207c661 | ||
|
|
541b06664f | ||
|
|
8469d010f8 | ||
|
|
a737bbff19 |
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.4.14
|
||||
current_version = 0.4.19
|
||||
commit = True
|
||||
message = Bump version: {current_version} → {new_version}
|
||||
tag = True
|
||||
@@ -7,6 +7,16 @@ tag_name = v{new_version}
|
||||
|
||||
[bumpversion:file:node/package.json]
|
||||
|
||||
[bumpversion:file:nodejs/package.json]
|
||||
|
||||
[bumpversion:file:nodejs/npm/darwin-x64/package.json]
|
||||
|
||||
[bumpversion:file:nodejs/npm/darwin-arm64/package.json]
|
||||
|
||||
[bumpversion:file:nodejs/npm/linux-x64-gnu/package.json]
|
||||
|
||||
[bumpversion:file:nodejs/npm/linux-arm64-gnu/package.json]
|
||||
|
||||
[bumpversion:file:rust/ffi/node/Cargo.toml]
|
||||
|
||||
[bumpversion:file:rust/lancedb/Cargo.toml]
|
||||
|
||||
@@ -14,6 +14,10 @@ inputs:
|
||||
# Note: this does *not* mean the host is arm64, since we might be cross-compiling.
|
||||
required: false
|
||||
default: "false"
|
||||
manylinux:
|
||||
description: "The manylinux version to build for"
|
||||
required: false
|
||||
default: "2_17"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -28,7 +32,7 @@ runs:
|
||||
command: build
|
||||
working-directory: python
|
||||
target: x86_64-unknown-linux-gnu
|
||||
manylinux: "2_17"
|
||||
manylinux: ${{ inputs.manylinux }}
|
||||
args: ${{ inputs.args }}
|
||||
before-script-linux: |
|
||||
set -e
|
||||
@@ -43,7 +47,7 @@ runs:
|
||||
command: build
|
||||
working-directory: python
|
||||
target: aarch64-unknown-linux-gnu
|
||||
manylinux: "2_24"
|
||||
manylinux: ${{ inputs.manylinux }}
|
||||
args: ${{ inputs.args }}
|
||||
before-script-linux: |
|
||||
set -e
|
||||
|
||||
3
.github/workflows/cargo-publish.yml
vendored
3
.github/workflows/cargo-publish.yml
vendored
@@ -8,6 +8,9 @@ env:
|
||||
# This env var is used by Swatinem/rust-cache@v2 for the cache
|
||||
# key, so we set it to make sure it is always consistent.
|
||||
CARGO_TERM_COLOR: always
|
||||
# Up-to-date compilers needed for fp16kernels.
|
||||
CC: gcc-12
|
||||
CXX: g++-12
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
1
.github/workflows/node.yml
vendored
1
.github/workflows/node.yml
vendored
@@ -107,6 +107,7 @@ jobs:
|
||||
AWS_ENDPOINT: http://localhost:4566
|
||||
# this one is for dynamodb
|
||||
DYNAMODB_ENDPOINT: http://localhost:4566
|
||||
ALLOW_HTTP: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
9
.github/workflows/nodejs.yml
vendored
9
.github/workflows/nodejs.yml
vendored
@@ -28,6 +28,10 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: nodejs
|
||||
env:
|
||||
# Need up-to-date compilers for kernels
|
||||
CC: gcc-12
|
||||
CXX: g++-12
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -81,7 +85,12 @@ jobs:
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
- name: Setup localstack
|
||||
working-directory: .
|
||||
run: docker compose up --detach --wait
|
||||
- name: Test
|
||||
env:
|
||||
S3_TEST: "1"
|
||||
run: npm run test
|
||||
macos:
|
||||
timeout-minutes: 30
|
||||
|
||||
4
.github/workflows/npm-publish.yml
vendored
4
.github/workflows/npm-publish.yml
vendored
@@ -63,7 +63,7 @@ jobs:
|
||||
- name: Upload Darwin Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: node-native-darwin
|
||||
name: node-native-darwin-${{ matrix.config.arch }}
|
||||
path: |
|
||||
node/dist/lancedb-vectordb-darwin*.tgz
|
||||
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
- name: Upload Linux Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: node-native-linux
|
||||
name: node-native-linux-${{ matrix.config.arch }}
|
||||
path: |
|
||||
node/dist/lancedb-vectordb-linux*.tgz
|
||||
|
||||
|
||||
29
.github/workflows/pypi-publish.yml
vendored
29
.github/workflows/pypi-publish.yml
vendored
@@ -6,13 +6,25 @@ on:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
# Only runs on tags that matches the python-make-release action
|
||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||
name: Python ${{ matrix.config.platform }} manylinux${{ matrix.config.manylinux }}
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
matrix:
|
||||
python-minor-version: ["8"]
|
||||
platform:
|
||||
- x86_64
|
||||
- aarch64
|
||||
config:
|
||||
- platform: x86_64
|
||||
manylinux: "2_17"
|
||||
extra_args: ""
|
||||
- platform: x86_64
|
||||
manylinux: "2_28"
|
||||
extra_args: "--features fp16kernels"
|
||||
- platform: aarch64
|
||||
manylinux: "2_24"
|
||||
extra_args: ""
|
||||
# We don't build fp16 kernels for aarch64, because it uses
|
||||
# cross compilation image, which doesn't have a new enough compiler.
|
||||
runs-on: "ubuntu-22.04"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -26,13 +38,16 @@ jobs:
|
||||
- uses: ./.github/workflows/build_linux_wheel
|
||||
with:
|
||||
python-minor-version: ${{ matrix.python-minor-version }}
|
||||
args: "--release --strip"
|
||||
arm-build: ${{ matrix.platform == 'aarch64' }}
|
||||
args: "--release --strip ${{ matrix.config.extra_args }}"
|
||||
arm-build: ${{ matrix.config.platform == 'aarch64' }}
|
||||
manylinux: ${{ matrix.config.manylinux }}
|
||||
- uses: ./.github/workflows/upload_wheel
|
||||
with:
|
||||
token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }}
|
||||
repo: "pypi"
|
||||
mac:
|
||||
# Only runs on tags that matches the python-make-release action
|
||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||
timeout-minutes: 60
|
||||
runs-on: ${{ matrix.config.runner }}
|
||||
strategy:
|
||||
@@ -58,13 +73,15 @@ jobs:
|
||||
- uses: ./.github/workflows/build_mac_wheel
|
||||
with:
|
||||
python-minor-version: ${{ matrix.python-minor-version }}
|
||||
args: "--release --strip --target ${{ matrix.config.target }}"
|
||||
args: "--release --strip --target ${{ matrix.config.target }} --features fp16kernels"
|
||||
- uses: ./.github/workflows/upload_wheel
|
||||
with:
|
||||
python-minor-version: ${{ matrix.python-minor-version }}
|
||||
token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }}
|
||||
repo: "pypi"
|
||||
windows:
|
||||
# Only runs on tags that matches the python-make-release action
|
||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||
timeout-minutes: 60
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
|
||||
4
.github/workflows/python.yml
vendored
4
.github/workflows/python.yml
vendored
@@ -99,6 +99,8 @@ jobs:
|
||||
workspaces: python
|
||||
- uses: ./.github/workflows/build_linux_wheel
|
||||
- uses: ./.github/workflows/run_tests
|
||||
with:
|
||||
integration: true
|
||||
# Make sure wheels are not included in the Rust cache
|
||||
- name: Delete wheels
|
||||
run: rm -rf target/wheels
|
||||
@@ -190,4 +192,4 @@ jobs:
|
||||
pip install -e .[tests]
|
||||
pip install tantivy
|
||||
- name: Run tests
|
||||
run: pytest -m "not slow" -x -v --durations=30 python/tests
|
||||
run: pytest -m "not slow and not s3_test" -x -v --durations=30 python/tests
|
||||
|
||||
16
.github/workflows/run_tests/action.yml
vendored
16
.github/workflows/run_tests/action.yml
vendored
@@ -5,6 +5,10 @@ inputs:
|
||||
python-minor-version:
|
||||
required: true
|
||||
description: "8 9 10 11 12"
|
||||
integration:
|
||||
required: false
|
||||
description: "Run integration tests"
|
||||
default: "false"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -12,6 +16,16 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
pip3 install $(ls target/wheels/lancedb-*.whl)[tests,dev]
|
||||
- name: pytest
|
||||
- name: Setup localstack for integration tests
|
||||
if: ${{ inputs.integration == 'true' }}
|
||||
shell: bash
|
||||
working-directory: .
|
||||
run: docker compose up --detach --wait
|
||||
- name: pytest (with integration)
|
||||
shell: bash
|
||||
if: ${{ inputs.integration == 'true' }}
|
||||
run: pytest -m "not slow" -x -v --durations=30 python/python/tests
|
||||
- name: pytest (no integration tests)
|
||||
shell: bash
|
||||
if: ${{ inputs.integration != 'true' }}
|
||||
run: pytest -m "not slow and not s3_test" -x -v --durations=30 python/python/tests
|
||||
|
||||
14
.github/workflows/rust.yml
vendored
14
.github/workflows/rust.yml
vendored
@@ -31,6 +31,10 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: rust
|
||||
env:
|
||||
# Need up-to-date compilers for kernels
|
||||
CC: gcc-12
|
||||
CXX: g++-12
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -54,6 +58,10 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: rust
|
||||
env:
|
||||
# Need up-to-date compilers for kernels
|
||||
CC: gcc-12
|
||||
CXX: g++-12
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -68,6 +76,9 @@ jobs:
|
||||
sudo apt install -y protobuf-compiler libssl-dev
|
||||
- name: Build
|
||||
run: cargo build --all-features
|
||||
- name: Start S3 integration test environment
|
||||
working-directory: .
|
||||
run: docker compose up --detach --wait
|
||||
- name: Run tests
|
||||
run: cargo test --all-features
|
||||
- name: Run examples
|
||||
@@ -97,7 +108,8 @@ jobs:
|
||||
- name: Build
|
||||
run: cargo build --all-features
|
||||
- name: Run tests
|
||||
run: cargo test --all-features
|
||||
# Run with everything except the integration tests.
|
||||
run: cargo test --features remote,fp16kernels
|
||||
windows:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@
|
||||
venv
|
||||
|
||||
.vscode
|
||||
|
||||
.zed
|
||||
rust/target
|
||||
rust/Cargo.lock
|
||||
|
||||
|
||||
24
Cargo.toml
24
Cargo.toml
@@ -14,19 +14,19 @@ keywords = ["lancedb", "lance", "database", "vector", "search"]
|
||||
categories = ["database-implementations"]
|
||||
|
||||
[workspace.dependencies]
|
||||
lance = { "version" = "=0.10.5", "features" = ["dynamodb"] }
|
||||
lance-index = { "version" = "=0.10.5" }
|
||||
lance-linalg = { "version" = "=0.10.5" }
|
||||
lance-testing = { "version" = "=0.10.5" }
|
||||
lance = { "version" = "=0.10.16", "features" = ["dynamodb"] }
|
||||
lance-index = { "version" = "=0.10.16" }
|
||||
lance-linalg = { "version" = "=0.10.16" }
|
||||
lance-testing = { "version" = "=0.10.16" }
|
||||
# Note that this one does not include pyarrow
|
||||
arrow = { version = "50.0", optional = false }
|
||||
arrow-array = "50.0"
|
||||
arrow-data = "50.0"
|
||||
arrow-ipc = "50.0"
|
||||
arrow-ord = "50.0"
|
||||
arrow-schema = "50.0"
|
||||
arrow-arith = "50.0"
|
||||
arrow-cast = "50.0"
|
||||
arrow = { version = "51.0", optional = false }
|
||||
arrow-array = "51.0"
|
||||
arrow-data = "51.0"
|
||||
arrow-ipc = "51.0"
|
||||
arrow-ord = "51.0"
|
||||
arrow-schema = "51.0"
|
||||
arrow-arith = "51.0"
|
||||
arrow-cast = "51.0"
|
||||
async-trait = "0"
|
||||
chrono = "0.4.35"
|
||||
half = { "version" = "=2.3.1", default-features = false, features = [
|
||||
|
||||
10
README.md
10
README.md
@@ -1,13 +1,13 @@
|
||||
<div align="center">
|
||||
<p align="center">
|
||||
|
||||
<img width="275" alt="LanceDB Logo" src="https://user-images.githubusercontent.com/917119/226205734-6063d87a-1ecc-45fe-85be-1dea6383a3d8.png">
|
||||
<img width="275" alt="LanceDB Logo" src="https://github.com/lancedb/lancedb/assets/5846846/37d7c7ad-c2fd-4f56-9f16-fffb0d17c73a">
|
||||
|
||||
**Developer-friendly, serverless vector database for AI applications**
|
||||
**Developer-friendly, database for multimodal AI**
|
||||
|
||||
<a href='https://github.com/lancedb/vectordb-recipes/tree/main' target="_blank"><img alt='LanceDB' src='https://img.shields.io/badge/VectorDB_Recipes-100000?style=for-the-badge&logo=LanceDB&logoColor=white&labelColor=645cfb&color=645cfb'/></a>
|
||||
<a href='https://lancedb.github.io/lancedb/' target="_blank"><img alt='lancdb' src='https://img.shields.io/badge/DOCS-100000?style=for-the-badge&logo=lancdb&logoColor=white&labelColor=645cfb&color=645cfb'/></a>
|
||||
[](https://blog.lancedb.com/)
|
||||
[](https://blog.lancedb.com/)
|
||||
[](https://discord.gg/zMM32dvNtd)
|
||||
[](https://twitter.com/lancedb)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<hr />
|
||||
|
||||
LanceDB is an open-source database for vector-search built with persistent storage, which greatly simplifies retrevial, filtering and management of embeddings.
|
||||
LanceDB is an open-source database for vector-search built with persistent storage, which greatly simplifies retrieval, filtering and management of embeddings.
|
||||
|
||||
The key features of LanceDB include:
|
||||
|
||||
@@ -36,7 +36,7 @@ The key features of LanceDB include:
|
||||
|
||||
* GPU support in building vector index(*).
|
||||
|
||||
* Ecosystem integrations with [LangChain 🦜️🔗](https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lanecdb.html), [LlamaIndex 🦙](https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/LanceDBIndexDemo.html), Apache-Arrow, Pandas, Polars, DuckDB and more on the way.
|
||||
* Ecosystem integrations with [LangChain 🦜️🔗](https://python.langchain.com/docs/integrations/vectorstores/lancedb/), [LlamaIndex 🦙](https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/LanceDBIndexDemo.html), Apache-Arrow, Pandas, Polars, DuckDB and more on the way.
|
||||
|
||||
LanceDB's core is written in Rust 🦀 and is built using <a href="https://github.com/lancedb/lance">Lance</a>, an open-source columnar format designed for performant ML workloads.
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
localstack:
|
||||
image: localstack/localstack:0.14
|
||||
image: localstack/localstack:3.3
|
||||
ports:
|
||||
- 4566:4566
|
||||
environment:
|
||||
- SERVICES=s3,dynamodb
|
||||
- SERVICES=s3,dynamodb,kms
|
||||
- DEBUG=1
|
||||
- LS_LOG=trace
|
||||
- DOCKER_HOST=unix:///var/run/docker.sock
|
||||
- AWS_ACCESS_KEY_ID=ACCESSKEY
|
||||
- AWS_SECRET_ACCESS_KEY=SECRETKEY
|
||||
healthcheck:
|
||||
test: [ "CMD", "curl", "-f", "http://localhost:4566/health" ]
|
||||
test: [ "CMD", "curl", "-s", "http://localhost:4566/_localstack/health" ]
|
||||
interval: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
@@ -57,16 +57,6 @@ plugins:
|
||||
- https://arrow.apache.org/docs/objects.inv
|
||||
- https://pandas.pydata.org/docs/objects.inv
|
||||
- mkdocs-jupyter
|
||||
- ultralytics:
|
||||
verbose: True
|
||||
enabled: True
|
||||
default_image: "assets/lancedb_and_lance.png" # Default image for all pages
|
||||
add_image: True # Automatically add meta image
|
||||
add_keywords: True # Add page keywords in the header tag
|
||||
add_share_buttons: True # Add social share buttons
|
||||
add_authors: False # Display page authors
|
||||
add_desc: False
|
||||
add_dates: False
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
@@ -85,7 +75,7 @@ markdown_extensions:
|
||||
alternate_style: true
|
||||
- md_in_html
|
||||
- attr_list
|
||||
|
||||
|
||||
nav:
|
||||
- Home:
|
||||
- LanceDB: index.md
|
||||
@@ -128,9 +118,10 @@ nav:
|
||||
- Pandas and PyArrow: python/pandas_and_pyarrow.md
|
||||
- Polars: python/polars_arrow.md
|
||||
- DuckDB: python/duckdb.md
|
||||
- LangChain 🔗: https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html
|
||||
- LangChain JS/TS 🔗: https://js.langchain.com/docs/modules/data_connection/vectorstores/integrations/lancedb
|
||||
- LlamaIndex 🦙: https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/LanceDBIndexDemo.html
|
||||
- LangChain:
|
||||
- LangChain 🔗: https://python.langchain.com/docs/integrations/vectorstores/lancedb/
|
||||
- LangChain JS/TS 🔗: https://js.langchain.com/docs/integrations/vectorstores/lancedb
|
||||
- LlamaIndex 🦙: https://docs.llamaindex.ai/en/stable/examples/vector_stores/LanceDBIndexDemo/
|
||||
- Pydantic: python/pydantic.md
|
||||
- Voxel51: integrations/voxel51.md
|
||||
- PromptTools: integrations/prompttools.md
|
||||
@@ -151,11 +142,11 @@ nav:
|
||||
- TransformersJS Embedding Search: examples/transformerjs_embedding_search_nodejs.md
|
||||
- 🦀 Rust:
|
||||
- Overview: examples/examples_rust.md
|
||||
- 🔧 CLI & Config: cli_config.md
|
||||
- 💭 FAQs: faq.md
|
||||
- ⚙️ API reference:
|
||||
- 🐍 Python: python/python.md
|
||||
- 👾 JavaScript: javascript/modules.md
|
||||
- 👾 JavaScript (vectordb): javascript/modules.md
|
||||
- 👾 JavaScript (lancedb): javascript/modules.md
|
||||
- 🦀 Rust: https://docs.rs/lancedb/latest/lancedb/
|
||||
- ☁️ LanceDB Cloud:
|
||||
- Overview: cloud/index.md
|
||||
@@ -202,8 +193,8 @@ nav:
|
||||
- Pandas and PyArrow: python/pandas_and_pyarrow.md
|
||||
- Polars: python/polars_arrow.md
|
||||
- DuckDB: python/duckdb.md
|
||||
- LangChain 🦜️🔗↗: https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/lancedb.html
|
||||
- LangChain.js 🦜️🔗↗: https://js.langchain.com/docs/modules/data_connection/vectorstores/integrations/lancedb
|
||||
- LangChain 🦜️🔗↗: https://python.langchain.com/docs/integrations/vectorstores/lancedb
|
||||
- LangChain.js 🦜️🔗↗: https://js.langchain.com/docs/integrations/vectorstores/lancedb
|
||||
- LlamaIndex 🦙↗: https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/LanceDBIndexDemo.html
|
||||
- Pydantic: python/pydantic.md
|
||||
- Voxel51: integrations/voxel51.md
|
||||
@@ -221,7 +212,8 @@ nav:
|
||||
- API reference:
|
||||
- Overview: api_reference.md
|
||||
- Python: python/python.md
|
||||
- Javascript: javascript/modules.md
|
||||
- Javascript (vectordb): javascript/modules.md
|
||||
- Javascript (lancedb): js/modules.md
|
||||
- Rust: https://docs.rs/lancedb/latest/lancedb/index.html
|
||||
- LanceDB Cloud:
|
||||
- Overview: cloud/index.md
|
||||
@@ -239,4 +231,11 @@ extra_javascript:
|
||||
extra:
|
||||
analytics:
|
||||
provider: google
|
||||
property: G-B7NFM40W74
|
||||
property: G-B7NFM40W74
|
||||
social:
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/lancedb/lancedb
|
||||
- icon: fontawesome/brands/x-twitter
|
||||
link: https://twitter.com/lancedb
|
||||
- icon: fontawesome/brands/linkedin
|
||||
link: https://www.linkedin.com/company/lancedb
|
||||
|
||||
@@ -2,5 +2,4 @@ mkdocs==1.5.3
|
||||
mkdocs-jupyter==0.24.1
|
||||
mkdocs-material==9.5.3
|
||||
mkdocstrings[python]==0.20.0
|
||||
pydantic
|
||||
mkdocs-ultralytics-plugin==0.0.44
|
||||
pydantic
|
||||
@@ -3,5 +3,6 @@
|
||||
The API reference for the LanceDB client SDKs are available at the following locations:
|
||||
|
||||
- [Python](python/python.md)
|
||||
- [JavaScript](javascript/modules.md)
|
||||
- [JavaScript (legacy vectordb package)](javascript/modules.md)
|
||||
- [JavaScript (newer @lancedb/lancedb package)](js/modules.md)
|
||||
- [Rust](https://docs.rs/lancedb/latest/lancedb/index.html)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 54 KiB |
@@ -71,6 +71,16 @@
|
||||
--8<-- "docs/src/basic_legacy.ts:open_db"
|
||||
```
|
||||
|
||||
!!! note "`@lancedb/lancedb` vs. `vectordb`"
|
||||
|
||||
The Javascript SDK was originally released as `vectordb`. In an effort to
|
||||
reduce maintenance we are aligning our SDKs. The new, aligned, Javascript
|
||||
API is being released as `lancedb`. If you are starting new work we encourage
|
||||
you to try out `lancedb`. Once the new API is feature complete we will begin
|
||||
slowly deprecating `vectordb` in favor of `lancedb`. There is a
|
||||
[migration guide](migration.md) detailing the differences which will assist
|
||||
you in this process.
|
||||
|
||||
=== "Rust"
|
||||
|
||||
```rust
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
|
||||
# CLI & Config
|
||||
|
||||
## LanceDB CLI
|
||||
Once lanceDB is installed, you can access the CLI using `lancedb` command on the console.
|
||||
|
||||
```
|
||||
lancedb
|
||||
```
|
||||
|
||||
This lists out all the various command-line options available. You can get the usage or help for a particular command.
|
||||
|
||||
```
|
||||
lancedb {command} --help
|
||||
```
|
||||
|
||||
## LanceDB config
|
||||
LanceDB uses a global config file to store certain settings. These settings are configurable using the lanceDB cli.
|
||||
To view your config settings, you can use:
|
||||
|
||||
```
|
||||
lancedb config
|
||||
```
|
||||
|
||||
These config parameters can be tuned using the cli.
|
||||
|
||||
```
|
||||
lancedb {config_name} --{argument}
|
||||
```
|
||||
|
||||
## LanceDB Opt-in Diagnostics
|
||||
When enabled, LanceDB will send anonymous events to help us improve LanceDB. These diagnostics are used only for error reporting and no data is collected. Error & stats allow us to automate certain aspects of bug reporting, prioritization of fixes and feature requests.
|
||||
These diagnostics are opt-in and can be enabled or disabled using the `lancedb diagnostics` command. These are enabled by default.
|
||||
|
||||
### Get usage help
|
||||
|
||||
```
|
||||
lancedb diagnostics --help
|
||||
```
|
||||
|
||||
### Disable diagnostics
|
||||
|
||||
```
|
||||
lancedb diagnostics --disabled
|
||||
```
|
||||
|
||||
### Enable diagnostics
|
||||
|
||||
```
|
||||
lancedb diagnostics --enabled
|
||||
```
|
||||
@@ -154,9 +154,12 @@ Allows you to set parameters when registering a `sentence-transformers` object.
|
||||
!!! note "BAAI Embeddings example"
|
||||
Here is an example that uses BAAI embedding model from the HuggingFace Hub [supported models](https://huggingface.co/models?library=sentence-transformers)
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
db = lancedb.connect("/tmp/db")
|
||||
registry = EmbeddingFunctionRegistry.get_instance()
|
||||
model = registry.get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
|
||||
model = get_registry().get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
|
||||
|
||||
class Words(LanceModel):
|
||||
text: str = model.SourceField()
|
||||
@@ -165,7 +168,7 @@ Allows you to set parameters when registering a `sentence-transformers` object.
|
||||
table = db.create_table("words", schema=Words)
|
||||
table.add(
|
||||
[
|
||||
{"text": "hello world"}
|
||||
{"text": "hello world"},
|
||||
{"text": "goodbye world"}
|
||||
]
|
||||
)
|
||||
@@ -177,6 +180,32 @@ Allows you to set parameters when registering a `sentence-transformers` object.
|
||||
Visit sentence-transformers [HuggingFace HUB](https://huggingface.co/sentence-transformers) page for more information on the available models.
|
||||
|
||||
|
||||
### Huggingface embedding models
|
||||
We offer support for all huggingface models (which can be loaded via [transformers](https://huggingface.co/docs/transformers/en/index) library). The default model is `colbert-ir/colbertv2.0` which also has its own special callout - `registry.get("colbert")`
|
||||
|
||||
Example usage -
|
||||
```python
|
||||
import lancedb
|
||||
import pandas as pd
|
||||
|
||||
from lancedb.embeddings import get_registry
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
|
||||
model = get_registry().get("huggingface").create(name='facebook/bart-base')
|
||||
|
||||
class TextModel(LanceModel):
|
||||
text: str = model.SourceField()
|
||||
vector: Vector(model.ndims()) = model.VectorField()
|
||||
|
||||
df = pd.DataFrame({"text": ["hi hello sayonara", "goodbye world"]})
|
||||
table = db.create_table("greets", schema=Words)
|
||||
table.add()
|
||||
query = "old greeting"
|
||||
actual = table.search(query).limit(1).to_pydantic(Words)[0]
|
||||
print(actual.text)
|
||||
```
|
||||
|
||||
|
||||
### OpenAI embeddings
|
||||
LanceDB registers the OpenAI embeddings function in the registry by default, as `openai`. Below are the parameters that you can customize when creating the instances:
|
||||
|
||||
@@ -187,18 +216,21 @@ LanceDB registers the OpenAI embeddings function in the registry by default, as
|
||||
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
db = lancedb.connect("/tmp/db")
|
||||
registry = EmbeddingFunctionRegistry.get_instance()
|
||||
func = registry.get("openai").create()
|
||||
func = get_registry().get("openai").create(name="text-embedding-ada-002")
|
||||
|
||||
class Words(LanceModel):
|
||||
text: str = func.SourceField()
|
||||
vector: Vector(func.ndims()) = func.VectorField()
|
||||
|
||||
table = db.create_table("words", schema=Words)
|
||||
table = db.create_table("words", schema=Words, mode="overwrite")
|
||||
table.add(
|
||||
[
|
||||
{"text": "hello world"}
|
||||
{"text": "hello world"},
|
||||
{"text": "goodbye world"}
|
||||
]
|
||||
)
|
||||
@@ -327,6 +359,10 @@ Supported parameters (to be passed in `create` method) are:
|
||||
Usage Example:
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
model = get_registry().get("bedrock-text").create()
|
||||
|
||||
class TextModel(LanceModel):
|
||||
@@ -361,10 +397,12 @@ This embedding function supports ingesting images as both bytes and urls. You ca
|
||||
LanceDB supports ingesting images directly from accessible links.
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
db = lancedb.connect(tmp_path)
|
||||
registry = EmbeddingFunctionRegistry.get_instance()
|
||||
func = registry.get("open-clip").create()
|
||||
func = get_registry.get("open-clip").create()
|
||||
|
||||
class Images(LanceModel):
|
||||
label: str
|
||||
@@ -439,9 +477,12 @@ This function is registered as `imagebind` and supports Audio, Video and Text mo
|
||||
Below is an example demonstrating how the API works:
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
db = lancedb.connect(tmp_path)
|
||||
registry = EmbeddingFunctionRegistry.get_instance()
|
||||
func = registry.get("imagebind").create()
|
||||
func = get_registry.get("imagebind").create()
|
||||
|
||||
class ImageBindModel(LanceModel):
|
||||
text: str
|
||||
|
||||
@@ -46,7 +46,7 @@ For this purpose, LanceDB introduces an **embedding functions API**, that allow
|
||||
|
||||
```python
|
||||
class Pets(LanceModel):
|
||||
vector: Vector(clip.ndims) = clip.VectorField()
|
||||
vector: Vector(clip.ndims()) = clip.VectorField()
|
||||
image_uri: str = clip.SourceField()
|
||||
```
|
||||
|
||||
@@ -149,7 +149,7 @@ You can also use the integration for adding utility operations in the schema. Fo
|
||||
|
||||
```python
|
||||
class Pets(LanceModel):
|
||||
vector: Vector(clip.ndims) = clip.VectorField()
|
||||
vector: Vector(clip.ndims()) = clip.VectorField()
|
||||
image_uri: str = clip.SourceField()
|
||||
|
||||
@property
|
||||
@@ -166,4 +166,4 @@ rs[2].image
|
||||

|
||||
|
||||
Now that you have the basic idea about LanceDB embedding functions and the embedding function registry,
|
||||
let's dive deeper into defining your own [custom functions](./custom_embedding_function.md).
|
||||
let's dive deeper into defining your own [custom functions](./custom_embedding_function.md).
|
||||
|
||||
@@ -11,4 +11,64 @@ LanceDB supports 3 methods of working with embeddings.
|
||||
that extends the default embedding functions.
|
||||
|
||||
For python users, there is also a legacy [with_embeddings API](./legacy.md).
|
||||
It is retained for compatibility and will be removed in a future version.
|
||||
It is retained for compatibility and will be removed in a future version.
|
||||
|
||||
## Quickstart
|
||||
|
||||
To get started with embeddings, you can use the built-in embedding functions.
|
||||
|
||||
### OpenAI Embedding function
|
||||
LanceDB registers the OpenAI embeddings function in the registry as `openai`. You can pass any supported model name to the `create`. By default it uses `"text-embedding-ada-002"`.
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
db = lancedb.connect("/tmp/db")
|
||||
func = get_registry().get("openai").create(name="text-embedding-ada-002")
|
||||
|
||||
class Words(LanceModel):
|
||||
text: str = func.SourceField()
|
||||
vector: Vector(func.ndims()) = func.VectorField()
|
||||
|
||||
table = db.create_table("words", schema=Words, mode="overwrite")
|
||||
table.add(
|
||||
[
|
||||
{"text": "hello world"},
|
||||
{"text": "goodbye world"}
|
||||
]
|
||||
)
|
||||
|
||||
query = "greetings"
|
||||
actual = table.search(query).limit(1).to_pydantic(Words)[0]
|
||||
print(actual.text)
|
||||
```
|
||||
|
||||
### Sentence Transformers Embedding function
|
||||
LanceDB registers the Sentence Transformers embeddings function in the registry as `sentence-transformers`. You can pass any supported model name to the `create`. By default it uses `"sentence-transformers/paraphrase-MiniLM-L6-v2"`.
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
from lancedb.pydantic import LanceModel, Vector
|
||||
from lancedb.embeddings import get_registry
|
||||
|
||||
db = lancedb.connect("/tmp/db")
|
||||
model = get_registry().get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
|
||||
|
||||
class Words(LanceModel):
|
||||
text: str = model.SourceField()
|
||||
vector: Vector(model.ndims()) = model.VectorField()
|
||||
|
||||
table = db.create_table("words", schema=Words)
|
||||
table.add(
|
||||
[
|
||||
{"text": "hello world"},
|
||||
{"text": "goodbye world"}
|
||||
]
|
||||
)
|
||||
|
||||
query = "greetings"
|
||||
actual = table.search(query).limit(1).to_pydantic(Words)[0]
|
||||
print(actual.text)
|
||||
```
|
||||
@@ -55,18 +55,139 @@ LanceDB OSS supports object stores such as AWS S3 (and compatible stores), Azure
|
||||
const db = await lancedb.connect("az://bucket/path");
|
||||
```
|
||||
|
||||
In most cases, when running in the respective cloud and permissions are set up correctly, no additional configuration is required. When running outside of the respective cloud, authentication credentials must be provided using environment variables. In general, these environment variables are the same as those used by the respective cloud SDKs. The sections below describe the environment variables that can be used to configure each object store.
|
||||
In most cases, when running in the respective cloud and permissions are set up correctly, no additional configuration is required. When running outside of the respective cloud, authentication credentials must be provided. Credentials and other configuration options can be set in two ways: first, by setting environment variables. And second, by passing a `storage_options` object to the `connect` function. For example, to increase the request timeout to 60 seconds, you can set the `TIMEOUT` environment variable to `60s`:
|
||||
|
||||
LanceDB OSS uses the [object-store](https://docs.rs/object_store/latest/object_store/) Rust crate for object store access. There are general environment variables that can be used to configure the object store, such as the request timeout and proxy configuration. See the [object_store ClientConfigKey](https://docs.rs/object_store/latest/object_store/enum.ClientConfigKey.html) doc for available configuration options. The environment variables that can be set are the snake-cased versions of these variable names. For example, to set `ProxyUrl` use the environment variable `PROXY_URL`. (Don't let the Rust docs intimidate you! We link to them so you can see an up-to-date list of the available options.)
|
||||
```bash
|
||||
export TIMEOUT=60s
|
||||
```
|
||||
|
||||
!!! note "`storage_options` availability"
|
||||
|
||||
The `storage_options` parameter is only available in Python *async* API and JavaScript API.
|
||||
It is not yet supported in the Python synchronous API.
|
||||
|
||||
If you only want this to apply to one particular connection, you can pass the `storage_options` argument when opening the connection:
|
||||
|
||||
=== "Python"
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async(
|
||||
"s3://bucket/path",
|
||||
storage_options={"timeout": "60s"}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect("s3://bucket/path",
|
||||
{storageOptions: {timeout: "60s"}});
|
||||
```
|
||||
|
||||
Getting even more specific, you can set the `timeout` for only a particular table:
|
||||
|
||||
=== "Python"
|
||||
|
||||
<!-- skip-test -->
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async("s3://bucket/path")
|
||||
table = await db.create_table(
|
||||
"table",
|
||||
[{"a": 1, "b": 2}],
|
||||
storage_options={"timeout": "60s"}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
<!-- skip-test -->
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect("s3://bucket/path");
|
||||
const table = db.createTable(
|
||||
"table",
|
||||
[{ a: 1, b: 2}],
|
||||
{storageOptions: {timeout: "60s"}}
|
||||
);
|
||||
```
|
||||
|
||||
!!! info "Storage option casing"
|
||||
|
||||
The storage option keys are case-insensitive. So `connect_timeout` and `CONNECT_TIMEOUT` are the same setting. Usually lowercase is used in the `storage_options` argument and uppercase is used for environment variables. In the `lancedb` Node package, the keys can also be provided in `camelCase` capitalization. For example, `connectTimeout` is equivalent to `connect_timeout`.
|
||||
|
||||
### General configuration
|
||||
|
||||
There are several options that can be set for all object stores, mostly related to network client configuration.
|
||||
|
||||
<!-- from here: https://docs.rs/object_store/latest/object_store/enum.ClientConfigKey.html -->
|
||||
|
||||
| Key | Description |
|
||||
|----------------------------|--------------------------------------------------------------------------------------------------|
|
||||
| `allow_http` | Allow non-TLS, i.e. non-HTTPS connections. Default: `False`. |
|
||||
| `allow_invalid_certificates`| Skip certificate validation on HTTPS connections. Default: `False`. |
|
||||
| `connect_timeout` | Timeout for only the connect phase of a Client. Default: `5s`. |
|
||||
| `timeout` | Timeout for the entire request, from connection until the response body has finished. Default: `30s`. |
|
||||
| `user_agent` | User agent string to use in requests. |
|
||||
| `proxy_url` | URL of a proxy server to use for requests. Default: `None`. |
|
||||
| `proxy_ca_certificate` | PEM-formatted CA certificate for proxy connections. |
|
||||
| `proxy_excludes` | List of hosts that bypass the proxy. This is a comma-separated list of domains and IP masks. Any subdomain of the provided domain will be bypassed. For example, `example.com, 192.168.1.0/24` would bypass `https://api.example.com`, `https://www.example.com`, and any IP in the range `192.168.1.0/24`. |
|
||||
|
||||
|
||||
### AWS S3
|
||||
|
||||
To configure credentials for AWS S3, you can use the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` environment variables.
|
||||
To configure credentials for AWS S3, you can use the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` keys. Region can also be set, but it is not mandatory when using AWS.
|
||||
These can be set as environment variables or passed in the `storage_options` parameter:
|
||||
|
||||
=== "Python"
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async(
|
||||
"s3://bucket/path",
|
||||
storage_options={
|
||||
"aws_access_key_id": "my-access-key",
|
||||
"aws_secret_access_key": "my-secret-key",
|
||||
"aws_session_token": "my-session-token",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect(
|
||||
"s3://bucket/path",
|
||||
{
|
||||
storageOptions: {
|
||||
awsAccessKeyId: "my-access-key",
|
||||
awsSecretAccessKey: "my-secret-key",
|
||||
awsSessionToken: "my-session-token",
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
Alternatively, if you are using AWS SSO, you can use the `AWS_PROFILE` and `AWS_DEFAULT_REGION` environment variables.
|
||||
|
||||
You can see a full list of environment variables [here](https://docs.rs/object_store/latest/object_store/aws/struct.AmazonS3Builder.html#method.from_env).
|
||||
The following keys can be used as both environment variables or keys in the `storage_options` parameter:
|
||||
|
||||
| Key | Description |
|
||||
|------------------------------------|------------------------------------------------------------------------------------------------------|
|
||||
| `aws_region` / `region` | The AWS region the bucket is in. This can be automatically detected when using AWS S3, but must be specified for S3-compatible stores. |
|
||||
| `aws_access_key_id` / `access_key_id` | The AWS access key ID to use. |
|
||||
| `aws_secret_access_key` / `secret_access_key` | The AWS secret access key to use. |
|
||||
| `aws_session_token` / `session_token` | The AWS session token to use. |
|
||||
| `aws_endpoint` / `endpoint` | The endpoint to use for S3-compatible stores. |
|
||||
| `aws_virtual_hosted_style_request` / `virtual_hosted_style_request` | Whether to use virtual hosted-style requests, where the bucket name is part of the endpoint. Meant to be used with `aws_endpoint`. Default: `False`. |
|
||||
| `aws_s3_express` / `s3_express` | Whether to use S3 Express One Zone endpoints. Default: `False`. See more details below. |
|
||||
| `aws_server_side_encryption` | The server-side encryption algorithm to use. Must be one of `"AES256"`, `"aws:kms"`, or `"aws:kms:dsse"`. Default: `None`. |
|
||||
| `aws_sse_kms_key_id` | The KMS key ID to use for server-side encryption. If set, `aws_server_side_encryption` must be `"aws:kms"` or `"aws:kms:dsse"`. |
|
||||
| `aws_sse_bucket_key_enabled` | Whether to use bucket keys for server-side encryption. |
|
||||
|
||||
|
||||
!!! tip "Automatic cleanup for failed writes"
|
||||
|
||||
@@ -146,22 +267,182 @@ For **read-only access**, LanceDB will need a policy such as:
|
||||
|
||||
#### S3-compatible stores
|
||||
|
||||
LanceDB can also connect to S3-compatible stores, such as MinIO. To do so, you must specify two environment variables: `AWS_ENDPOINT` and `AWS_DEFAULT_REGION`. `AWS_ENDPOINT` should be the URL of the S3-compatible store, and `AWS_DEFAULT_REGION` should be the region to use.
|
||||
LanceDB can also connect to S3-compatible stores, such as MinIO. To do so, you must specify both region and endpoint:
|
||||
|
||||
=== "Python"
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async(
|
||||
"s3://bucket/path",
|
||||
storage_options={
|
||||
"region": "us-east-1",
|
||||
"endpoint": "http://minio:9000",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect(
|
||||
"s3://bucket/path",
|
||||
{
|
||||
storageOptions: {
|
||||
region: "us-east-1",
|
||||
endpoint: "http://minio:9000",
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
This can also be done with the ``AWS_ENDPOINT`` and ``AWS_DEFAULT_REGION`` environment variables.
|
||||
|
||||
!!! tip "Local servers"
|
||||
|
||||
For local development, the server often has a `http` endpoint rather than a
|
||||
secure `https` endpoint. In this case, you must also set the `ALLOW_HTTP`
|
||||
environment variable to `true` to allow non-TLS connections, or pass the
|
||||
storage option `allow_http` as `true`. If you do not do this, you will get
|
||||
an error like `URL scheme is not allowed`.
|
||||
|
||||
#### S3 Express
|
||||
|
||||
LanceDB supports [S3 Express One Zone](https://aws.amazon.com/s3/storage-classes/express-one-zone/) endpoints, but requires additional configuration. Also, S3 Express endpoints only support connecting from an EC2 instance within the same region.
|
||||
|
||||
To configure LanceDB to use an S3 Express endpoint, you must set the storage option `s3_express`. The bucket name in your table URI should **include the suffix**.
|
||||
|
||||
=== "Python"
|
||||
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async(
|
||||
"s3://my-bucket--use1-az4--x-s3/path",
|
||||
storage_options={
|
||||
"region": "us-east-1",
|
||||
"s3_express": "true",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect(
|
||||
"s3://my-bucket--use1-az4--x-s3/path",
|
||||
{
|
||||
storageOptions: {
|
||||
region: "us-east-1",
|
||||
s3Express: "true",
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
<!-- TODO: we should also document the use of S3 Express once we fully support it -->
|
||||
|
||||
### Google Cloud Storage
|
||||
|
||||
GCS credentials are configured by setting the `GOOGLE_SERVICE_ACCOUNT` environment variable to the path of a JSON file containing the service account credentials. There are several aliases for this environment variable, documented [here](https://docs.rs/object_store/latest/object_store/gcp/struct.GoogleCloudStorageBuilder.html#method.from_env).
|
||||
GCS credentials are configured by setting the `GOOGLE_SERVICE_ACCOUNT` environment variable to the path of a JSON file containing the service account credentials. Alternatively, you can pass the path to the JSON file in the `storage_options`:
|
||||
|
||||
=== "Python"
|
||||
|
||||
<!-- skip-test -->
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async(
|
||||
"gs://my-bucket/my-database",
|
||||
storage_options={
|
||||
"service_account": "path/to/service-account.json",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect(
|
||||
"gs://my-bucket/my-database",
|
||||
{
|
||||
storageOptions: {
|
||||
serviceAccount: "path/to/service-account.json",
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
!!! info "HTTP/2 support"
|
||||
|
||||
By default, GCS uses HTTP/1 for communication, as opposed to HTTP/2. This improves maximum throughput significantly. However, if you wish to use HTTP/2 for some reason, you can set the environment variable `HTTP1_ONLY` to `false`.
|
||||
|
||||
|
||||
The following keys can be used as both environment variables or keys in the `storage_options` parameter:
|
||||
<!-- source: https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html -->
|
||||
|
||||
| Key | Description |
|
||||
|---------------------------------------|----------------------------------------------|
|
||||
| ``google_service_account`` / `service_account` | Path to the service account JSON file. |
|
||||
| ``google_service_account_key`` | The serialized service account key. |
|
||||
| ``google_application_credentials`` | Path to the application credentials. |
|
||||
|
||||
|
||||
### Azure Blob Storage
|
||||
|
||||
Azure Blob Storage credentials can be configured by setting the `AZURE_STORAGE_ACCOUNT_NAME` and ``AZURE_STORAGE_ACCOUNT_KEY`` environment variables. The full list of environment variables that can be set are documented [here](https://docs.rs/object_store/latest/object_store/azure/struct.MicrosoftAzureBuilder.html#method.from_env).
|
||||
Azure Blob Storage credentials can be configured by setting the `AZURE_STORAGE_ACCOUNT_NAME`and `AZURE_STORAGE_ACCOUNT_KEY` environment variables. Alternatively, you can pass the account name and key in the `storage_options` parameter:
|
||||
|
||||
=== "Python"
|
||||
|
||||
<!-- skip-test -->
|
||||
```python
|
||||
import lancedb
|
||||
db = await lancedb.connect_async(
|
||||
"az://my-container/my-database",
|
||||
storage_options={
|
||||
account_name: "some-account",
|
||||
account_key: "some-key",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
||||
```javascript
|
||||
const lancedb = require("lancedb");
|
||||
const db = await lancedb.connect(
|
||||
"az://my-container/my-database",
|
||||
{
|
||||
storageOptions: {
|
||||
accountName: "some-account",
|
||||
accountKey: "some-key",
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
These keys can be used as both environment variables or keys in the `storage_options` parameter:
|
||||
|
||||
<!-- source: https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html -->
|
||||
|
||||
| Key | Description |
|
||||
|---------------------------------------|--------------------------------------------------------------------------------------------------|
|
||||
| ``azure_storage_account_name`` | The name of the azure storage account. |
|
||||
| ``azure_storage_account_key`` | The serialized service account key. |
|
||||
| ``azure_client_id`` | Service principal client id for authorizing requests. |
|
||||
| ``azure_client_secret`` | Service principal client secret for authorizing requests. |
|
||||
| ``azure_tenant_id`` | Tenant id used in oauth flows. |
|
||||
| ``azure_storage_sas_key`` | Shared access signature. The signature is expected to be percent-encoded, much like they are provided in the azure storage explorer or azure portal. |
|
||||
| ``azure_storage_token`` | Bearer token. |
|
||||
| ``azure_storage_use_emulator`` | Use object store with azurite storage emulator. |
|
||||
| ``azure_endpoint`` | Override the endpoint used to communicate with blob storage. |
|
||||
| ``azure_use_fabric_endpoint`` | Use object store with url scheme account.dfs.fabric.microsoft.com. |
|
||||
| ``azure_msi_endpoint`` | Endpoint to request a imds managed identity token. |
|
||||
| ``azure_object_id`` | Object id for use with managed identity authentication. |
|
||||
| ``azure_msi_resource_id`` | Msi resource id for use with managed identity authentication. |
|
||||
| ``azure_federated_token_file`` | File containing token for Azure AD workload identity federation. |
|
||||
| ``azure_use_azure_cli`` | Use azure cli for acquiring access token. |
|
||||
| ``azure_disable_tagging`` | Disables tagging objects. This can be desirable if not supported by the backing store. |
|
||||
|
||||
<!-- TODO: demonstrate how to configure networked file systems for optimal performance -->
|
||||
@@ -5,9 +5,6 @@ LanceDB supports both semantic and keyword-based search (also termed full-text s
|
||||
## Hybrid search in LanceDB
|
||||
You can perform hybrid search in LanceDB by combining the results of semantic and full-text search via a reranking algorithm of your choice. LanceDB provides multiple rerankers out of the box. However, you can always write a custom reranker if your use case need more sophisticated logic .
|
||||
|
||||
!!! note
|
||||
You need to create a full-text search index before performing a hybrid search. You can create a full-text search index using the `create_fts_index()` method of the table object.
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
@@ -58,7 +55,188 @@ By default, LanceDB uses `LinearCombinationReranker(weight=0.7)` to combine and
|
||||
|
||||
|
||||
## Available Rerankers
|
||||
LanceDB provides a number of re-rankers out of the box. You can use any of these re-rankers by passing them to the `rerank()` method. Visit the [rerankers](../reranking/) page for more information on each re-ranker.
|
||||
LanceDB provides a number of re-rankers out of the box. You can use any of these re-rankers by passing them to the `rerank()` method. Here's a list of available re-rankers:
|
||||
|
||||
## Custom Rerankers
|
||||
You can also create custom rerankers by extending the base `Reranker` class. The custom reranker should implement the `rerank` method that takes a list of search results and returns a reranked list of search results. Visit the [custom rerankers](../reranking/custom_reranker.md) page for more information on creating custom rerankers.
|
||||
### Linear Combination Reranker
|
||||
This is the default re-ranker used by LanceDB. It combines the results of semantic and full-text search using a linear combination of the scores. The weights for the linear combination can be specified. It defaults to 0.7, i.e, 70% weight for semantic search and 30% weight for full-text search.
|
||||
|
||||
|
||||
```python
|
||||
from lancedb.rerankers import LinearCombinationReranker
|
||||
|
||||
reranker = LinearCombinationReranker(weight=0.3) # Use 0.3 as the weight for vector search
|
||||
|
||||
results = table.search("rebel", query_type="hybrid").rerank(reranker=reranker).to_pandas()
|
||||
```
|
||||
|
||||
### Arguments
|
||||
----------------
|
||||
* `weight`: `float`, default `0.7`:
|
||||
The weight to use for the semantic search score. The weight for the full-text search score is `1 - weights`.
|
||||
* `fill`: `float`, default `1.0`:
|
||||
The score to give to results that are only in one of the two result sets.This is treated as penalty, so a higher value means a lower score.
|
||||
TODO: We should just hardcode this-- its pretty confusing as we invert scores to calculate final score
|
||||
* `return_score` : str, default `"relevance"`
|
||||
options are "relevance" or "all"
|
||||
The type of score to return. If "relevance", will return only the `_relevance_score. If "all", will return all scores from the vector and FTS search along with the relevance score.
|
||||
|
||||
### Cohere Reranker
|
||||
This re-ranker uses the [Cohere](https://cohere.ai/) API to combine the results of semantic and full-text search. You can use this re-ranker by passing `CohereReranker()` to the `rerank()` method. Note that you'll need to set the `COHERE_API_KEY` environment variable to use this re-ranker.
|
||||
|
||||
```python
|
||||
from lancedb.rerankers import CohereReranker
|
||||
|
||||
reranker = CohereReranker()
|
||||
|
||||
results = table.search("vampire weekend", query_type="hybrid").rerank(reranker=reranker).to_pandas()
|
||||
```
|
||||
|
||||
### Arguments
|
||||
----------------
|
||||
* `model_name` : str, default `"rerank-english-v2.0"`
|
||||
The name of the cross encoder model to use. Available cohere models are:
|
||||
- rerank-english-v2.0
|
||||
- rerank-multilingual-v2.0
|
||||
* `column` : str, default `"text"`
|
||||
The name of the column to use as input to the cross encoder model.
|
||||
* `top_n` : str, default `None`
|
||||
The number of results to return. If None, will return all results.
|
||||
|
||||
!!! Note
|
||||
Only returns `_relevance_score`. Does not support `return_score = "all"`.
|
||||
|
||||
### Cross Encoder Reranker
|
||||
This reranker uses the [Sentence Transformers](https://www.sbert.net/) library to combine the results of semantic and full-text search. You can use it by passing `CrossEncoderReranker()` to the `rerank()` method.
|
||||
|
||||
```python
|
||||
from lancedb.rerankers import CrossEncoderReranker
|
||||
|
||||
reranker = CrossEncoderReranker()
|
||||
|
||||
results = table.search("harmony hall", query_type="hybrid").rerank(reranker=reranker).to_pandas()
|
||||
```
|
||||
|
||||
|
||||
### Arguments
|
||||
----------------
|
||||
* `model` : str, default `"cross-encoder/ms-marco-TinyBERT-L-6"`
|
||||
The name of the cross encoder model to use. Available cross encoder models can be found [here](https://www.sbert.net/docs/pretrained_cross-encoders.html)
|
||||
* `column` : str, default `"text"`
|
||||
The name of the column to use as input to the cross encoder model.
|
||||
* `device` : str, default `None`
|
||||
The device to use for the cross encoder model. If None, will use "cuda" if available, otherwise "cpu".
|
||||
|
||||
!!! Note
|
||||
Only returns `_relevance_score`. Does not support `return_score = "all"`.
|
||||
|
||||
|
||||
### ColBERT Reranker
|
||||
This reranker uses the ColBERT model to combine the results of semantic and full-text search. You can use it by passing `ColbertrReranker()` to the `rerank()` method.
|
||||
|
||||
ColBERT reranker model calculates relevance of given docs against the query and don't take existing fts and vector search scores into account, so it currently only supports `return_score="relevance"`. By default, it looks for `text` column to rerank the results. But you can specify the column name to use as input to the cross encoder model as described below.
|
||||
|
||||
```python
|
||||
from lancedb.rerankers import ColbertReranker
|
||||
|
||||
reranker = ColbertReranker()
|
||||
|
||||
results = table.search("harmony hall", query_type="hybrid").rerank(reranker=reranker).to_pandas()
|
||||
```
|
||||
|
||||
### Arguments
|
||||
----------------
|
||||
* `model_name` : `str`, default `"colbert-ir/colbertv2.0"`
|
||||
The name of the cross encoder model to use.
|
||||
* `column` : `str`, default `"text"`
|
||||
The name of the column to use as input to the cross encoder model.
|
||||
* `return_score` : `str`, default `"relevance"`
|
||||
options are `"relevance"` or `"all"`. Only `"relevance"` is supported for now.
|
||||
|
||||
!!! Note
|
||||
Only returns `_relevance_score`. Does not support `return_score = "all"`.
|
||||
|
||||
### OpenAI Reranker
|
||||
This reranker uses the OpenAI API to combine the results of semantic and full-text search. You can use it by passing `OpenaiReranker()` to the `rerank()` method.
|
||||
|
||||
!!! Note
|
||||
This prompts chat model to rerank results which is not a dedicated reranker model. This should be treated as experimental.
|
||||
|
||||
!!! Tip
|
||||
- You might run out of token limit so set the search `limits` based on your token limit.
|
||||
- It is recommended to use gpt-4-turbo-preview, the default model, older models might lead to undesired behaviour
|
||||
|
||||
```python
|
||||
from lancedb.rerankers import OpenaiReranker
|
||||
|
||||
reranker = OpenaiReranker()
|
||||
|
||||
results = table.search("harmony hall", query_type="hybrid").rerank(reranker=reranker).to_pandas()
|
||||
```
|
||||
|
||||
### Arguments
|
||||
----------------
|
||||
* `model_name` : `str`, default `"gpt-4-turbo-preview"`
|
||||
The name of the cross encoder model to use.
|
||||
* `column` : `str`, default `"text"`
|
||||
The name of the column to use as input to the cross encoder model.
|
||||
* `return_score` : `str`, default `"relevance"`
|
||||
options are "relevance" or "all". Only "relevance" is supported for now.
|
||||
* `api_key` : `str`, default `None`
|
||||
The API key to use. If None, will use the OPENAI_API_KEY environment variable.
|
||||
|
||||
|
||||
## Building Custom Rerankers
|
||||
You can build your own custom reranker by subclassing the `Reranker` class and implementing the `rerank_hybrid()` method. Here's an example of a custom reranker that combines the results of semantic and full-text search using a linear combination of the scores.
|
||||
|
||||
The `Reranker` base interface comes with a `merge_results()` method that can be used to combine the results of semantic and full-text search. This is a vanilla merging algorithm that simply concatenates the results and removes the duplicates without taking the scores into consideration. It only keeps the first copy of the row encountered. This works well in cases that don't require the scores of semantic and full-text search to combine the results. If you want to use the scores or want to support `return_score="all"`, you'll need to implement your own merging algorithm.
|
||||
|
||||
```python
|
||||
|
||||
from lancedb.rerankers import Reranker
|
||||
import pyarrow as pa
|
||||
|
||||
class MyReranker(Reranker):
|
||||
def __init__(self, param1, param2, ..., return_score="relevance"):
|
||||
super().__init__(return_score)
|
||||
self.param1 = param1
|
||||
self.param2 = param2
|
||||
|
||||
def rerank_hybrid(self, query: str, vector_results: pa.Table, fts_results: pa.Table):
|
||||
# Use the built-in merging function
|
||||
combined_result = self.merge_results(vector_results, fts_results)
|
||||
|
||||
# Do something with the combined results
|
||||
# ...
|
||||
|
||||
# Return the combined results
|
||||
return combined_result
|
||||
|
||||
```
|
||||
|
||||
### Example of a Custom Reranker
|
||||
For the sake of simplicity let's build custom reranker that just enchances the Cohere Reranker by accepting a filter query, and accept other CohereReranker params as kwags.
|
||||
|
||||
```python
|
||||
|
||||
from typing import List, Union
|
||||
import pandas as pd
|
||||
from lancedb.rerankers import CohereReranker
|
||||
|
||||
class MofidifiedCohereReranker(CohereReranker):
|
||||
def __init__(self, filters: Union[str, List[str]], **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
filters = filters if isinstance(filters, list) else [filters]
|
||||
self.filters = filters
|
||||
|
||||
def rerank_hybrid(self, query: str, vector_results: pa.Table, fts_results: pa.Table)-> pa.Table:
|
||||
combined_result = super().rerank_hybrid(query, vector_results, fts_results)
|
||||
df = combined_result.to_pandas()
|
||||
for filter in self.filters:
|
||||
df = df.query("not text.str.contains(@filter)")
|
||||
|
||||
return pa.Table.from_pandas(df)
|
||||
|
||||
```
|
||||
|
||||
!!! tip
|
||||
The `vector_results` and `fts_results` are pyarrow tables. You can convert them to pandas dataframes using `to_pandas()` method and perform any operations you want. After you are done, you can convert the dataframe back to pyarrow table using `pa.Table.from_pandas()` method and return it.
|
||||
|
||||
1
docs/src/js/.nojekyll
Normal file
1
docs/src/js/.nojekyll
Normal file
@@ -0,0 +1 @@
|
||||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
||||
83
docs/src/js/README.md
Normal file
83
docs/src/js/README.md
Normal file
@@ -0,0 +1,83 @@
|
||||
@lancedb/lancedb / [Exports](modules.md)
|
||||
|
||||
# LanceDB JavaScript SDK
|
||||
|
||||
A JavaScript library for [LanceDB](https://github.com/lancedb/lancedb).
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @lancedb/lancedb
|
||||
```
|
||||
|
||||
This will download the appropriate native library for your platform. We currently
|
||||
support:
|
||||
|
||||
- Linux (x86_64 and aarch64)
|
||||
- MacOS (Intel and ARM/M1/M2)
|
||||
- Windows (x86_64 only)
|
||||
|
||||
We do not yet support musl-based Linux (such as Alpine Linux) or aarch64 Windows.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Example
|
||||
|
||||
```javascript
|
||||
import * as lancedb from "@lancedb/lancedb";
|
||||
const db = await lancedb.connect("data/sample-lancedb");
|
||||
const table = await db.createTable("my_table", [
|
||||
{ id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
|
||||
{ id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 },
|
||||
]);
|
||||
const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
|
||||
console.log(results);
|
||||
```
|
||||
|
||||
The [quickstart](../basic.md) contains a more complete example.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
npm run test
|
||||
```
|
||||
|
||||
### Running lint / format
|
||||
|
||||
LanceDb uses eslint for linting. VSCode does not need any plugins to use eslint. However, it
|
||||
may need some additional configuration. Make sure that eslint.experimental.useFlatConfig is
|
||||
set to true. Also, if your vscode root folder is the repo root then you will need to set
|
||||
the eslint.workingDirectories to ["nodejs"]. To manually lint your code you can run:
|
||||
|
||||
```sh
|
||||
npm run lint
|
||||
```
|
||||
|
||||
LanceDb uses prettier for formatting. If you are using VSCode you will need to install the
|
||||
"Prettier - Code formatter" extension. You should then configure it to be the default formatter
|
||||
for typescript and you should enable format on save. To manually check your code's format you
|
||||
can run:
|
||||
|
||||
```sh
|
||||
npm run chkformat
|
||||
```
|
||||
|
||||
If you need to manually format your code you can run:
|
||||
|
||||
```sh
|
||||
npx prettier --write .
|
||||
```
|
||||
|
||||
### Generating docs
|
||||
|
||||
```sh
|
||||
npm run docs
|
||||
|
||||
cd ../docs
|
||||
# Asssume the virtual environment was created
|
||||
# python3 -m venv venv
|
||||
# pip install -r requirements.txt
|
||||
. ./venv/bin/activate
|
||||
mkdocs build
|
||||
```
|
||||
239
docs/src/js/classes/Connection.md
Normal file
239
docs/src/js/classes/Connection.md
Normal file
@@ -0,0 +1,239 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Connection
|
||||
|
||||
# Class: Connection
|
||||
|
||||
A LanceDB Connection that allows you to open tables and create new ones.
|
||||
|
||||
Connection could be local against filesystem or remote against a server.
|
||||
|
||||
A Connection is intended to be a long lived object and may hold open
|
||||
resources such as HTTP connection pools. This is generally fine and
|
||||
a single connection should be shared if it is going to be used many
|
||||
times. However, if you are finished with a connection, you may call
|
||||
close to eagerly free these resources. Any call to a Connection
|
||||
method after it has been closed will result in an error.
|
||||
|
||||
Closing a connection is optional. Connections will automatically
|
||||
be closed when they are garbage collected.
|
||||
|
||||
Any created tables are independent and will continue to work even if
|
||||
the underlying connection has been closed.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](Connection.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](Connection.md#inner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [close](Connection.md#close)
|
||||
- [createEmptyTable](Connection.md#createemptytable)
|
||||
- [createTable](Connection.md#createtable)
|
||||
- [display](Connection.md#display)
|
||||
- [dropTable](Connection.md#droptable)
|
||||
- [isOpen](Connection.md#isopen)
|
||||
- [openTable](Connection.md#opentable)
|
||||
- [tableNames](Connection.md#tablenames)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new Connection**(`inner`): [`Connection`](Connection.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `inner` | `Connection` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Connection`](Connection.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:72](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L72)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Readonly` **inner**: `Connection`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:70](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L70)
|
||||
|
||||
## Methods
|
||||
|
||||
### close
|
||||
|
||||
▸ **close**(): `void`
|
||||
|
||||
Close the connection, releasing any underlying resources.
|
||||
|
||||
It is safe to call this method multiple times.
|
||||
|
||||
Any attempt to use the connection after it is closed will result in an error.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:88](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L88)
|
||||
|
||||
___
|
||||
|
||||
### createEmptyTable
|
||||
|
||||
▸ **createEmptyTable**(`name`, `schema`, `options?`): `Promise`\<[`Table`](Table.md)\>
|
||||
|
||||
Creates a new empty Table
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `name` | `string` | The name of the table. |
|
||||
| `schema` | `Schema`\<`any`\> | The schema of the table |
|
||||
| `options?` | `Partial`\<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)\> | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<[`Table`](Table.md)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:151](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L151)
|
||||
|
||||
___
|
||||
|
||||
### createTable
|
||||
|
||||
▸ **createTable**(`name`, `data`, `options?`): `Promise`\<[`Table`](Table.md)\>
|
||||
|
||||
Creates a new Table and initialize it with new data.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `name` | `string` | The name of the table. |
|
||||
| `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table |
|
||||
| `options?` | `Partial`\<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)\> | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<[`Table`](Table.md)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:123](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L123)
|
||||
|
||||
___
|
||||
|
||||
### display
|
||||
|
||||
▸ **display**(): `string`
|
||||
|
||||
Return a brief description of the connection
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:93](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L93)
|
||||
|
||||
___
|
||||
|
||||
### dropTable
|
||||
|
||||
▸ **dropTable**(`name`): `Promise`\<`void`\>
|
||||
|
||||
Drop an existing table.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `name` | `string` | The name of the table to drop. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:173](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L173)
|
||||
|
||||
___
|
||||
|
||||
### isOpen
|
||||
|
||||
▸ **isOpen**(): `boolean`
|
||||
|
||||
Return true if the connection has not been closed
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:77](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L77)
|
||||
|
||||
___
|
||||
|
||||
### openTable
|
||||
|
||||
▸ **openTable**(`name`): `Promise`\<[`Table`](Table.md)\>
|
||||
|
||||
Open a table in the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `name` | `string` | The name of the table |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<[`Table`](Table.md)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:112](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L112)
|
||||
|
||||
___
|
||||
|
||||
### tableNames
|
||||
|
||||
▸ **tableNames**(`options?`): `Promise`\<`string`[]\>
|
||||
|
||||
List all the table names in this database.
|
||||
|
||||
Tables will be returned in lexicographical order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `options?` | `Partial`\<[`TableNamesOptions`](../interfaces/TableNamesOptions.md)\> | options to control the paging / start point |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`string`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:104](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L104)
|
||||
121
docs/src/js/classes/Index.md
Normal file
121
docs/src/js/classes/Index.md
Normal file
@@ -0,0 +1,121 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Index
|
||||
|
||||
# Class: Index
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](Index.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](Index.md#inner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [btree](Index.md#btree)
|
||||
- [ivfPq](Index.md#ivfpq)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new Index**(`inner`): [`Index`](Index.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `inner` | `Index` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Index`](Index.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:118](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L118)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Private` `Readonly` **inner**: `Index`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:117](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L117)
|
||||
|
||||
## Methods
|
||||
|
||||
### btree
|
||||
|
||||
▸ **btree**(): [`Index`](Index.md)
|
||||
|
||||
Create a btree index
|
||||
|
||||
A btree index is an index on a scalar columns. The index stores a copy of the column
|
||||
in sorted order. A header entry is created for each block of rows (currently the
|
||||
block size is fixed at 4096). These header entries are stored in a separate
|
||||
cacheable structure (a btree). To search for data the header is used to determine
|
||||
which blocks need to be read from disk.
|
||||
|
||||
For example, a btree index in a table with 1Bi rows requires sizeof(Scalar) * 256Ki
|
||||
bytes of memory and will generally need to read sizeof(Scalar) * 4096 bytes to find
|
||||
the correct row ids.
|
||||
|
||||
This index is good for scalar columns with mostly distinct values and does best when
|
||||
the query is highly selective.
|
||||
|
||||
The btree index does not currently have any parameters though parameters such as the
|
||||
block size may be added in the future.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Index`](Index.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:175](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L175)
|
||||
|
||||
___
|
||||
|
||||
### ivfPq
|
||||
|
||||
▸ **ivfPq**(`options?`): [`Index`](Index.md)
|
||||
|
||||
Create an IvfPq index
|
||||
|
||||
This index stores a compressed (quantized) copy of every vector. These vectors
|
||||
are grouped into partitions of similar vectors. Each partition keeps track of
|
||||
a centroid which is the average value of all vectors in the group.
|
||||
|
||||
During a query the centroids are compared with the query vector to find the closest
|
||||
partitions. The compressed vectors in these partitions are then searched to find
|
||||
the closest vectors.
|
||||
|
||||
The compression scheme is called product quantization. Each vector is divided into
|
||||
subvectors and then each subvector is quantized into a small number of bits. the
|
||||
parameters `num_bits` and `num_subvectors` control this process, providing a tradeoff
|
||||
between index size (and thus search speed) and index accuracy.
|
||||
|
||||
The partitioning process is called IVF and the `num_partitions` parameter controls how
|
||||
many groups to create.
|
||||
|
||||
Note that training an IVF PQ index on a large dataset is a slow operation and
|
||||
currently is also a memory intensive operation.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `options?` | `Partial`\<[`IvfPqOptions`](../interfaces/IvfPqOptions.md)\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Index`](Index.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:144](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L144)
|
||||
75
docs/src/js/classes/MakeArrowTableOptions.md
Normal file
75
docs/src/js/classes/MakeArrowTableOptions.md
Normal file
@@ -0,0 +1,75 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / MakeArrowTableOptions
|
||||
|
||||
# Class: MakeArrowTableOptions
|
||||
|
||||
Options to control the makeArrowTable call.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](MakeArrowTableOptions.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [dictionaryEncodeStrings](MakeArrowTableOptions.md#dictionaryencodestrings)
|
||||
- [schema](MakeArrowTableOptions.md#schema)
|
||||
- [vectorColumns](MakeArrowTableOptions.md#vectorcolumns)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new MakeArrowTableOptions**(`values?`): [`MakeArrowTableOptions`](MakeArrowTableOptions.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `values?` | `Partial`\<[`MakeArrowTableOptions`](MakeArrowTableOptions.md)\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`MakeArrowTableOptions`](MakeArrowTableOptions.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:100](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L100)
|
||||
|
||||
## Properties
|
||||
|
||||
### dictionaryEncodeStrings
|
||||
|
||||
• **dictionaryEncodeStrings**: `boolean` = `false`
|
||||
|
||||
If true then string columns will be encoded with dictionary encoding
|
||||
|
||||
Set this to true if your string columns tend to repeat the same values
|
||||
often. For more precise control use the `schema` property to specify the
|
||||
data type for individual columns.
|
||||
|
||||
If `schema` is provided then this property is ignored.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:98](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L98)
|
||||
|
||||
___
|
||||
|
||||
### schema
|
||||
|
||||
• `Optional` **schema**: `Schema`\<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:67](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### vectorColumns
|
||||
|
||||
• **vectorColumns**: `Record`\<`string`, [`VectorColumnOptions`](VectorColumnOptions.md)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:85](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L85)
|
||||
368
docs/src/js/classes/Query.md
Normal file
368
docs/src/js/classes/Query.md
Normal file
@@ -0,0 +1,368 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Query
|
||||
|
||||
# Class: Query
|
||||
|
||||
A builder for LanceDB queries.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- [`QueryBase`](QueryBase.md)\<`NativeQuery`, [`Query`](Query.md)\>
|
||||
|
||||
↳ **`Query`**
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](Query.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](Query.md#inner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [[asyncIterator]](Query.md#[asynciterator])
|
||||
- [execute](Query.md#execute)
|
||||
- [limit](Query.md#limit)
|
||||
- [nativeExecute](Query.md#nativeexecute)
|
||||
- [nearestTo](Query.md#nearestto)
|
||||
- [select](Query.md#select)
|
||||
- [toArray](Query.md#toarray)
|
||||
- [toArrow](Query.md#toarrow)
|
||||
- [where](Query.md#where)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new Query**(`tbl`): [`Query`](Query.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `tbl` | `Table` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Query`](Query.md)
|
||||
|
||||
#### Overrides
|
||||
|
||||
[QueryBase](QueryBase.md).[constructor](QueryBase.md#constructor)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:329](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L329)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Protected` **inner**: `Query`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[inner](QueryBase.md#inner)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:59](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L59)
|
||||
|
||||
## Methods
|
||||
|
||||
### [asyncIterator]
|
||||
|
||||
▸ **[asyncIterator]**(): `AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[[asyncIterator]](QueryBase.md#[asynciterator])
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:154](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### execute
|
||||
|
||||
▸ **execute**(): [`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
Execute the query and return the results as an
|
||||
|
||||
#### Returns
|
||||
|
||||
[`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
- AsyncIterator
|
||||
of
|
||||
- RecordBatch.
|
||||
|
||||
By default, LanceDb will use many threads to calculate results and, when
|
||||
the result set is large, multiple batches will be processed at one time.
|
||||
This readahead is limited however and backpressure will be applied if this
|
||||
stream is consumed slowly (this constrains the maximum memory used by a
|
||||
single query)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[execute](QueryBase.md#execute)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:149](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L149)
|
||||
|
||||
___
|
||||
|
||||
### limit
|
||||
|
||||
▸ **limit**(`limit`): [`Query`](Query.md)
|
||||
|
||||
Set the maximum number of results to return.
|
||||
|
||||
By default, a plain search has no limit. If this method is not
|
||||
called then every valid row from the table will be returned.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `limit` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Query`](Query.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[limit](QueryBase.md#limit)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:129](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L129)
|
||||
|
||||
___
|
||||
|
||||
### nativeExecute
|
||||
|
||||
▸ **nativeExecute**(): `Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[nativeExecute](QueryBase.md#nativeexecute)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:134](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### nearestTo
|
||||
|
||||
▸ **nearestTo**(`vector`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Find the nearest vectors to the given query vector.
|
||||
|
||||
This converts the query from a plain query to a vector query.
|
||||
|
||||
This method will attempt to convert the input to the query vector
|
||||
expected by the embedding model. If the input cannot be converted
|
||||
then an error will be thrown.
|
||||
|
||||
By default, there is no embedding model, and the input should be
|
||||
an array-like object of numbers (something that can be used as input
|
||||
to Float32Array.from)
|
||||
|
||||
If there is only one vector column (a column whose data type is a
|
||||
fixed size list of floats) then the column does not need to be specified.
|
||||
If there is more than one vector column you must use
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `vector` | `unknown` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
- [VectorQuery#column](VectorQuery.md#column) to specify which column you would like
|
||||
to compare with.
|
||||
|
||||
If no index has been created on the vector column then a vector query
|
||||
will perform a distance comparison between the query vector and every
|
||||
vector in the database and then sort the results. This is sometimes
|
||||
called a "flat search"
|
||||
|
||||
For small databases, with a few hundred thousand vectors or less, this can
|
||||
be reasonably fast. In larger databases you should create a vector index
|
||||
on the column. If there is a vector index then an "approximate" nearest
|
||||
neighbor search (frequently called an ANN search) will be performed. This
|
||||
search is much faster, but the results will be approximate.
|
||||
|
||||
The query can be further parameterized using the returned builder. There
|
||||
are various ANN search parameters that will let you fine tune your recall
|
||||
accuracy vs search latency.
|
||||
|
||||
Vector searches always have a `limit`. If `limit` has not been called then
|
||||
a default `limit` of 10 will be used.
|
||||
- [Query#limit](Query.md#limit)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:370](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L370)
|
||||
|
||||
___
|
||||
|
||||
### select
|
||||
|
||||
▸ **select**(`columns`): [`Query`](Query.md)
|
||||
|
||||
Return only the specified columns.
|
||||
|
||||
By default a query will return all columns from the table. However, this can have
|
||||
a very significant impact on latency. LanceDb stores data in a columnar fashion. This
|
||||
means we can finely tune our I/O to select exactly the columns we need.
|
||||
|
||||
As a best practice you should always limit queries to the columns that you need. If you
|
||||
pass in an array of column names then only those columns will be returned.
|
||||
|
||||
You can also use this method to create new "dynamic" columns based on your existing columns.
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `columns` | `string`[] \| `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Query`](Query.md)
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[select](QueryBase.md#select)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:108](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
### toArray
|
||||
|
||||
▸ **toArray**(): `Promise`\<`unknown`[]\>
|
||||
|
||||
Collect the results as an array of objects.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`unknown`[]\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[toArray](QueryBase.md#toarray)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:169](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L169)
|
||||
|
||||
___
|
||||
|
||||
### toArrow
|
||||
|
||||
▸ **toArrow**(): `Promise`\<`Table`\<`any`\>\>
|
||||
|
||||
Collect the results as an Arrow
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`Table`\<`any`\>\>
|
||||
|
||||
**`See`**
|
||||
|
||||
ArrowTable.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[toArrow](QueryBase.md#toarrow)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:160](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L160)
|
||||
|
||||
___
|
||||
|
||||
### where
|
||||
|
||||
▸ **where**(`predicate`): [`Query`](Query.md)
|
||||
|
||||
A filter statement to be applied to this query.
|
||||
|
||||
The filter should be supplied as an SQL query string. For example:
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `predicate` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Query`](Query.md)
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
x > 10
|
||||
y > 0 AND y < 100
|
||||
x > 5 OR y = 'test'
|
||||
|
||||
Filtering performance can often be improved by creating a scalar index
|
||||
on the filter column(s).
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[where](QueryBase.md#where)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:73](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L73)
|
||||
291
docs/src/js/classes/QueryBase.md
Normal file
291
docs/src/js/classes/QueryBase.md
Normal file
@@ -0,0 +1,291 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / QueryBase
|
||||
|
||||
# Class: QueryBase\<NativeQueryType, QueryType\>
|
||||
|
||||
Common methods supported by all query types
|
||||
|
||||
## Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `NativeQueryType` | extends `NativeQuery` \| `NativeVectorQuery` |
|
||||
| `QueryType` | `QueryType` |
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- **`QueryBase`**
|
||||
|
||||
↳ [`Query`](Query.md)
|
||||
|
||||
↳ [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
## Implements
|
||||
|
||||
- `AsyncIterable`\<`RecordBatch`\>
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](QueryBase.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](QueryBase.md#inner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [[asyncIterator]](QueryBase.md#[asynciterator])
|
||||
- [execute](QueryBase.md#execute)
|
||||
- [limit](QueryBase.md#limit)
|
||||
- [nativeExecute](QueryBase.md#nativeexecute)
|
||||
- [select](QueryBase.md#select)
|
||||
- [toArray](QueryBase.md#toarray)
|
||||
- [toArrow](QueryBase.md#toarrow)
|
||||
- [where](QueryBase.md#where)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new QueryBase**\<`NativeQueryType`, `QueryType`\>(`inner`): [`QueryBase`](QueryBase.md)\<`NativeQueryType`, `QueryType`\>
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `NativeQueryType` | extends `Query` \| `VectorQuery` |
|
||||
| `QueryType` | `QueryType` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `inner` | `NativeQueryType` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`QueryBase`](QueryBase.md)\<`NativeQueryType`, `QueryType`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:59](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L59)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Protected` **inner**: `NativeQueryType`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:59](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L59)
|
||||
|
||||
## Methods
|
||||
|
||||
### [asyncIterator]
|
||||
|
||||
▸ **[asyncIterator]**(): `AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\>
|
||||
|
||||
#### Implementation of
|
||||
|
||||
AsyncIterable.[asyncIterator]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:154](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### execute
|
||||
|
||||
▸ **execute**(): [`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
Execute the query and return the results as an
|
||||
|
||||
#### Returns
|
||||
|
||||
[`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
- AsyncIterator
|
||||
of
|
||||
- RecordBatch.
|
||||
|
||||
By default, LanceDb will use many threads to calculate results and, when
|
||||
the result set is large, multiple batches will be processed at one time.
|
||||
This readahead is limited however and backpressure will be applied if this
|
||||
stream is consumed slowly (this constrains the maximum memory used by a
|
||||
single query)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:149](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L149)
|
||||
|
||||
___
|
||||
|
||||
### limit
|
||||
|
||||
▸ **limit**(`limit`): `QueryType`
|
||||
|
||||
Set the maximum number of results to return.
|
||||
|
||||
By default, a plain search has no limit. If this method is not
|
||||
called then every valid row from the table will be returned.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `limit` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`QueryType`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:129](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L129)
|
||||
|
||||
___
|
||||
|
||||
### nativeExecute
|
||||
|
||||
▸ **nativeExecute**(): `Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:134](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### select
|
||||
|
||||
▸ **select**(`columns`): `QueryType`
|
||||
|
||||
Return only the specified columns.
|
||||
|
||||
By default a query will return all columns from the table. However, this can have
|
||||
a very significant impact on latency. LanceDb stores data in a columnar fashion. This
|
||||
means we can finely tune our I/O to select exactly the columns we need.
|
||||
|
||||
As a best practice you should always limit queries to the columns that you need. If you
|
||||
pass in an array of column names then only those columns will be returned.
|
||||
|
||||
You can also use this method to create new "dynamic" columns based on your existing columns.
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `columns` | `string`[] \| `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`QueryType`
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
```
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:108](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
### toArray
|
||||
|
||||
▸ **toArray**(): `Promise`\<`unknown`[]\>
|
||||
|
||||
Collect the results as an array of objects.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`unknown`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:169](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L169)
|
||||
|
||||
___
|
||||
|
||||
### toArrow
|
||||
|
||||
▸ **toArrow**(): `Promise`\<`Table`\<`any`\>\>
|
||||
|
||||
Collect the results as an Arrow
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`Table`\<`any`\>\>
|
||||
|
||||
**`See`**
|
||||
|
||||
ArrowTable.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:160](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L160)
|
||||
|
||||
___
|
||||
|
||||
### where
|
||||
|
||||
▸ **where**(`predicate`): `QueryType`
|
||||
|
||||
A filter statement to be applied to this query.
|
||||
|
||||
The filter should be supplied as an SQL query string. For example:
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `predicate` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`QueryType`
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
x > 10
|
||||
y > 0 AND y < 100
|
||||
x > 5 OR y = 'test'
|
||||
|
||||
Filtering performance can often be improved by creating a scalar index
|
||||
on the filter column(s).
|
||||
```
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:73](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L73)
|
||||
80
docs/src/js/classes/RecordBatchIterator.md
Normal file
80
docs/src/js/classes/RecordBatchIterator.md
Normal file
@@ -0,0 +1,80 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / RecordBatchIterator
|
||||
|
||||
# Class: RecordBatchIterator
|
||||
|
||||
## Implements
|
||||
|
||||
- `AsyncIterator`\<`RecordBatch`\>
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](RecordBatchIterator.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](RecordBatchIterator.md#inner)
|
||||
- [promisedInner](RecordBatchIterator.md#promisedinner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [next](RecordBatchIterator.md#next)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new RecordBatchIterator**(`promise?`): [`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `promise?` | `Promise`\<`RecordBatchIterator`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:27](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L27)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Private` `Optional` **inner**: `RecordBatchIterator`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:25](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### promisedInner
|
||||
|
||||
• `Private` `Optional` **promisedInner**: `Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:24](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L24)
|
||||
|
||||
## Methods
|
||||
|
||||
### next
|
||||
|
||||
▸ **next**(): `Promise`\<`IteratorResult`\<`RecordBatch`\<`any`\>, `any`\>\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`IteratorResult`\<`RecordBatch`\<`any`\>, `any`\>\>
|
||||
|
||||
#### Implementation of
|
||||
|
||||
AsyncIterator.next
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:33](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L33)
|
||||
594
docs/src/js/classes/Table.md
Normal file
594
docs/src/js/classes/Table.md
Normal file
@@ -0,0 +1,594 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Table
|
||||
|
||||
# Class: Table
|
||||
|
||||
A Table is a collection of Records in a LanceDB Database.
|
||||
|
||||
A Table object is expected to be long lived and reused for multiple operations.
|
||||
Table objects will cache a certain amount of index data in memory. This cache
|
||||
will be freed when the Table is garbage collected. To eagerly free the cache you
|
||||
can call the `close` method. Once the Table is closed, it cannot be used for any
|
||||
further operations.
|
||||
|
||||
Closing a table is optional. It not closed, it will be closed when it is garbage
|
||||
collected.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](Table.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](Table.md#inner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [add](Table.md#add)
|
||||
- [addColumns](Table.md#addcolumns)
|
||||
- [alterColumns](Table.md#altercolumns)
|
||||
- [checkout](Table.md#checkout)
|
||||
- [checkoutLatest](Table.md#checkoutlatest)
|
||||
- [close](Table.md#close)
|
||||
- [countRows](Table.md#countrows)
|
||||
- [createIndex](Table.md#createindex)
|
||||
- [delete](Table.md#delete)
|
||||
- [display](Table.md#display)
|
||||
- [dropColumns](Table.md#dropcolumns)
|
||||
- [isOpen](Table.md#isopen)
|
||||
- [listIndices](Table.md#listindices)
|
||||
- [query](Table.md#query)
|
||||
- [restore](Table.md#restore)
|
||||
- [schema](Table.md#schema)
|
||||
- [update](Table.md#update)
|
||||
- [vectorSearch](Table.md#vectorsearch)
|
||||
- [version](Table.md#version)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new Table**(`inner`): [`Table`](Table.md)
|
||||
|
||||
Construct a Table. Internal use only.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `inner` | `Table` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Table`](Table.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:69](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L69)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Private` `Readonly` **inner**: `Table`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:66](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L66)
|
||||
|
||||
## Methods
|
||||
|
||||
### add
|
||||
|
||||
▸ **add**(`data`, `options?`): `Promise`\<`void`\>
|
||||
|
||||
Insert records into this Table.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | [`Data`](../modules.md#data) | Records to be inserted into the Table |
|
||||
| `options?` | `Partial`\<[`AddDataOptions`](../interfaces/AddDataOptions.md)\> | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:105](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L105)
|
||||
|
||||
___
|
||||
|
||||
### addColumns
|
||||
|
||||
▸ **addColumns**(`newColumnTransforms`): `Promise`\<`void`\>
|
||||
|
||||
Add new columns with defined values.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `newColumnTransforms` | [`AddColumnsSql`](../interfaces/AddColumnsSql.md)[] | pairs of column names and the SQL expression to use to calculate the value of the new column. These expressions will be evaluated for each row in the table, and can reference existing columns in the table. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:261](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L261)
|
||||
|
||||
___
|
||||
|
||||
### alterColumns
|
||||
|
||||
▸ **alterColumns**(`columnAlterations`): `Promise`\<`void`\>
|
||||
|
||||
Alter the name or nullability of columns.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `columnAlterations` | [`ColumnAlteration`](../interfaces/ColumnAlteration.md)[] | One or more alterations to apply to columns. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:270](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L270)
|
||||
|
||||
___
|
||||
|
||||
### checkout
|
||||
|
||||
▸ **checkout**(`version`): `Promise`\<`void`\>
|
||||
|
||||
Checks out a specific version of the Table
|
||||
|
||||
Any read operation on the table will now access the data at the checked out version.
|
||||
As a consequence, calling this method will disable any read consistency interval
|
||||
that was previously set.
|
||||
|
||||
This is a read-only operation that turns the table into a sort of "view"
|
||||
or "detached head". Other table instances will not be affected. To make the change
|
||||
permanent you can use the `[Self::restore]` method.
|
||||
|
||||
Any operation that modifies the table will fail while the table is in a checked
|
||||
out state.
|
||||
|
||||
To return the table to a normal state use `[Self::checkout_latest]`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `version` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:317](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L317)
|
||||
|
||||
___
|
||||
|
||||
### checkoutLatest
|
||||
|
||||
▸ **checkoutLatest**(): `Promise`\<`void`\>
|
||||
|
||||
Ensures the table is pointing at the latest version
|
||||
|
||||
This can be used to manually update a table when the read_consistency_interval is None
|
||||
It can also be used to undo a `[Self::checkout]` operation
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:327](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L327)
|
||||
|
||||
___
|
||||
|
||||
### close
|
||||
|
||||
▸ **close**(): `void`
|
||||
|
||||
Close the table, releasing any underlying resources.
|
||||
|
||||
It is safe to call this method multiple times.
|
||||
|
||||
Any attempt to use the table after it is closed will result in an error.
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:85](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L85)
|
||||
|
||||
___
|
||||
|
||||
### countRows
|
||||
|
||||
▸ **countRows**(`filter?`): `Promise`\<`number`\>
|
||||
|
||||
Count the total number of rows in the dataset.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `filter?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`number`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:152](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L152)
|
||||
|
||||
___
|
||||
|
||||
### createIndex
|
||||
|
||||
▸ **createIndex**(`column`, `options?`): `Promise`\<`void`\>
|
||||
|
||||
Create an index to speed up queries.
|
||||
|
||||
Indices can be created on vector columns or scalar columns.
|
||||
Indices on vector columns will speed up vector searches.
|
||||
Indices on scalar columns will speed up filtering (in both
|
||||
vector and non-vector searches)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `column` | `string` |
|
||||
| `options?` | `Partial`\<[`IndexOptions`](../interfaces/IndexOptions.md)\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
// If the column has a vector (fixed size list) data type then
|
||||
// an IvfPq vector index will be created.
|
||||
const table = await conn.openTable("my_table");
|
||||
await table.createIndex(["vector"]);
|
||||
```
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
// For advanced control over vector index creation you can specify
|
||||
// the index type and options.
|
||||
const table = await conn.openTable("my_table");
|
||||
await table.createIndex(["vector"], I)
|
||||
.ivf_pq({ num_partitions: 128, num_sub_vectors: 16 })
|
||||
.build();
|
||||
```
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
// Or create a Scalar index
|
||||
await table.createIndex("my_float_col").build();
|
||||
```
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:184](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L184)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`predicate`): `Promise`\<`void`\>
|
||||
|
||||
Delete the rows that satisfy the predicate.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `predicate` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:157](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L157)
|
||||
|
||||
___
|
||||
|
||||
### display
|
||||
|
||||
▸ **display**(): `string`
|
||||
|
||||
Return a brief description of the table
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:90](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L90)
|
||||
|
||||
___
|
||||
|
||||
### dropColumns
|
||||
|
||||
▸ **dropColumns**(`columnNames`): `Promise`\<`void`\>
|
||||
|
||||
Drop one or more columns from the dataset
|
||||
|
||||
This is a metadata-only operation and does not remove the data from the
|
||||
underlying storage. In order to remove the data, you must subsequently
|
||||
call ``compact_files`` to rewrite the data without the removed columns and
|
||||
then call ``cleanup_files`` to remove the old files.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `columnNames` | `string`[] | The names of the columns to drop. These can be nested column references (e.g. "a.b.c") or top-level column names (e.g. "a"). |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:285](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L285)
|
||||
|
||||
___
|
||||
|
||||
### isOpen
|
||||
|
||||
▸ **isOpen**(): `boolean`
|
||||
|
||||
Return true if the table has not been closed
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:74](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L74)
|
||||
|
||||
___
|
||||
|
||||
### listIndices
|
||||
|
||||
▸ **listIndices**(): `Promise`\<[`IndexConfig`](../interfaces/IndexConfig.md)[]\>
|
||||
|
||||
List all indices that have been created with Self::create_index
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<[`IndexConfig`](../interfaces/IndexConfig.md)[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:350](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L350)
|
||||
|
||||
___
|
||||
|
||||
### query
|
||||
|
||||
▸ **query**(): [`Query`](Query.md)
|
||||
|
||||
Create a [Query](Query.md) Builder.
|
||||
|
||||
Queries allow you to search your existing data. By default the query will
|
||||
return all the data in the table in no particular order. The builder
|
||||
returned by this method can be used to control the query using filtering,
|
||||
vector similarity, sorting, and more.
|
||||
|
||||
Note: By default, all columns are returned. For best performance, you should
|
||||
only fetch the columns you need. See [`Query::select_with_projection`] for
|
||||
more details.
|
||||
|
||||
When appropriate, various indices and statistics based pruning will be used to
|
||||
accelerate the query.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`Query`](Query.md)
|
||||
|
||||
A builder that can be used to parameterize the query
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
// SQL-style filtering
|
||||
//
|
||||
// This query will return up to 1000 rows whose value in the `id` column
|
||||
// is greater than 5. LanceDb supports a broad set of filtering functions.
|
||||
for await (const batch of table.query()
|
||||
.filter("id > 1").select(["id"]).limit(20)) {
|
||||
console.log(batch);
|
||||
}
|
||||
```
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
// Vector Similarity Search
|
||||
//
|
||||
// This example will find the 10 rows whose value in the "vector" column are
|
||||
// closest to the query vector [1.0, 2.0, 3.0]. If an index has been created
|
||||
// on the "vector" column then this will perform an ANN search.
|
||||
//
|
||||
// The `refine_factor` and `nprobes` methods are used to control the recall /
|
||||
// latency tradeoff of the search.
|
||||
for await (const batch of table.query()
|
||||
.nearestTo([1, 2, 3])
|
||||
.refineFactor(5).nprobe(10)
|
||||
.limit(10)) {
|
||||
console.log(batch);
|
||||
}
|
||||
```
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
// Scan the full dataset
|
||||
//
|
||||
// This query will return everything in the table in no particular order.
|
||||
for await (const batch of table.query()) {
|
||||
console.log(batch);
|
||||
}
|
||||
```
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:238](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L238)
|
||||
|
||||
___
|
||||
|
||||
### restore
|
||||
|
||||
▸ **restore**(): `Promise`\<`void`\>
|
||||
|
||||
Restore the table to the currently checked out version
|
||||
|
||||
This operation will fail if checkout has not been called previously
|
||||
|
||||
This operation will overwrite the latest version of the table with a
|
||||
previous version. Any changes made since the checked out version will
|
||||
no longer be visible.
|
||||
|
||||
Once the operation concludes the table will no longer be in a checked
|
||||
out state and the read_consistency_interval, if any, will apply.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:343](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L343)
|
||||
|
||||
___
|
||||
|
||||
### schema
|
||||
|
||||
▸ **schema**(): `Promise`\<`Schema`\<`any`\>\>
|
||||
|
||||
Get the schema of the table.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`Schema`\<`any`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:95](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L95)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`updates`, `options?`): `Promise`\<`void`\>
|
||||
|
||||
Update existing records in the Table
|
||||
|
||||
An update operation can be used to adjust existing values. Use the
|
||||
returned builder to specify which columns to update. The new value
|
||||
can be a literal value (e.g. replacing nulls with some default value)
|
||||
or an expression applied to the old value (e.g. incrementing a value)
|
||||
|
||||
An optional condition can be specified (e.g. "only update if the old
|
||||
value is 0")
|
||||
|
||||
Note: if your condition is something like "some_id_column == 7" and
|
||||
you are updating many rows (with different ids) then you will get
|
||||
better performance with a single [`merge_insert`] call instead of
|
||||
repeatedly calilng this method.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `updates` | `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> | the columns to update Keys in the map should specify the name of the column to update. Values in the map provide the new value of the column. These can be SQL literal strings (e.g. "7" or "'foo'") or they can be expressions based on the row being updated (e.g. "my_col + 1") |
|
||||
| `options?` | `Partial`\<[`UpdateOptions`](../interfaces/UpdateOptions.md)\> | additional options to control the update behavior |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:137](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L137)
|
||||
|
||||
___
|
||||
|
||||
### vectorSearch
|
||||
|
||||
▸ **vectorSearch**(`vector`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Search the table with a given query vector.
|
||||
|
||||
This is a convenience method for preparing a vector query and
|
||||
is the same thing as calling `nearestTo` on the builder returned
|
||||
by `query`.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `vector` | `unknown` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
[Query#nearestTo](Query.md#nearestto) for more details.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:249](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L249)
|
||||
|
||||
___
|
||||
|
||||
### version
|
||||
|
||||
▸ **version**(): `Promise`\<`number`\>
|
||||
|
||||
Retrieve the version of the table
|
||||
|
||||
LanceDb supports versioning. Every operation that modifies the table increases
|
||||
version. As long as a version hasn't been deleted you can `[Self::checkout]` that
|
||||
version to view the data at that point. In addition, you can `[Self::restore]` the
|
||||
version to replace the current table with a previous version.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`number`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:297](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L297)
|
||||
45
docs/src/js/classes/VectorColumnOptions.md
Normal file
45
docs/src/js/classes/VectorColumnOptions.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / VectorColumnOptions
|
||||
|
||||
# Class: VectorColumnOptions
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](VectorColumnOptions.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [type](VectorColumnOptions.md#type)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new VectorColumnOptions**(`values?`): [`VectorColumnOptions`](VectorColumnOptions.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `values?` | `Partial`\<[`VectorColumnOptions`](VectorColumnOptions.md)\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorColumnOptions`](VectorColumnOptions.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:49](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L49)
|
||||
|
||||
## Properties
|
||||
|
||||
### type
|
||||
|
||||
• **type**: `Float`\<`Floats`\>
|
||||
|
||||
Vector column type.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:47](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L47)
|
||||
531
docs/src/js/classes/VectorQuery.md
Normal file
531
docs/src/js/classes/VectorQuery.md
Normal file
@@ -0,0 +1,531 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / VectorQuery
|
||||
|
||||
# Class: VectorQuery
|
||||
|
||||
A builder used to construct a vector search
|
||||
|
||||
This builder can be reused to execute the query many times.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- [`QueryBase`](QueryBase.md)\<`NativeVectorQuery`, [`VectorQuery`](VectorQuery.md)\>
|
||||
|
||||
↳ **`VectorQuery`**
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](VectorQuery.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [inner](VectorQuery.md#inner)
|
||||
|
||||
### Methods
|
||||
|
||||
- [[asyncIterator]](VectorQuery.md#[asynciterator])
|
||||
- [bypassVectorIndex](VectorQuery.md#bypassvectorindex)
|
||||
- [column](VectorQuery.md#column)
|
||||
- [distanceType](VectorQuery.md#distancetype)
|
||||
- [execute](VectorQuery.md#execute)
|
||||
- [limit](VectorQuery.md#limit)
|
||||
- [nativeExecute](VectorQuery.md#nativeexecute)
|
||||
- [nprobes](VectorQuery.md#nprobes)
|
||||
- [postfilter](VectorQuery.md#postfilter)
|
||||
- [refineFactor](VectorQuery.md#refinefactor)
|
||||
- [select](VectorQuery.md#select)
|
||||
- [toArray](VectorQuery.md#toarray)
|
||||
- [toArrow](VectorQuery.md#toarrow)
|
||||
- [where](VectorQuery.md#where)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new VectorQuery**(`inner`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `inner` | `VectorQuery` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
#### Overrides
|
||||
|
||||
[QueryBase](QueryBase.md).[constructor](QueryBase.md#constructor)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:189](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L189)
|
||||
|
||||
## Properties
|
||||
|
||||
### inner
|
||||
|
||||
• `Protected` **inner**: `VectorQuery`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[inner](QueryBase.md#inner)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:59](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L59)
|
||||
|
||||
## Methods
|
||||
|
||||
### [asyncIterator]
|
||||
|
||||
▸ **[asyncIterator]**(): `AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[[asyncIterator]](QueryBase.md#[asynciterator])
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:154](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### bypassVectorIndex
|
||||
|
||||
▸ **bypassVectorIndex**(): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
If this is called then any vector index is skipped
|
||||
|
||||
An exhaustive (flat) search will be performed. The query vector will
|
||||
be compared to every vector in the table. At high scales this can be
|
||||
expensive. However, this is often still useful. For example, skipping
|
||||
the vector index can give you ground truth results which you can use to
|
||||
calculate your recall to select an appropriate value for nprobes.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:321](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L321)
|
||||
|
||||
___
|
||||
|
||||
### column
|
||||
|
||||
▸ **column**(`column`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Set the vector column to query
|
||||
|
||||
This controls which column is compared to the query vector supplied in
|
||||
the call to
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `column` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
[Query#nearestTo](Query.md#nearestto)
|
||||
|
||||
This parameter must be specified if the table has more than one column
|
||||
whose data type is a fixed-size-list of floats.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:229](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L229)
|
||||
|
||||
___
|
||||
|
||||
### distanceType
|
||||
|
||||
▸ **distanceType**(`distanceType`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Set the distance metric to use
|
||||
|
||||
When performing a vector search we try and find the "nearest" vectors according
|
||||
to some kind of distance metric. This parameter controls which distance metric to
|
||||
use. See
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `distanceType` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
[IvfPqOptions.distanceType](../interfaces/IvfPqOptions.md#distancetype) for more details on the different
|
||||
distance metrics available.
|
||||
|
||||
Note: if there is a vector index then the distance type used MUST match the distance
|
||||
type used to train the vector index. If this is not done then the results will be
|
||||
invalid.
|
||||
|
||||
By default "l2" is used.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:248](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L248)
|
||||
|
||||
___
|
||||
|
||||
### execute
|
||||
|
||||
▸ **execute**(): [`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
Execute the query and return the results as an
|
||||
|
||||
#### Returns
|
||||
|
||||
[`RecordBatchIterator`](RecordBatchIterator.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
- AsyncIterator
|
||||
of
|
||||
- RecordBatch.
|
||||
|
||||
By default, LanceDb will use many threads to calculate results and, when
|
||||
the result set is large, multiple batches will be processed at one time.
|
||||
This readahead is limited however and backpressure will be applied if this
|
||||
stream is consumed slowly (this constrains the maximum memory used by a
|
||||
single query)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[execute](QueryBase.md#execute)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:149](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L149)
|
||||
|
||||
___
|
||||
|
||||
### limit
|
||||
|
||||
▸ **limit**(`limit`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Set the maximum number of results to return.
|
||||
|
||||
By default, a plain search has no limit. If this method is not
|
||||
called then every valid row from the table will be returned.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `limit` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[limit](QueryBase.md#limit)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:129](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L129)
|
||||
|
||||
___
|
||||
|
||||
### nativeExecute
|
||||
|
||||
▸ **nativeExecute**(): `Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`RecordBatchIterator`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[nativeExecute](QueryBase.md#nativeexecute)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:134](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### nprobes
|
||||
|
||||
▸ **nprobes**(`nprobes`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Set the number of partitions to search (probe)
|
||||
|
||||
This argument is only used when the vector column has an IVF PQ index.
|
||||
If there is no index then this value is ignored.
|
||||
|
||||
The IVF stage of IVF PQ divides the input into partitions (clusters) of
|
||||
related values.
|
||||
|
||||
The partition whose centroids are closest to the query vector will be
|
||||
exhaustiely searched to find matches. This parameter controls how many
|
||||
partitions should be searched.
|
||||
|
||||
Increasing this value will increase the recall of your query but will
|
||||
also increase the latency of your query. The default value is 20. This
|
||||
default is good for many cases but the best value to use will depend on
|
||||
your data and the recall that you need to achieve.
|
||||
|
||||
For best results we recommend tuning this parameter with a benchmark against
|
||||
your actual data to find the smallest possible value that will still give
|
||||
you the desired recall.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `nprobes` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:215](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L215)
|
||||
|
||||
___
|
||||
|
||||
### postfilter
|
||||
|
||||
▸ **postfilter**(): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
If this is called then filtering will happen after the vector search instead of
|
||||
before.
|
||||
|
||||
By default filtering will be performed before the vector search. This is how
|
||||
filtering is typically understood to work. This prefilter step does add some
|
||||
additional latency. Creating a scalar index on the filter column(s) can
|
||||
often improve this latency. However, sometimes a filter is too complex or scalar
|
||||
indices cannot be applied to the column. In these cases postfiltering can be
|
||||
used instead of prefiltering to improve latency.
|
||||
|
||||
Post filtering applies the filter to the results of the vector search. This means
|
||||
we only run the filter on a much smaller set of data. However, it can cause the
|
||||
query to return fewer than `limit` results (or even no results) if none of the nearest
|
||||
results match the filter.
|
||||
|
||||
Post filtering happens during the "refine stage" (described in more detail in
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`See`**
|
||||
|
||||
[VectorQuery#refineFactor](VectorQuery.md#refinefactor)). This means that setting a higher refine
|
||||
factor can often help restore some of the results lost by post filtering.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:307](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L307)
|
||||
|
||||
___
|
||||
|
||||
### refineFactor
|
||||
|
||||
▸ **refineFactor**(`refineFactor`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
A multiplier to control how many additional rows are taken during the refine step
|
||||
|
||||
This argument is only used when the vector column has an IVF PQ index.
|
||||
If there is no index then this value is ignored.
|
||||
|
||||
An IVF PQ index stores compressed (quantized) values. They query vector is compared
|
||||
against these values and, since they are compressed, the comparison is inaccurate.
|
||||
|
||||
This parameter can be used to refine the results. It can improve both improve recall
|
||||
and correct the ordering of the nearest results.
|
||||
|
||||
To refine results LanceDb will first perform an ANN search to find the nearest
|
||||
`limit` * `refine_factor` results. In other words, if `refine_factor` is 3 and
|
||||
`limit` is the default (10) then the first 30 results will be selected. LanceDb
|
||||
then fetches the full, uncompressed, values for these 30 results. The results are
|
||||
then reordered by the true distance and only the nearest 10 are kept.
|
||||
|
||||
Note: there is a difference between calling this method with a value of 1 and never
|
||||
calling this method at all. Calling this method with any value will have an impact
|
||||
on your search latency. When you call this method with a `refine_factor` of 1 then
|
||||
LanceDb still needs to fetch the full, uncompressed, values so that it can potentially
|
||||
reorder the results.
|
||||
|
||||
Note: if this method is NOT called then the distances returned in the _distance column
|
||||
will be approximate distances based on the comparison of the quantized query vector
|
||||
and the quantized result vectors. This can be considerably different than the true
|
||||
distance between the query vector and the actual uncompressed vector.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `refineFactor` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:282](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L282)
|
||||
|
||||
___
|
||||
|
||||
### select
|
||||
|
||||
▸ **select**(`columns`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
Return only the specified columns.
|
||||
|
||||
By default a query will return all columns from the table. However, this can have
|
||||
a very significant impact on latency. LanceDb stores data in a columnar fashion. This
|
||||
means we can finely tune our I/O to select exactly the columns we need.
|
||||
|
||||
As a best practice you should always limit queries to the columns that you need. If you
|
||||
pass in an array of column names then only those columns will be returned.
|
||||
|
||||
You can also use this method to create new "dynamic" columns based on your existing columns.
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `columns` | `string`[] \| `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[select](QueryBase.md#select)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:108](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
### toArray
|
||||
|
||||
▸ **toArray**(): `Promise`\<`unknown`[]\>
|
||||
|
||||
Collect the results as an array of objects.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`unknown`[]\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[toArray](QueryBase.md#toarray)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:169](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L169)
|
||||
|
||||
___
|
||||
|
||||
### toArrow
|
||||
|
||||
▸ **toArrow**(): `Promise`\<`Table`\<`any`\>\>
|
||||
|
||||
Collect the results as an Arrow
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`Table`\<`any`\>\>
|
||||
|
||||
**`See`**
|
||||
|
||||
ArrowTable.
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[toArrow](QueryBase.md#toarrow)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:160](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L160)
|
||||
|
||||
___
|
||||
|
||||
### where
|
||||
|
||||
▸ **where**(`predicate`): [`VectorQuery`](VectorQuery.md)
|
||||
|
||||
A filter statement to be applied to this query.
|
||||
|
||||
The filter should be supplied as an SQL query string. For example:
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `predicate` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`VectorQuery`](VectorQuery.md)
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
x > 10
|
||||
y > 0 AND y < 100
|
||||
x > 5 OR y = 'test'
|
||||
|
||||
Filtering performance can often be improved by creating a scalar index
|
||||
on the filter column(s).
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[QueryBase](QueryBase.md).[where](QueryBase.md#where)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[query.ts:73](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L73)
|
||||
111
docs/src/js/classes/embedding.OpenAIEmbeddingFunction.md
Normal file
111
docs/src/js/classes/embedding.OpenAIEmbeddingFunction.md
Normal file
@@ -0,0 +1,111 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / [embedding](../modules/embedding.md) / OpenAIEmbeddingFunction
|
||||
|
||||
# Class: OpenAIEmbeddingFunction
|
||||
|
||||
[embedding](../modules/embedding.md).OpenAIEmbeddingFunction
|
||||
|
||||
An embedding function that automatically creates vector representation for a given column.
|
||||
|
||||
## Implements
|
||||
|
||||
- [`EmbeddingFunction`](../interfaces/embedding.EmbeddingFunction.md)\<`string`\>
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Constructors
|
||||
|
||||
- [constructor](embedding.OpenAIEmbeddingFunction.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
- [\_modelName](embedding.OpenAIEmbeddingFunction.md#_modelname)
|
||||
- [\_openai](embedding.OpenAIEmbeddingFunction.md#_openai)
|
||||
- [sourceColumn](embedding.OpenAIEmbeddingFunction.md#sourcecolumn)
|
||||
|
||||
### Methods
|
||||
|
||||
- [embed](embedding.OpenAIEmbeddingFunction.md#embed)
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new OpenAIEmbeddingFunction**(`sourceColumn`, `openAIKey`, `modelName?`): [`OpenAIEmbeddingFunction`](embedding.OpenAIEmbeddingFunction.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `sourceColumn` | `string` | `undefined` |
|
||||
| `openAIKey` | `string` | `undefined` |
|
||||
| `modelName` | `string` | `"text-embedding-ada-002"` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`OpenAIEmbeddingFunction`](embedding.OpenAIEmbeddingFunction.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/openai.ts:22](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/openai.ts#L22)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_modelName
|
||||
|
||||
• `Private` `Readonly` **\_modelName**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/openai.ts:20](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/openai.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### \_openai
|
||||
|
||||
• `Private` `Readonly` **\_openai**: `OpenAI`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/openai.ts:19](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/openai.ts#L19)
|
||||
|
||||
___
|
||||
|
||||
### sourceColumn
|
||||
|
||||
• **sourceColumn**: `string`
|
||||
|
||||
The name of the column that will be used as input for the Embedding Function.
|
||||
|
||||
#### Implementation of
|
||||
|
||||
[EmbeddingFunction](../interfaces/embedding.EmbeddingFunction.md).[sourceColumn](../interfaces/embedding.EmbeddingFunction.md#sourcecolumn)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/openai.ts:61](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/openai.ts#L61)
|
||||
|
||||
## Methods
|
||||
|
||||
### embed
|
||||
|
||||
▸ **embed**(`data`): `Promise`\<`number`[][]\>
|
||||
|
||||
Creates a vector representation for the given values.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<`number`[][]\>
|
||||
|
||||
#### Implementation of
|
||||
|
||||
[EmbeddingFunction](../interfaces/embedding.EmbeddingFunction.md).[embed](../interfaces/embedding.EmbeddingFunction.md#embed)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/openai.ts:48](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/openai.ts#L48)
|
||||
43
docs/src/js/enums/WriteMode.md
Normal file
43
docs/src/js/enums/WriteMode.md
Normal file
@@ -0,0 +1,43 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / WriteMode
|
||||
|
||||
# Enumeration: WriteMode
|
||||
|
||||
Write mode for writing a table.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Enumeration Members
|
||||
|
||||
- [Append](WriteMode.md#append)
|
||||
- [Create](WriteMode.md#create)
|
||||
- [Overwrite](WriteMode.md#overwrite)
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
### Append
|
||||
|
||||
• **Append** = ``"Append"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:69
|
||||
|
||||
___
|
||||
|
||||
### Create
|
||||
|
||||
• **Create** = ``"Create"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:68
|
||||
|
||||
___
|
||||
|
||||
### Overwrite
|
||||
|
||||
• **Overwrite** = ``"Overwrite"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:70
|
||||
37
docs/src/js/interfaces/AddColumnsSql.md
Normal file
37
docs/src/js/interfaces/AddColumnsSql.md
Normal file
@@ -0,0 +1,37 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / AddColumnsSql
|
||||
|
||||
# Interface: AddColumnsSql
|
||||
|
||||
A definition of a new column to add to a table.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [name](AddColumnsSql.md#name)
|
||||
- [valueSql](AddColumnsSql.md#valuesql)
|
||||
|
||||
## Properties
|
||||
|
||||
### name
|
||||
|
||||
• **name**: `string`
|
||||
|
||||
The name of the new column.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:43
|
||||
|
||||
___
|
||||
|
||||
### valueSql
|
||||
|
||||
• **valueSql**: `string`
|
||||
|
||||
The values to populate the new column with, as a SQL expression.
|
||||
The expression can reference other columns in the table.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:48
|
||||
25
docs/src/js/interfaces/AddDataOptions.md
Normal file
25
docs/src/js/interfaces/AddDataOptions.md
Normal file
@@ -0,0 +1,25 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / AddDataOptions
|
||||
|
||||
# Interface: AddDataOptions
|
||||
|
||||
Options for adding data to a table.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [mode](AddDataOptions.md#mode)
|
||||
|
||||
## Properties
|
||||
|
||||
### mode
|
||||
|
||||
• **mode**: ``"append"`` \| ``"overwrite"``
|
||||
|
||||
If "append" (the default) then the new data will be added to the table
|
||||
|
||||
If "overwrite" then the new data will replace the existing data in the table.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:36](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L36)
|
||||
56
docs/src/js/interfaces/ColumnAlteration.md
Normal file
56
docs/src/js/interfaces/ColumnAlteration.md
Normal file
@@ -0,0 +1,56 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / ColumnAlteration
|
||||
|
||||
# Interface: ColumnAlteration
|
||||
|
||||
A definition of a column alteration. The alteration changes the column at
|
||||
`path` to have the new name `name`, to be nullable if `nullable` is true,
|
||||
and to have the data type `data_type`. At least one of `rename` or `nullable`
|
||||
must be provided.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [nullable](ColumnAlteration.md#nullable)
|
||||
- [path](ColumnAlteration.md#path)
|
||||
- [rename](ColumnAlteration.md#rename)
|
||||
|
||||
## Properties
|
||||
|
||||
### nullable
|
||||
|
||||
• `Optional` **nullable**: `boolean`
|
||||
|
||||
Set the new nullability. Note that a nullable column cannot be made non-nullable.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:38
|
||||
|
||||
___
|
||||
|
||||
### path
|
||||
|
||||
• **path**: `string`
|
||||
|
||||
The path to the column to alter. This is a dot-separated path to the column.
|
||||
If it is a top-level column then it is just the name of the column. If it is
|
||||
a nested column then it is the path to the column, e.g. "a.b.c" for a column
|
||||
`c` nested inside a column `b` nested inside a column `a`.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:31
|
||||
|
||||
___
|
||||
|
||||
### rename
|
||||
|
||||
• `Optional` **rename**: `string`
|
||||
|
||||
The new name of the column. If not provided then the name will not be changed.
|
||||
This must be distinct from the names of all other columns in the table.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:36
|
||||
51
docs/src/js/interfaces/ConnectionOptions.md
Normal file
51
docs/src/js/interfaces/ConnectionOptions.md
Normal file
@@ -0,0 +1,51 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / ConnectionOptions
|
||||
|
||||
# Interface: ConnectionOptions
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [apiKey](ConnectionOptions.md#apikey)
|
||||
- [hostOverride](ConnectionOptions.md#hostoverride)
|
||||
- [readConsistencyInterval](ConnectionOptions.md#readconsistencyinterval)
|
||||
|
||||
## Properties
|
||||
|
||||
### apiKey
|
||||
|
||||
• `Optional` **apiKey**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:51
|
||||
|
||||
___
|
||||
|
||||
### hostOverride
|
||||
|
||||
• `Optional` **hostOverride**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:52
|
||||
|
||||
___
|
||||
|
||||
### readConsistencyInterval
|
||||
|
||||
• `Optional` **readConsistencyInterval**: `number`
|
||||
|
||||
(For LanceDB OSS only): The interval, in seconds, at which to check for
|
||||
updates to the table from other processes. If None, then consistency is not
|
||||
checked. For performance reasons, this is the default. For strong
|
||||
consistency, set this to zero seconds. Then every read will check for
|
||||
updates from other processes. As a compromise, you can set this to a
|
||||
non-zero value for eventual consistency. If more than that interval
|
||||
has passed since the last check, then the table will be checked for updates.
|
||||
Note: this consistency only applies to read operations. Write operations are
|
||||
always consistent.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:64
|
||||
41
docs/src/js/interfaces/CreateTableOptions.md
Normal file
41
docs/src/js/interfaces/CreateTableOptions.md
Normal file
@@ -0,0 +1,41 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / CreateTableOptions
|
||||
|
||||
# Interface: CreateTableOptions
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [existOk](CreateTableOptions.md#existok)
|
||||
- [mode](CreateTableOptions.md#mode)
|
||||
|
||||
## Properties
|
||||
|
||||
### existOk
|
||||
|
||||
• **existOk**: `boolean`
|
||||
|
||||
If this is true and the table already exists and the mode is "create"
|
||||
then no error will be raised.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:35](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
### mode
|
||||
|
||||
• **mode**: ``"overwrite"`` \| ``"create"``
|
||||
|
||||
The mode to use when creating the table.
|
||||
|
||||
If this is set to "create" and the table already exists then either
|
||||
an error will be thrown or, if existOk is true, then nothing will
|
||||
happen. Any provided data will be ignored.
|
||||
|
||||
If this is set to "overwrite" then any existing table will be replaced.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:30](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L30)
|
||||
7
docs/src/js/interfaces/ExecutableQuery.md
Normal file
7
docs/src/js/interfaces/ExecutableQuery.md
Normal file
@@ -0,0 +1,7 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / ExecutableQuery
|
||||
|
||||
# Interface: ExecutableQuery
|
||||
|
||||
An interface for a query that can be executed
|
||||
|
||||
Supported by all query types
|
||||
39
docs/src/js/interfaces/IndexConfig.md
Normal file
39
docs/src/js/interfaces/IndexConfig.md
Normal file
@@ -0,0 +1,39 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / IndexConfig
|
||||
|
||||
# Interface: IndexConfig
|
||||
|
||||
A description of an index currently configured on a column
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [columns](IndexConfig.md#columns)
|
||||
- [indexType](IndexConfig.md#indextype)
|
||||
|
||||
## Properties
|
||||
|
||||
### columns
|
||||
|
||||
• **columns**: `string`[]
|
||||
|
||||
The columns in the index
|
||||
|
||||
Currently this is always an array of size 1. In the future there may
|
||||
be more columns to represent composite indices.
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:16
|
||||
|
||||
___
|
||||
|
||||
### indexType
|
||||
|
||||
• **indexType**: `string`
|
||||
|
||||
The type of the index
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:9
|
||||
48
docs/src/js/interfaces/IndexOptions.md
Normal file
48
docs/src/js/interfaces/IndexOptions.md
Normal file
@@ -0,0 +1,48 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / IndexOptions
|
||||
|
||||
# Interface: IndexOptions
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [config](IndexOptions.md#config)
|
||||
- [replace](IndexOptions.md#replace)
|
||||
|
||||
## Properties
|
||||
|
||||
### config
|
||||
|
||||
• `Optional` **config**: [`Index`](../classes/Index.md)
|
||||
|
||||
Advanced index configuration
|
||||
|
||||
This option allows you to specify a specfic index to create and also
|
||||
allows you to pass in configuration for training the index.
|
||||
|
||||
See the static methods on Index for details on the various index types.
|
||||
|
||||
If this is not supplied then column data type(s) and column statistics
|
||||
will be used to determine the most useful kind of index to create.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:192](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L192)
|
||||
|
||||
___
|
||||
|
||||
### replace
|
||||
|
||||
• `Optional` **replace**: `boolean`
|
||||
|
||||
Whether to replace the existing index
|
||||
|
||||
If this is false, and another index already exists on the same columns
|
||||
and the same name, then an error will be returned. This is true even if
|
||||
that index is out of date.
|
||||
|
||||
The default is true
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:202](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L202)
|
||||
144
docs/src/js/interfaces/IvfPqOptions.md
Normal file
144
docs/src/js/interfaces/IvfPqOptions.md
Normal file
@@ -0,0 +1,144 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / IvfPqOptions
|
||||
|
||||
# Interface: IvfPqOptions
|
||||
|
||||
Options to create an `IVF_PQ` index
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [distanceType](IvfPqOptions.md#distancetype)
|
||||
- [maxIterations](IvfPqOptions.md#maxiterations)
|
||||
- [numPartitions](IvfPqOptions.md#numpartitions)
|
||||
- [numSubVectors](IvfPqOptions.md#numsubvectors)
|
||||
- [sampleRate](IvfPqOptions.md#samplerate)
|
||||
|
||||
## Properties
|
||||
|
||||
### distanceType
|
||||
|
||||
• `Optional` **distanceType**: ``"l2"`` \| ``"cosine"`` \| ``"dot"``
|
||||
|
||||
Distance type to use to build the index.
|
||||
|
||||
Default value is "l2".
|
||||
|
||||
This is used when training the index to calculate the IVF partitions
|
||||
(vectors are grouped in partitions with similar vectors according to this
|
||||
distance type) and to calculate a subvector's code during quantization.
|
||||
|
||||
The distance type used to train an index MUST match the distance type used
|
||||
to search the index. Failure to do so will yield inaccurate results.
|
||||
|
||||
The following distance types are available:
|
||||
|
||||
"l2" - Euclidean distance. This is a very common distance metric that
|
||||
accounts for both magnitude and direction when determining the distance
|
||||
between vectors. L2 distance has a range of [0, ∞).
|
||||
|
||||
"cosine" - Cosine distance. Cosine distance is a distance metric
|
||||
calculated from the cosine similarity between two vectors. Cosine
|
||||
similarity is a measure of similarity between two non-zero vectors of an
|
||||
inner product space. It is defined to equal the cosine of the angle
|
||||
between them. Unlike L2, the cosine distance is not affected by the
|
||||
magnitude of the vectors. Cosine distance has a range of [0, 2].
|
||||
|
||||
Note: the cosine distance is undefined when one (or both) of the vectors
|
||||
are all zeros (there is no direction). These vectors are invalid and may
|
||||
never be returned from a vector search.
|
||||
|
||||
"dot" - Dot product. Dot distance is the dot product of two vectors. Dot
|
||||
distance has a range of (-∞, ∞). If the vectors are normalized (i.e. their
|
||||
L2 norm is 1), then dot distance is equivalent to the cosine distance.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:83](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L83)
|
||||
|
||||
___
|
||||
|
||||
### maxIterations
|
||||
|
||||
• `Optional` **maxIterations**: `number`
|
||||
|
||||
Max iteration to train IVF kmeans.
|
||||
|
||||
When training an IVF PQ index we use kmeans to calculate the partitions. This parameter
|
||||
controls how many iterations of kmeans to run.
|
||||
|
||||
Increasing this might improve the quality of the index but in most cases these extra
|
||||
iterations have diminishing returns.
|
||||
|
||||
The default value is 50.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:96](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L96)
|
||||
|
||||
___
|
||||
|
||||
### numPartitions
|
||||
|
||||
• `Optional` **numPartitions**: `number`
|
||||
|
||||
The number of IVF partitions to create.
|
||||
|
||||
This value should generally scale with the number of rows in the dataset.
|
||||
By default the number of partitions is the square root of the number of
|
||||
rows.
|
||||
|
||||
If this value is too large then the first part of the search (picking the
|
||||
right partition) will be slow. If this value is too small then the second
|
||||
part of the search (searching within a partition) will be slow.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:32](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### numSubVectors
|
||||
|
||||
• `Optional` **numSubVectors**: `number`
|
||||
|
||||
Number of sub-vectors of PQ.
|
||||
|
||||
This value controls how much the vector is compressed during the quantization step.
|
||||
The more sub vectors there are the less the vector is compressed. The default is
|
||||
the dimension of the vector divided by 16. If the dimension is not evenly divisible
|
||||
by 16 we use the dimension divded by 8.
|
||||
|
||||
The above two cases are highly preferred. Having 8 or 16 values per subvector allows
|
||||
us to use efficient SIMD instructions.
|
||||
|
||||
If the dimension is not visible by 8 then we use 1 subvector. This is not ideal and
|
||||
will likely result in poor performance.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:48](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### sampleRate
|
||||
|
||||
• `Optional` **sampleRate**: `number`
|
||||
|
||||
The number of vectors, per partition, to sample when training IVF kmeans.
|
||||
|
||||
When an IVF PQ index is trained, we need to calculate partitions. These are groups
|
||||
of vectors that are similar to each other. To do this we use an algorithm called kmeans.
|
||||
|
||||
Running kmeans on a large dataset can be slow. To speed this up we run kmeans on a
|
||||
random sample of the data. This parameter controls the size of the sample. The total
|
||||
number of vectors used to train the index is `sample_rate * num_partitions`.
|
||||
|
||||
Increasing this value might improve the quality of the index but in most cases the
|
||||
default should be sufficient.
|
||||
|
||||
The default value is 256.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices.ts:113](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L113)
|
||||
38
docs/src/js/interfaces/TableNamesOptions.md
Normal file
38
docs/src/js/interfaces/TableNamesOptions.md
Normal file
@@ -0,0 +1,38 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / TableNamesOptions
|
||||
|
||||
# Interface: TableNamesOptions
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [limit](TableNamesOptions.md#limit)
|
||||
- [startAfter](TableNamesOptions.md#startafter)
|
||||
|
||||
## Properties
|
||||
|
||||
### limit
|
||||
|
||||
• `Optional` **limit**: `number`
|
||||
|
||||
An optional limit to the number of results to return.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:48](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### startAfter
|
||||
|
||||
• `Optional` **startAfter**: `string`
|
||||
|
||||
If present, only return names that come lexicographically after the
|
||||
supplied value.
|
||||
|
||||
This can be combined with limit to implement pagination by setting this to
|
||||
the last table name from the previous page.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[connection.ts:46](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L46)
|
||||
28
docs/src/js/interfaces/UpdateOptions.md
Normal file
28
docs/src/js/interfaces/UpdateOptions.md
Normal file
@@ -0,0 +1,28 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / UpdateOptions
|
||||
|
||||
# Interface: UpdateOptions
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [where](UpdateOptions.md#where)
|
||||
|
||||
## Properties
|
||||
|
||||
### where
|
||||
|
||||
• **where**: `string`
|
||||
|
||||
A filter that limits the scope of the update.
|
||||
|
||||
This should be an SQL filter expression.
|
||||
|
||||
Only rows that satisfy the expression will be updated.
|
||||
|
||||
For example, this could be 'my_col == 0' to replace all instances
|
||||
of 0 in a column with some other default value.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[table.ts:50](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L50)
|
||||
21
docs/src/js/interfaces/WriteOptions.md
Normal file
21
docs/src/js/interfaces/WriteOptions.md
Normal file
@@ -0,0 +1,21 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / WriteOptions
|
||||
|
||||
# Interface: WriteOptions
|
||||
|
||||
Write options when creating a Table.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [mode](WriteOptions.md#mode)
|
||||
|
||||
## Properties
|
||||
|
||||
### mode
|
||||
|
||||
• `Optional` **mode**: [`WriteMode`](../enums/WriteMode.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
native.d.ts:74
|
||||
129
docs/src/js/interfaces/embedding.EmbeddingFunction.md
Normal file
129
docs/src/js/interfaces/embedding.EmbeddingFunction.md
Normal file
@@ -0,0 +1,129 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / [embedding](../modules/embedding.md) / EmbeddingFunction
|
||||
|
||||
# Interface: EmbeddingFunction\<T\>
|
||||
|
||||
[embedding](../modules/embedding.md).EmbeddingFunction
|
||||
|
||||
An embedding function that automatically creates vector representation for a given column.
|
||||
|
||||
## Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
## Implemented by
|
||||
|
||||
- [`OpenAIEmbeddingFunction`](../classes/embedding.OpenAIEmbeddingFunction.md)
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [destColumn](embedding.EmbeddingFunction.md#destcolumn)
|
||||
- [embed](embedding.EmbeddingFunction.md#embed)
|
||||
- [embeddingDataType](embedding.EmbeddingFunction.md#embeddingdatatype)
|
||||
- [embeddingDimension](embedding.EmbeddingFunction.md#embeddingdimension)
|
||||
- [excludeSource](embedding.EmbeddingFunction.md#excludesource)
|
||||
- [sourceColumn](embedding.EmbeddingFunction.md#sourcecolumn)
|
||||
|
||||
## Properties
|
||||
|
||||
### destColumn
|
||||
|
||||
• `Optional` **destColumn**: `string`
|
||||
|
||||
The name of the column that will contain the embedding
|
||||
|
||||
By default this is "vector"
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:49](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### embed
|
||||
|
||||
• **embed**: (`data`: `T`[]) => `Promise`\<`number`[][]\>
|
||||
|
||||
Creates a vector representation for the given values.
|
||||
|
||||
#### Type declaration
|
||||
|
||||
▸ (`data`): `Promise`\<`number`[][]\>
|
||||
|
||||
Creates a vector representation for the given values.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `T`[] |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`\<`number`[][]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:62](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### embeddingDataType
|
||||
|
||||
• `Optional` **embeddingDataType**: `Float`\<`Floats`\>
|
||||
|
||||
The data type of the embedding
|
||||
|
||||
The embedding function should return `number`. This will be converted into
|
||||
an Arrow float array. By default this will be Float32 but this property can
|
||||
be used to control the conversion.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:33](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
### embeddingDimension
|
||||
|
||||
• `Optional` **embeddingDimension**: `number`
|
||||
|
||||
The dimension of the embedding
|
||||
|
||||
This is optional, normally this can be determined by looking at the results of
|
||||
`embed`. If this is not specified, and there is an attempt to apply the embedding
|
||||
to an empty table, then that process will fail.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:42](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### excludeSource
|
||||
|
||||
• `Optional` **excludeSource**: `boolean`
|
||||
|
||||
Should the source column be excluded from the resulting table
|
||||
|
||||
By default the source column is included. Set this to true and
|
||||
only the embedding will be stored.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:57](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### sourceColumn
|
||||
|
||||
• **sourceColumn**: `string`
|
||||
|
||||
The name of the column that will be used as input for the Embedding Function.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:24](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L24)
|
||||
209
docs/src/js/modules.md
Normal file
209
docs/src/js/modules.md
Normal file
@@ -0,0 +1,209 @@
|
||||
[@lancedb/lancedb](README.md) / Exports
|
||||
|
||||
# @lancedb/lancedb
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Namespaces
|
||||
|
||||
- [embedding](modules/embedding.md)
|
||||
|
||||
### Enumerations
|
||||
|
||||
- [WriteMode](enums/WriteMode.md)
|
||||
|
||||
### Classes
|
||||
|
||||
- [Connection](classes/Connection.md)
|
||||
- [Index](classes/Index.md)
|
||||
- [MakeArrowTableOptions](classes/MakeArrowTableOptions.md)
|
||||
- [Query](classes/Query.md)
|
||||
- [QueryBase](classes/QueryBase.md)
|
||||
- [RecordBatchIterator](classes/RecordBatchIterator.md)
|
||||
- [Table](classes/Table.md)
|
||||
- [VectorColumnOptions](classes/VectorColumnOptions.md)
|
||||
- [VectorQuery](classes/VectorQuery.md)
|
||||
|
||||
### Interfaces
|
||||
|
||||
- [AddColumnsSql](interfaces/AddColumnsSql.md)
|
||||
- [AddDataOptions](interfaces/AddDataOptions.md)
|
||||
- [ColumnAlteration](interfaces/ColumnAlteration.md)
|
||||
- [ConnectionOptions](interfaces/ConnectionOptions.md)
|
||||
- [CreateTableOptions](interfaces/CreateTableOptions.md)
|
||||
- [ExecutableQuery](interfaces/ExecutableQuery.md)
|
||||
- [IndexConfig](interfaces/IndexConfig.md)
|
||||
- [IndexOptions](interfaces/IndexOptions.md)
|
||||
- [IvfPqOptions](interfaces/IvfPqOptions.md)
|
||||
- [TableNamesOptions](interfaces/TableNamesOptions.md)
|
||||
- [UpdateOptions](interfaces/UpdateOptions.md)
|
||||
- [WriteOptions](interfaces/WriteOptions.md)
|
||||
|
||||
### Type Aliases
|
||||
|
||||
- [Data](modules.md#data)
|
||||
|
||||
### Functions
|
||||
|
||||
- [connect](modules.md#connect)
|
||||
- [makeArrowTable](modules.md#makearrowtable)
|
||||
|
||||
## Type Aliases
|
||||
|
||||
### Data
|
||||
|
||||
Ƭ **Data**: `Record`\<`string`, `unknown`\>[] \| `ArrowTable`
|
||||
|
||||
Data type accepted by NodeJS SDK
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:40](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L40)
|
||||
|
||||
## Functions
|
||||
|
||||
### connect
|
||||
|
||||
▸ **connect**(`uri`, `opts?`): `Promise`\<[`Connection`](classes/Connection.md)\>
|
||||
|
||||
Connect to a LanceDB instance at the given URI.
|
||||
|
||||
Accpeted formats:
|
||||
|
||||
- `/path/to/database` - local database
|
||||
- `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
|
||||
- `db://host:port` - remote database (LanceDB cloud)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `uri` | `string` | The uri of the database. If the database uri starts with `db://` then it connects to a remote database. |
|
||||
| `opts?` | `Partial`\<[`ConnectionOptions`](interfaces/ConnectionOptions.md)\> | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`\<[`Connection`](classes/Connection.md)\>
|
||||
|
||||
**`See`**
|
||||
|
||||
[ConnectionOptions](interfaces/ConnectionOptions.md) for more details on the URI format.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[index.ts:62](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/index.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### makeArrowTable
|
||||
|
||||
▸ **makeArrowTable**(`data`, `options?`): `ArrowTable`
|
||||
|
||||
An enhanced version of the makeTable function from Apache Arrow
|
||||
that supports nested fields and embeddings columns.
|
||||
|
||||
(typically you do not need to call this function. It will be called automatically
|
||||
when creating a table or adding data to it)
|
||||
|
||||
This function converts an array of Record<String, any> (row-major JS objects)
|
||||
to an Arrow Table (a columnar structure)
|
||||
|
||||
Note that it currently does not support nulls.
|
||||
|
||||
If a schema is provided then it will be used to determine the resulting array
|
||||
types. Fields will also be reordered to fit the order defined by the schema.
|
||||
|
||||
If a schema is not provided then the types will be inferred and the field order
|
||||
will be controlled by the order of properties in the first record. If a type
|
||||
is inferred it will always be nullable.
|
||||
|
||||
If the input is empty then a schema must be provided to create an empty table.
|
||||
|
||||
When a schema is not specified then data types will be inferred. The inference
|
||||
rules are as follows:
|
||||
|
||||
- boolean => Bool
|
||||
- number => Float64
|
||||
- String => Utf8
|
||||
- Buffer => Binary
|
||||
- Record<String, any> => Struct
|
||||
- Array<any> => List
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `Record`\<`string`, `unknown`\>[] |
|
||||
| `options?` | `Partial`\<[`MakeArrowTableOptions`](classes/MakeArrowTableOptions.md)\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ArrowTable`
|
||||
|
||||
**`Example`**
|
||||
|
||||
```ts
|
||||
import { fromTableToBuffer, makeArrowTable } from "../arrow";
|
||||
import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
|
||||
|
||||
const schema = new Schema([
|
||||
new Field("a", new Int32()),
|
||||
new Field("b", new Float32()),
|
||||
new Field("c", new FixedSizeList(3, new Field("item", new Float16()))),
|
||||
]);
|
||||
const table = makeArrowTable([
|
||||
{ a: 1, b: 2, c: [1, 2, 3] },
|
||||
{ a: 4, b: 5, c: [4, 5, 6] },
|
||||
{ a: 7, b: 8, c: [7, 8, 9] },
|
||||
], { schema });
|
||||
```
|
||||
|
||||
By default it assumes that the column named `vector` is a vector column
|
||||
and it will be converted into a fixed size list array of type float32.
|
||||
The `vectorColumns` option can be used to support other vector column
|
||||
names and data types.
|
||||
|
||||
```ts
|
||||
|
||||
const schema = new Schema([
|
||||
new Field("a", new Float64()),
|
||||
new Field("b", new Float64()),
|
||||
new Field(
|
||||
"vector",
|
||||
new FixedSizeList(3, new Field("item", new Float32()))
|
||||
),
|
||||
]);
|
||||
const table = makeArrowTable([
|
||||
{ a: 1, b: 2, vector: [1, 2, 3] },
|
||||
{ a: 4, b: 5, vector: [4, 5, 6] },
|
||||
{ a: 7, b: 8, vector: [7, 8, 9] },
|
||||
]);
|
||||
assert.deepEqual(table.schema, schema);
|
||||
```
|
||||
|
||||
You can specify the vector column types and names using the options as well
|
||||
|
||||
```typescript
|
||||
|
||||
const schema = new Schema([
|
||||
new Field('a', new Float64()),
|
||||
new Field('b', new Float64()),
|
||||
new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
|
||||
new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
|
||||
]);
|
||||
const table = makeArrowTable([
|
||||
{ a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
|
||||
{ a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
|
||||
{ a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
|
||||
], {
|
||||
vectorColumns: {
|
||||
vec1: { type: new Float16() },
|
||||
vec2: { type: new Float16() }
|
||||
}
|
||||
}
|
||||
assert.deepEqual(table.schema, schema)
|
||||
```
|
||||
|
||||
#### Defined in
|
||||
|
||||
[arrow.ts:197](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L197)
|
||||
45
docs/src/js/modules/embedding.md
Normal file
45
docs/src/js/modules/embedding.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / embedding
|
||||
|
||||
# Namespace: embedding
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Classes
|
||||
|
||||
- [OpenAIEmbeddingFunction](../classes/embedding.OpenAIEmbeddingFunction.md)
|
||||
|
||||
### Interfaces
|
||||
|
||||
- [EmbeddingFunction](../interfaces/embedding.EmbeddingFunction.md)
|
||||
|
||||
### Functions
|
||||
|
||||
- [isEmbeddingFunction](embedding.md#isembeddingfunction)
|
||||
|
||||
## Functions
|
||||
|
||||
### isEmbeddingFunction
|
||||
|
||||
▸ **isEmbeddingFunction**\<`T`\>(`value`): value is EmbeddingFunction\<T\>
|
||||
|
||||
Test if the input seems to be an embedding function
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `value` | `unknown` |
|
||||
|
||||
#### Returns
|
||||
|
||||
value is EmbeddingFunction\<T\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[embedding/embedding_function.ts:66](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L66)
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install --quiet openai datasets \n",
|
||||
"!pip install --quiet openai datasets\n",
|
||||
"!pip install --quiet -U lancedb"
|
||||
]
|
||||
},
|
||||
@@ -213,7 +213,7 @@
|
||||
"if \"OPENAI_API_KEY\" not in os.environ:\n",
|
||||
" # OR set the key here as a variable\n",
|
||||
" os.environ[\"OPENAI_API_KEY\"] = \"sk-...\"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"client = OpenAI()\n",
|
||||
"assert len(client.models.list().data) > 0"
|
||||
]
|
||||
@@ -234,9 +234,12 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def embed_func(c): \n",
|
||||
"def embed_func(c):\n",
|
||||
" rs = client.embeddings.create(input=c, model=\"text-embedding-ada-002\")\n",
|
||||
" return [rs.data[0].embedding]"
|
||||
" return [\n",
|
||||
" data.embedding\n",
|
||||
" for data in rs.data\n",
|
||||
" ]"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -514,7 +517,7 @@
|
||||
" prompt_start +\n",
|
||||
" \"\\n\\n---\\n\\n\".join(context.text) +\n",
|
||||
" prompt_end\n",
|
||||
" ) \n",
|
||||
" )\n",
|
||||
" return prompt"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -24,7 +24,8 @@ data = [
|
||||
table = db.create_table("pd_table", data=data)
|
||||
```
|
||||
|
||||
To query the table, first call `to_lance` to convert the table to a "dataset", which is an object that can be queried by DuckDB. Then all you need to do is reference that dataset by the same name in your SQL query.
|
||||
The `to_lance` method converts the LanceDB table to a `LanceDataset`, which is accessible to DuckDB through the Arrow compatibility layer.
|
||||
To query the resulting Lance dataset in DuckDB, all you need to do is reference the dataset by the same name in your SQL query.
|
||||
|
||||
```python
|
||||
import duckdb
|
||||
|
||||
@@ -72,4 +72,4 @@ You can specify the type of scores you want the reranker to return. The followin
|
||||
|`return_score`| Status | Description |
|
||||
| --- | --- | --- |
|
||||
| `relevance` | ✅ Supported | Returns only have the `_relevance_score` column |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
@@ -68,4 +68,4 @@ You can specify the type of scores you want the reranker to return. The followin
|
||||
|`return_score`| Status | Description |
|
||||
| --- | --- | --- |
|
||||
| `relevance` | ✅ Supported | Returns only have the `_relevance_score` column |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
@@ -67,4 +67,4 @@ You can specify the type of scores you want the reranker to return. The followin
|
||||
|`return_score`| Status | Description |
|
||||
| --- | --- | --- |
|
||||
| `relevance` | ✅ Supported | Returns only have the `_relevance_score` column |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
@@ -14,24 +14,24 @@ class MyReranker(Reranker):
|
||||
super().__init__(return_score)
|
||||
self.param1 = param1
|
||||
self.param2 = param2
|
||||
|
||||
|
||||
def rerank_hybrid(self, query: str, vector_results: pa.Table, fts_results: pa.Table):
|
||||
# Use the built-in merging function
|
||||
combined_result = self.merge_results(vector_results, fts_results)
|
||||
|
||||
|
||||
# Do something with the combined results
|
||||
# ...
|
||||
|
||||
# Return the combined results
|
||||
return combined_result
|
||||
|
||||
|
||||
def rerank_vector(self, query: str, vector_results: pa.Table):
|
||||
# Do something with the vector results
|
||||
# ...
|
||||
|
||||
# Return the vector results
|
||||
return vector_results
|
||||
|
||||
|
||||
def rerank_fts(self, query: str, fts_results: pa.Table):
|
||||
# Do something with the FTS results
|
||||
# ...
|
||||
@@ -63,7 +63,7 @@ class ModifiedCohereReranker(CohereReranker):
|
||||
df = df.query("not text.str.contains(@filter)")
|
||||
|
||||
return pa.Table.from_pandas(df)
|
||||
|
||||
|
||||
def rerank_vector(self, query: str, vector_results: pa.Table)-> pa.Table:
|
||||
vector_results = super().rerank_vector(query, vector_results)
|
||||
df = vector_results.to_pandas()
|
||||
@@ -71,7 +71,7 @@ class ModifiedCohereReranker(CohereReranker):
|
||||
df = df.query("not text.str.contains(@filter)")
|
||||
|
||||
return pa.Table.from_pandas(df)
|
||||
|
||||
|
||||
def rerank_fts(self, query: str, fts_results: pa.Table)-> pa.Table:
|
||||
fts_results = super().rerank_fts(query, fts_results)
|
||||
df = fts_results.to_pandas()
|
||||
@@ -85,5 +85,4 @@ class ModifiedCohereReranker(CohereReranker):
|
||||
!!! tip
|
||||
The `vector_results` and `fts_results` are pyarrow tables. Lean more about pyarrow tables [here](https://arrow.apache.org/docs/python). It can be convered to other data types like pandas dataframe, pydict, pylist etc.
|
||||
|
||||
For example, You can convert them to pandas dataframes using `to_pandas()` method and perform any operations you want. After you are done, you can convert the dataframe back to pyarrow table using `pa.Table.from_pandas()` method and return it.
|
||||
|
||||
For example, You can convert them to pandas dataframes using `to_pandas()` method and perform any operations you want. After you are done, you can convert the dataframe back to pyarrow table using `pa.Table.from_pandas()` method and return it.
|
||||
@@ -57,5 +57,4 @@ LanceDB comes with some built-in rerankers. Here are some of the rerankers that
|
||||
|
||||
## Creating Custom Rerankers
|
||||
|
||||
LanceDB also you to create custom rerankers by extending the base `Reranker` class. The custom reranker should implement the `rerank` method that takes a list of search results and returns a reranked list of search results. This is covered in more detail in the [Creating Custom Rerankers](./custom_reranker.md) section.
|
||||
|
||||
LanceDB also you to create custom rerankers by extending the base `Reranker` class. The custom reranker should implement the `rerank` method that takes a list of search results and returns a reranked list of search results. This is covered in more detail in the [Creating Custom Rerankers](./custom_reranker.md) section.
|
||||
@@ -49,4 +49,4 @@ You can specify the type of scores you want the reranker to return. The followin
|
||||
|`return_score`| Status | Description |
|
||||
| --- | --- | --- |
|
||||
| `relevance` | ✅ Supported | Returns only have the `_relevance_score` column |
|
||||
| `all` | ✅ Supported | Returns have vector(`_distance`) and FTS(`score`) along with Hybrid Search score(`_distance`) |
|
||||
| `all` | ✅ Supported | Returns have vector(`_distance`) and FTS(`score`) along with Hybrid Search score(`_distance`) |
|
||||
@@ -70,4 +70,4 @@ You can specify the type of scores you want the reranker to return. The followin
|
||||
|`return_score`| Status | Description |
|
||||
| --- | --- | --- |
|
||||
| `relevance` | ✅ Supported | Returns only have the `_relevance_score` column |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
| `all` | ✅ Supported | Returns have FTS(`score`) along with Hybrid Search score(`_relevance_score`) |
|
||||
@@ -66,6 +66,7 @@ Currently, Lance supports a growing list of SQL expressions.
|
||||
- `LIKE`, `NOT LIKE`
|
||||
- `CAST`
|
||||
- `regexp_match(column, pattern)`
|
||||
- [DataFusion Functions](https://arrow.apache.org/datafusion/user-guide/sql/scalar_functions.html)
|
||||
|
||||
For example, the following filter string is acceptable:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import glob
|
||||
from typing import Iterator
|
||||
from typing import Iterator, List
|
||||
from pathlib import Path
|
||||
|
||||
glob_string = "../src/**/*.md"
|
||||
@@ -51,11 +51,24 @@ def yield_lines(lines: Iterator[str], prefix: str, suffix: str):
|
||||
yield line[strip_length:]
|
||||
|
||||
|
||||
def wrap_async(lines: List[str]) -> List[str]:
|
||||
# Indent all the lines
|
||||
lines = [" " + line for line in lines]
|
||||
# Put all lines in `async def main():`
|
||||
lines = ["async def main():\n"] + lines
|
||||
# Put `import asyncio\n asyncio.run(main())` at the end
|
||||
lines = lines + ["\n", "import asyncio\n", "asyncio.run(main())\n"]
|
||||
return lines
|
||||
|
||||
|
||||
for file in filter(lambda file: file not in excluded_files, files):
|
||||
with open(file, "r") as f:
|
||||
lines = list(yield_lines(iter(f), "```", "```"))
|
||||
|
||||
if len(lines) > 0:
|
||||
if any("await" in line for line in lines):
|
||||
lines = wrap_async(lines)
|
||||
|
||||
print(lines)
|
||||
out_path = (
|
||||
Path(python_folder)
|
||||
|
||||
50
node/package-lock.json
generated
50
node/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vectordb",
|
||||
"version": "0.4.14",
|
||||
"version": "0.4.19",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "vectordb",
|
||||
"version": "0.4.14",
|
||||
"version": "0.4.19",
|
||||
"cpu": [
|
||||
"x64",
|
||||
"arm64"
|
||||
@@ -52,11 +52,11 @@
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@lancedb/vectordb-darwin-arm64": "0.4.14",
|
||||
"@lancedb/vectordb-darwin-x64": "0.4.14",
|
||||
"@lancedb/vectordb-linux-arm64-gnu": "0.4.14",
|
||||
"@lancedb/vectordb-linux-x64-gnu": "0.4.14",
|
||||
"@lancedb/vectordb-win32-x64-msvc": "0.4.14"
|
||||
"@lancedb/vectordb-darwin-arm64": "0.4.19",
|
||||
"@lancedb/vectordb-darwin-x64": "0.4.19",
|
||||
"@lancedb/vectordb-linux-arm64-gnu": "0.4.19",
|
||||
"@lancedb/vectordb-linux-x64-gnu": "0.4.19",
|
||||
"@lancedb/vectordb-win32-x64-msvc": "0.4.19"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-arrow/ts": "^14.0.2",
|
||||
@@ -333,42 +333,6 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@lancedb/vectordb-darwin-arm64": {
|
||||
"version": "0.4.14",
|
||||
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.14.tgz",
|
||||
"integrity": "sha512-fw6mf6UhFf4j2kKdFcw0P+SOiIqmRbt+YQSgDbF4BFU3OUSW0XyfETIj9cUMQbSwPFsofhlGp5BRpCd7W9noew==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@lancedb/vectordb-linux-arm64-gnu": {
|
||||
"version": "0.4.14",
|
||||
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-arm64-gnu/-/vectordb-linux-arm64-gnu-0.4.14.tgz",
|
||||
"integrity": "sha512-1+LFI8vU+f/lnGy1s3XCySuV4oj3ZUW03xtmedGBW8nv/Y/jWXP0OYJCRI72eu+dLIdu0tCPsEiu8Hl+o02t9g==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@lancedb/vectordb-win32-x64-msvc": {
|
||||
"version": "0.4.14",
|
||||
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-win32-x64-msvc/-/vectordb-win32-x64-msvc-0.4.14.tgz",
|
||||
"integrity": "sha512-fpuNMZ4aHSpZC3ztp5a0Wh18N6DpCx5EPWhS7bGA5XulGc0l+sZAJHfHwalx76ys//0Ns1z7cuKJhZpSa4SrdQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@neon-rs/cli": {
|
||||
"version": "0.0.160",
|
||||
"resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.160.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vectordb",
|
||||
"version": "0.4.14",
|
||||
"version": "0.4.19",
|
||||
"description": " Serverless, low-latency vector database for AI applications",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -88,10 +88,10 @@
|
||||
}
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@lancedb/vectordb-darwin-arm64": "0.4.14",
|
||||
"@lancedb/vectordb-darwin-x64": "0.4.14",
|
||||
"@lancedb/vectordb-linux-arm64-gnu": "0.4.14",
|
||||
"@lancedb/vectordb-linux-x64-gnu": "0.4.14",
|
||||
"@lancedb/vectordb-win32-x64-msvc": "0.4.14"
|
||||
"@lancedb/vectordb-darwin-arm64": "0.4.19",
|
||||
"@lancedb/vectordb-darwin-x64": "0.4.19",
|
||||
"@lancedb/vectordb-linux-arm64-gnu": "0.4.19",
|
||||
"@lancedb/vectordb-linux-x64-gnu": "0.4.19",
|
||||
"@lancedb/vectordb-win32-x64-msvc": "0.4.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,12 +78,25 @@ export interface ConnectionOptions {
|
||||
/** User provided AWS crednetials.
|
||||
*
|
||||
* If not provided, LanceDB will use the default credentials provider chain.
|
||||
*
|
||||
* @deprecated Pass `aws_access_key_id`, `aws_secret_access_key`, and `aws_session_token`
|
||||
* through `storageOptions` instead.
|
||||
*/
|
||||
awsCredentials?: AwsCredentials
|
||||
|
||||
/** AWS region to connect to. Default is {@link defaultAwsRegion}. */
|
||||
/** AWS region to connect to. Default is {@link defaultAwsRegion}
|
||||
*
|
||||
* @deprecated Pass `region` through `storageOptions` instead.
|
||||
*/
|
||||
awsRegion?: string
|
||||
|
||||
/**
|
||||
* User provided options for object storage. For example, S3 credentials or request timeouts.
|
||||
*
|
||||
* The various options are described at https://lancedb.github.io/lancedb/guides/storage/
|
||||
*/
|
||||
storageOptions?: Record<string, string>
|
||||
|
||||
/**
|
||||
* API key for the remote connections
|
||||
*
|
||||
@@ -150,7 +163,7 @@ export interface CreateTableOptions<T> {
|
||||
/**
|
||||
* Connect to a LanceDB instance at the given URI.
|
||||
*
|
||||
* Accpeted formats:
|
||||
* Accepted formats:
|
||||
*
|
||||
* - `/path/to/database` - local database
|
||||
* - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
|
||||
@@ -176,7 +189,6 @@ export async function connect (
|
||||
if (typeof arg === 'string') {
|
||||
opts = { uri: arg }
|
||||
} else {
|
||||
// opts = { uri: arg.uri, awsCredentials = arg.awsCredentials }
|
||||
const keys = Object.keys(arg)
|
||||
if (keys.length === 1 && keys[0] === 'uri' && typeof arg.uri === 'string') {
|
||||
opts = { uri: arg.uri }
|
||||
@@ -198,12 +210,26 @@ export async function connect (
|
||||
// Remote connection
|
||||
return new RemoteConnection(opts)
|
||||
}
|
||||
|
||||
const storageOptions = opts.storageOptions ?? {};
|
||||
if (opts.awsCredentials?.accessKeyId !== undefined) {
|
||||
storageOptions.aws_access_key_id = opts.awsCredentials.accessKeyId
|
||||
}
|
||||
if (opts.awsCredentials?.secretKey !== undefined) {
|
||||
storageOptions.aws_secret_access_key = opts.awsCredentials.secretKey
|
||||
}
|
||||
if (opts.awsCredentials?.sessionToken !== undefined) {
|
||||
storageOptions.aws_session_token = opts.awsCredentials.sessionToken
|
||||
}
|
||||
if (opts.awsRegion !== undefined) {
|
||||
storageOptions.region = opts.awsRegion
|
||||
}
|
||||
// It's a pain to pass a record to Rust, so we convert it to an array of key-value pairs
|
||||
const storageOptionsArr = Object.entries(storageOptions);
|
||||
|
||||
const db = await databaseNew(
|
||||
opts.uri,
|
||||
opts.awsCredentials?.accessKeyId,
|
||||
opts.awsCredentials?.secretKey,
|
||||
opts.awsCredentials?.sessionToken,
|
||||
opts.awsRegion,
|
||||
storageOptionsArr,
|
||||
opts.readConsistencyInterval
|
||||
)
|
||||
return new LocalConnection(db, opts)
|
||||
@@ -720,7 +746,6 @@ export class LocalConnection implements Connection {
|
||||
const tbl = await databaseOpenTable.call(
|
||||
this._db,
|
||||
name,
|
||||
...getAwsArgs(this._options())
|
||||
)
|
||||
if (embeddings !== undefined) {
|
||||
return new LocalTable(tbl, name, this._options(), embeddings)
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('LanceDB Mirrored Store Integration test', function () {
|
||||
|
||||
const dir = tmpdir()
|
||||
console.log(dir)
|
||||
const conn = await lancedb.connect(`s3://lancedb-integtest?mirroredStore=${dir}`)
|
||||
const conn = await lancedb.connect({ uri: `s3://lancedb-integtest?mirroredStore=${dir}`, storageOptions: { allowHttp: 'true' } })
|
||||
const data = Array(200).fill({ vector: Array(128).fill(1.0), id: 0 })
|
||||
data.push(...Array(200).fill({ vector: Array(128).fill(1.0), id: 1 }))
|
||||
data.push(...Array(200).fill({ vector: Array(128).fill(1.0), id: 2 }))
|
||||
|
||||
@@ -38,7 +38,7 @@ export class Query<T = number[]> {
|
||||
constructor (query?: T, tbl?: any, embeddings?: EmbeddingFunction<T>) {
|
||||
this._tbl = tbl
|
||||
this._query = query
|
||||
this._limit = undefined
|
||||
this._limit = 10
|
||||
this._nprobes = 20
|
||||
this._refineFactor = undefined
|
||||
this._select = undefined
|
||||
@@ -50,6 +50,7 @@ export class Query<T = number[]> {
|
||||
|
||||
/***
|
||||
* Sets the number of results that will be returned
|
||||
* default value is 10
|
||||
* @param value number of results
|
||||
*/
|
||||
limit (value: number): Query<T> {
|
||||
|
||||
@@ -103,6 +103,22 @@ function toLanceRes (res: AxiosResponse): RemoteResponse {
|
||||
}
|
||||
}
|
||||
|
||||
async function decodeErrorData(
|
||||
res: RemoteResponse,
|
||||
responseType?: ResponseType
|
||||
): Promise<string> {
|
||||
const errorData = await res.body()
|
||||
if (responseType === 'arraybuffer') {
|
||||
return new TextDecoder().decode(errorData)
|
||||
} else {
|
||||
if (typeof errorData === 'object') {
|
||||
return JSON.stringify(errorData)
|
||||
}
|
||||
|
||||
return errorData
|
||||
}
|
||||
}
|
||||
|
||||
export class HttpLancedbClient {
|
||||
private readonly _url: string
|
||||
private readonly _apiKey: () => string
|
||||
@@ -180,7 +196,7 @@ export class HttpLancedbClient {
|
||||
}
|
||||
|
||||
if (response.status !== 200) {
|
||||
const errorData = new TextDecoder().decode(await response.body())
|
||||
const errorData = await decodeErrorData(response)
|
||||
throw new Error(
|
||||
`Server Error, status: ${response.status}, ` +
|
||||
`message: ${response.statusText}: ${errorData}`
|
||||
@@ -226,7 +242,7 @@ export class HttpLancedbClient {
|
||||
}
|
||||
|
||||
if (response.status !== 200) {
|
||||
const errorData = new TextDecoder().decode(await response.body())
|
||||
const errorData = await decodeErrorData(response, responseType)
|
||||
throw new Error(
|
||||
`Server Error, status: ${response.status}, ` +
|
||||
`message: ${response.statusText}: ${errorData}`
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
fromRecordsToStreamBuffer,
|
||||
fromTableToStreamBuffer
|
||||
} from '../arrow'
|
||||
import { toSQL } from '../util'
|
||||
import { toSQL, TTLCache } from '../util'
|
||||
import { type HttpMiddleware } from '../middleware'
|
||||
|
||||
/**
|
||||
@@ -47,6 +47,7 @@ import { type HttpMiddleware } from '../middleware'
|
||||
export class RemoteConnection implements Connection {
|
||||
private _client: HttpLancedbClient
|
||||
private readonly _dbName: string
|
||||
private readonly _tableCache = new TTLCache(300_000)
|
||||
|
||||
constructor (opts: ConnectionOptions) {
|
||||
if (!opts.uri.startsWith('db://')) {
|
||||
@@ -89,6 +90,9 @@ export class RemoteConnection implements Connection {
|
||||
page_token: pageToken
|
||||
})
|
||||
const body = await response.body()
|
||||
for (const table of body.tables) {
|
||||
this._tableCache.set(table, true)
|
||||
}
|
||||
return body.tables
|
||||
}
|
||||
|
||||
@@ -101,6 +105,12 @@ export class RemoteConnection implements Connection {
|
||||
name: string,
|
||||
embeddings?: EmbeddingFunction<T>
|
||||
): Promise<Table<T>> {
|
||||
// check if the table exists
|
||||
if (this._tableCache.get(name) === undefined) {
|
||||
await this._client.post(`/v1/table/${encodeURIComponent(name)}/describe/`)
|
||||
this._tableCache.set(name, true)
|
||||
}
|
||||
|
||||
if (embeddings !== undefined) {
|
||||
return new RemoteTable(this._client, name, embeddings)
|
||||
} else {
|
||||
@@ -130,6 +140,9 @@ export class RemoteConnection implements Connection {
|
||||
schema = nameOrOpts.schema
|
||||
embeddings = nameOrOpts.embeddingFunction
|
||||
tableName = nameOrOpts.name
|
||||
if (data === undefined) {
|
||||
data = nameOrOpts.data
|
||||
}
|
||||
}
|
||||
|
||||
let buffer: Buffer
|
||||
@@ -156,7 +169,7 @@ export class RemoteConnection implements Connection {
|
||||
}
|
||||
|
||||
const res = await this._client.post(
|
||||
`/v1/table/${tableName}/create/`,
|
||||
`/v1/table/${encodeURIComponent(tableName)}/create/`,
|
||||
buffer,
|
||||
undefined,
|
||||
'application/vnd.apache.arrow.stream'
|
||||
@@ -169,6 +182,7 @@ export class RemoteConnection implements Connection {
|
||||
)
|
||||
}
|
||||
|
||||
this._tableCache.set(tableName, true)
|
||||
if (embeddings === undefined) {
|
||||
return new RemoteTable(this._client, tableName)
|
||||
} else {
|
||||
@@ -177,7 +191,8 @@ export class RemoteConnection implements Connection {
|
||||
}
|
||||
|
||||
async dropTable (name: string): Promise<void> {
|
||||
await this._client.post(`/v1/table/${name}/drop/`)
|
||||
await this._client.post(`/v1/table/${encodeURIComponent(name)}/drop/`)
|
||||
this._tableCache.delete(name)
|
||||
}
|
||||
|
||||
withMiddleware (middleware: HttpMiddleware): Connection {
|
||||
@@ -268,7 +283,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
|
||||
get schema (): Promise<any> {
|
||||
return this._client
|
||||
.post(`/v1/table/${this._name}/describe/`)
|
||||
.post(`/v1/table/${encodeURIComponent(this._name)}/describe/`)
|
||||
.then(async (res) => {
|
||||
if (res.status !== 200) {
|
||||
throw new Error(
|
||||
@@ -282,7 +297,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
}
|
||||
|
||||
search (query: T): Query<T> {
|
||||
return new RemoteQuery(query, this._client, this._name) //, this._embeddings_new)
|
||||
return new RemoteQuery(query, this._client, encodeURIComponent(this._name)) //, this._embeddings_new)
|
||||
}
|
||||
|
||||
filter (where: string): Query<T> {
|
||||
@@ -324,7 +339,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
|
||||
const buffer = await fromTableToStreamBuffer(tbl, this._embeddings)
|
||||
const res = await this._client.post(
|
||||
`/v1/table/${this._name}/merge_insert/`,
|
||||
`/v1/table/${encodeURIComponent(this._name)}/merge_insert/`,
|
||||
buffer,
|
||||
queryParams,
|
||||
'application/vnd.apache.arrow.stream'
|
||||
@@ -348,7 +363,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
|
||||
const buffer = await fromTableToStreamBuffer(tbl, this._embeddings)
|
||||
const res = await this._client.post(
|
||||
`/v1/table/${this._name}/insert/`,
|
||||
`/v1/table/${encodeURIComponent(this._name)}/insert/`,
|
||||
buffer,
|
||||
{
|
||||
mode: 'append'
|
||||
@@ -374,7 +389,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
}
|
||||
const buffer = await fromTableToStreamBuffer(tbl, this._embeddings)
|
||||
const res = await this._client.post(
|
||||
`/v1/table/${this._name}/insert/`,
|
||||
`/v1/table/${encodeURIComponent(this._name)}/insert/`,
|
||||
buffer,
|
||||
{
|
||||
mode: 'overwrite'
|
||||
@@ -421,7 +436,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
index_cache_size: indexCacheSize
|
||||
}
|
||||
const res = await this._client.post(
|
||||
`/v1/table/${this._name}/create_index/`,
|
||||
`/v1/table/${encodeURIComponent(this._name)}/create_index/`,
|
||||
data
|
||||
)
|
||||
if (res.status !== 200) {
|
||||
@@ -442,7 +457,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
replace: true
|
||||
}
|
||||
const res = await this._client.post(
|
||||
`/v1/table/${this._name}/create_scalar_index/`,
|
||||
`/v1/table/${encodeURIComponent(this._name)}/create_scalar_index/`,
|
||||
data
|
||||
)
|
||||
if (res.status !== 200) {
|
||||
@@ -454,13 +469,15 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
}
|
||||
}
|
||||
|
||||
async countRows (): Promise<number> {
|
||||
const result = await this._client.post(`/v1/table/${this._name}/describe/`)
|
||||
return (await result.body())?.stats?.num_rows
|
||||
async countRows (filter?: string): Promise<number> {
|
||||
const result = await this._client.post(`/v1/table/${encodeURIComponent(this._name)}/count_rows/`, {
|
||||
predicate: filter
|
||||
})
|
||||
return (await result.body())
|
||||
}
|
||||
|
||||
async delete (filter: string): Promise<void> {
|
||||
await this._client.post(`/v1/table/${this._name}/delete/`, {
|
||||
await this._client.post(`/v1/table/${encodeURIComponent(this._name)}/delete/`, {
|
||||
predicate: filter
|
||||
})
|
||||
}
|
||||
@@ -479,7 +496,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
updates[key] = toSQL(value)
|
||||
}
|
||||
}
|
||||
await this._client.post(`/v1/table/${this._name}/update/`, {
|
||||
await this._client.post(`/v1/table/${encodeURIComponent(this._name)}/update/`, {
|
||||
predicate: filter,
|
||||
updates: Object.entries(updates).map(([key, value]) => [key, value])
|
||||
})
|
||||
@@ -487,7 +504,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
|
||||
async listIndices (): Promise<VectorIndex[]> {
|
||||
const results = await this._client.post(
|
||||
`/v1/table/${this._name}/index/list/`
|
||||
`/v1/table/${encodeURIComponent(this._name)}/index/list/`
|
||||
)
|
||||
return (await results.body()).indexes?.map((index: any) => ({
|
||||
columns: index.columns,
|
||||
@@ -498,7 +515,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
|
||||
|
||||
async indexStats (indexUuid: string): Promise<IndexStats> {
|
||||
const results = await this._client.post(
|
||||
`/v1/table/${this._name}/index/${indexUuid}/stats/`
|
||||
`/v1/table/${encodeURIComponent(this._name)}/index/${indexUuid}/stats/`
|
||||
)
|
||||
const body = await results.body()
|
||||
return {
|
||||
|
||||
@@ -42,6 +42,7 @@ import {
|
||||
Float16,
|
||||
Int64
|
||||
} from 'apache-arrow'
|
||||
import type { RemoteRequest, RemoteResponse } from '../middleware'
|
||||
|
||||
const expect = chai.expect
|
||||
const assert = chai.assert
|
||||
@@ -74,6 +75,19 @@ describe('LanceDB client', function () {
|
||||
assert.equal(con.uri, uri)
|
||||
})
|
||||
|
||||
it('should accept custom storage options', async function () {
|
||||
const uri = await createTestDB()
|
||||
const storageOptions = {
|
||||
region: 'us-west-2',
|
||||
timeout: '30s'
|
||||
};
|
||||
const con = await lancedb.connect({
|
||||
uri,
|
||||
storageOptions
|
||||
})
|
||||
assert.equal(con.uri, uri)
|
||||
})
|
||||
|
||||
it('should return the existing table names', async function () {
|
||||
const uri = await createTestDB()
|
||||
const con = await lancedb.connect(uri)
|
||||
@@ -124,9 +138,9 @@ describe('LanceDB client', function () {
|
||||
const uri = await createTestDB(2, 100)
|
||||
const con = await lancedb.connect(uri)
|
||||
const table = (await con.openTable('vectors')) as LocalTable
|
||||
let results = await table.filter('id % 2 = 0').execute()
|
||||
let results = await table.filter('id % 2 = 0').limit(100).execute()
|
||||
assertResults(results)
|
||||
results = await table.where('id % 2 = 0').execute()
|
||||
results = await table.where('id % 2 = 0').limit(100).execute()
|
||||
assertResults(results)
|
||||
|
||||
// Should reject a bad filter
|
||||
@@ -913,7 +927,22 @@ describe('Remote LanceDB client', function () {
|
||||
}
|
||||
|
||||
// Search
|
||||
const table = await con.openTable('vectors')
|
||||
const table = await con.withMiddleware(new (class {
|
||||
async onRemoteRequest(req: RemoteRequest, next: (req: RemoteRequest) => Promise<RemoteResponse>) {
|
||||
// intercept call to check if the table exists and make the call succeed
|
||||
if (req.uri.endsWith('/describe/')) {
|
||||
return {
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: new Map(),
|
||||
body: async () => ({})
|
||||
}
|
||||
}
|
||||
|
||||
return await next(req)
|
||||
}
|
||||
})()).openTable('vectors')
|
||||
|
||||
try {
|
||||
await table.search([0.1, 0.3]).execute()
|
||||
} catch (err) {
|
||||
|
||||
@@ -42,3 +42,36 @@ export function toSQL (value: Literal): string {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
throw new Error(`Unsupported value type: ${typeof value} value: (${value})`)
|
||||
}
|
||||
|
||||
export class TTLCache {
|
||||
private readonly cache: Map<string, { value: any, expires: number }>
|
||||
|
||||
/**
|
||||
* @param ttl Time to live in milliseconds
|
||||
*/
|
||||
constructor (private readonly ttl: number) {
|
||||
this.cache = new Map()
|
||||
}
|
||||
|
||||
get (key: string): any | undefined {
|
||||
const entry = this.cache.get(key)
|
||||
if (entry === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (entry.expires < Date.now()) {
|
||||
this.cache.delete(key)
|
||||
return undefined
|
||||
}
|
||||
|
||||
return entry.value
|
||||
}
|
||||
|
||||
set (key: string, value: any): void {
|
||||
this.cache.set(key, { value, expires: Date.now() + this.ttl })
|
||||
}
|
||||
|
||||
delete (key: string): void {
|
||||
this.cache.delete(key)
|
||||
}
|
||||
}
|
||||
|
||||
1
nodejs/.gitignore
vendored
Normal file
1
nodejs/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
yarn.lock
|
||||
@@ -1,12 +1,44 @@
|
||||
# (New) LanceDB NodeJS SDK
|
||||
# LanceDB JavaScript SDK
|
||||
|
||||
It will replace the NodeJS SDK when it is ready.
|
||||
A JavaScript library for [LanceDB](https://github.com/lancedb/lancedb).
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @lancedb/lancedb
|
||||
```
|
||||
|
||||
This will download the appropriate native library for your platform. We currently
|
||||
support:
|
||||
|
||||
- Linux (x86_64 and aarch64)
|
||||
- MacOS (Intel and ARM/M1/M2)
|
||||
- Windows (x86_64 only)
|
||||
|
||||
We do not yet support musl-based Linux (such as Alpine Linux) or aarch64 Windows.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Example
|
||||
|
||||
```javascript
|
||||
import * as lancedb from "@lancedb/lancedb";
|
||||
const db = await lancedb.connect("data/sample-lancedb");
|
||||
const table = await db.createTable("my_table", [
|
||||
{ id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
|
||||
{ id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 },
|
||||
]);
|
||||
const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
|
||||
console.log(results);
|
||||
```
|
||||
|
||||
The [quickstart](../basic.md) contains a more complete example.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
npm t
|
||||
npm run test
|
||||
```
|
||||
|
||||
### Running lint / format
|
||||
|
||||
219
nodejs/__test__/s3_integration.test.ts
Normal file
219
nodejs/__test__/s3_integration.test.ts
Normal file
@@ -0,0 +1,219 @@
|
||||
// Copyright 2024 Lance Developers.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import { connect } from "../dist";
|
||||
import {
|
||||
CreateBucketCommand,
|
||||
DeleteBucketCommand,
|
||||
DeleteObjectCommand,
|
||||
HeadObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
S3Client,
|
||||
} from "@aws-sdk/client-s3";
|
||||
import {
|
||||
CreateKeyCommand,
|
||||
ScheduleKeyDeletionCommand,
|
||||
KMSClient,
|
||||
} from "@aws-sdk/client-kms";
|
||||
|
||||
// Skip these tests unless the S3_TEST environment variable is set
|
||||
const maybeDescribe = process.env.S3_TEST ? describe : describe.skip;
|
||||
|
||||
// These are all keys that are accepted by storage_options
|
||||
const CONFIG = {
|
||||
allowHttp: "true",
|
||||
awsAccessKeyId: "ACCESSKEY",
|
||||
awsSecretAccessKey: "SECRETKEY",
|
||||
awsEndpoint: "http://127.0.0.1:4566",
|
||||
awsRegion: "us-east-1",
|
||||
};
|
||||
|
||||
class S3Bucket {
|
||||
name: string;
|
||||
constructor(name: string) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
static s3Client() {
|
||||
return new S3Client({
|
||||
region: CONFIG.awsRegion,
|
||||
credentials: {
|
||||
accessKeyId: CONFIG.awsAccessKeyId,
|
||||
secretAccessKey: CONFIG.awsSecretAccessKey,
|
||||
},
|
||||
endpoint: CONFIG.awsEndpoint,
|
||||
});
|
||||
}
|
||||
|
||||
public static async create(name: string): Promise<S3Bucket> {
|
||||
const client = this.s3Client();
|
||||
// Delete the bucket if it already exists
|
||||
try {
|
||||
await this.deleteBucket(client, name);
|
||||
} catch (e) {
|
||||
// It's fine if the bucket doesn't exist
|
||||
}
|
||||
await client.send(new CreateBucketCommand({ Bucket: name }));
|
||||
return new S3Bucket(name);
|
||||
}
|
||||
|
||||
public async delete() {
|
||||
const client = S3Bucket.s3Client();
|
||||
await S3Bucket.deleteBucket(client, this.name);
|
||||
}
|
||||
|
||||
static async deleteBucket(client: S3Client, name: string) {
|
||||
// Must delete all objects before we can delete the bucket
|
||||
const objects = await client.send(
|
||||
new ListObjectsV2Command({ Bucket: name }),
|
||||
);
|
||||
if (objects.Contents) {
|
||||
for (const object of objects.Contents) {
|
||||
await client.send(
|
||||
new DeleteObjectCommand({ Bucket: name, Key: object.Key }),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await client.send(new DeleteBucketCommand({ Bucket: name }));
|
||||
}
|
||||
|
||||
public async assertAllEncrypted(path: string, keyId: string) {
|
||||
const client = S3Bucket.s3Client();
|
||||
const objects = await client.send(
|
||||
new ListObjectsV2Command({ Bucket: this.name, Prefix: path }),
|
||||
);
|
||||
if (objects.Contents) {
|
||||
for (const object of objects.Contents) {
|
||||
const metadata = await client.send(
|
||||
new HeadObjectCommand({ Bucket: this.name, Key: object.Key }),
|
||||
);
|
||||
expect(metadata.ServerSideEncryption).toBe("aws:kms");
|
||||
expect(metadata.SSEKMSKeyId).toContain(keyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KmsKey {
|
||||
keyId: string;
|
||||
constructor(keyId: string) {
|
||||
this.keyId = keyId;
|
||||
}
|
||||
|
||||
static kmsClient() {
|
||||
return new KMSClient({
|
||||
region: CONFIG.awsRegion,
|
||||
credentials: {
|
||||
accessKeyId: CONFIG.awsAccessKeyId,
|
||||
secretAccessKey: CONFIG.awsSecretAccessKey,
|
||||
},
|
||||
endpoint: CONFIG.awsEndpoint,
|
||||
});
|
||||
}
|
||||
|
||||
public static async create(): Promise<KmsKey> {
|
||||
const client = this.kmsClient();
|
||||
const key = await client.send(new CreateKeyCommand({}));
|
||||
const keyId = key?.KeyMetadata?.KeyId;
|
||||
if (!keyId) {
|
||||
throw new Error("Failed to create KMS key");
|
||||
}
|
||||
return new KmsKey(keyId);
|
||||
}
|
||||
|
||||
public async delete() {
|
||||
const client = KmsKey.kmsClient();
|
||||
await client.send(new ScheduleKeyDeletionCommand({ KeyId: this.keyId }));
|
||||
}
|
||||
}
|
||||
|
||||
maybeDescribe("storage_options", () => {
|
||||
let bucket: S3Bucket;
|
||||
let kmsKey: KmsKey;
|
||||
beforeAll(async () => {
|
||||
bucket = await S3Bucket.create("lancedb");
|
||||
kmsKey = await KmsKey.create();
|
||||
});
|
||||
afterAll(async () => {
|
||||
await kmsKey.delete();
|
||||
await bucket.delete();
|
||||
});
|
||||
|
||||
it("can be used to configure auth and endpoints", async () => {
|
||||
const uri = `s3://${bucket.name}/test`;
|
||||
const db = await connect(uri, { storageOptions: CONFIG });
|
||||
|
||||
let table = await db.createTable("test", [{ a: 1, b: 2 }]);
|
||||
|
||||
let rowCount = await table.countRows();
|
||||
expect(rowCount).toBe(1);
|
||||
|
||||
let tableNames = await db.tableNames();
|
||||
expect(tableNames).toEqual(["test"]);
|
||||
|
||||
table = await db.openTable("test");
|
||||
rowCount = await table.countRows();
|
||||
expect(rowCount).toBe(1);
|
||||
|
||||
await table.add([
|
||||
{ a: 2, b: 3 },
|
||||
{ a: 3, b: 4 },
|
||||
]);
|
||||
rowCount = await table.countRows();
|
||||
expect(rowCount).toBe(3);
|
||||
|
||||
await db.dropTable("test");
|
||||
|
||||
tableNames = await db.tableNames();
|
||||
expect(tableNames).toEqual([]);
|
||||
});
|
||||
|
||||
it("can configure encryption at connection and table level", async () => {
|
||||
const uri = `s3://${bucket.name}/test`;
|
||||
let db = await connect(uri, { storageOptions: CONFIG });
|
||||
|
||||
let table = await db.createTable("table1", [{ a: 1, b: 2 }], {
|
||||
storageOptions: {
|
||||
awsServerSideEncryption: "aws:kms",
|
||||
awsSseKmsKeyId: kmsKey.keyId,
|
||||
},
|
||||
});
|
||||
|
||||
let rowCount = await table.countRows();
|
||||
expect(rowCount).toBe(1);
|
||||
|
||||
await table.add([{ a: 2, b: 3 }]);
|
||||
|
||||
await bucket.assertAllEncrypted("test/table1.lance", kmsKey.keyId);
|
||||
|
||||
// Now with encryption settings at connection level
|
||||
db = await connect(uri, {
|
||||
storageOptions: {
|
||||
...CONFIG,
|
||||
awsServerSideEncryption: "aws:kms",
|
||||
awsSseKmsKeyId: kmsKey.keyId,
|
||||
},
|
||||
});
|
||||
table = await db.createTable("table2", [{ a: 1, b: 2 }]);
|
||||
rowCount = await table.countRows();
|
||||
expect(rowCount).toBe(1);
|
||||
|
||||
await table.add([{ a: 2, b: 3 }]);
|
||||
|
||||
await bucket.assertAllEncrypted("test/table2.lance", kmsKey.keyId);
|
||||
});
|
||||
});
|
||||
@@ -13,10 +13,32 @@
|
||||
// limitations under the License.
|
||||
|
||||
import { fromTableToBuffer, makeArrowTable, makeEmptyTable } from "./arrow";
|
||||
import { Connection as LanceDbConnection } from "./native";
|
||||
import { ConnectionOptions, Connection as LanceDbConnection } from "./native";
|
||||
import { Table } from "./table";
|
||||
import { Table as ArrowTable, Schema } from "apache-arrow";
|
||||
|
||||
/**
|
||||
* Connect to a LanceDB instance at the given URI.
|
||||
*
|
||||
* Accepted formats:
|
||||
*
|
||||
* - `/path/to/database` - local database
|
||||
* - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
|
||||
* - `db://host:port` - remote database (LanceDB cloud)
|
||||
* @param {string} uri - The uri of the database. If the database uri starts
|
||||
* with `db://` then it connects to a remote database.
|
||||
* @see {@link ConnectionOptions} for more details on the URI format.
|
||||
*/
|
||||
export async function connect(
|
||||
uri: string,
|
||||
opts?: Partial<ConnectionOptions>,
|
||||
): Promise<Connection> {
|
||||
opts = opts ?? {};
|
||||
opts.storageOptions = cleanseStorageOptions(opts.storageOptions);
|
||||
const nativeConn = await LanceDbConnection.new(uri, opts);
|
||||
return new Connection(nativeConn);
|
||||
}
|
||||
|
||||
export interface CreateTableOptions {
|
||||
/**
|
||||
* The mode to use when creating the table.
|
||||
@@ -33,6 +55,40 @@ export interface CreateTableOptions {
|
||||
* then no error will be raised.
|
||||
*/
|
||||
existOk: boolean;
|
||||
|
||||
/**
|
||||
* Configuration for object storage.
|
||||
*
|
||||
* Options already set on the connection will be inherited by the table,
|
||||
* but can be overridden here.
|
||||
*
|
||||
* The available options are described at https://lancedb.github.io/lancedb/guides/storage/
|
||||
*/
|
||||
storageOptions?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface OpenTableOptions {
|
||||
/**
|
||||
* Configuration for object storage.
|
||||
*
|
||||
* Options already set on the connection will be inherited by the table,
|
||||
* but can be overridden here.
|
||||
*
|
||||
* The available options are described at https://lancedb.github.io/lancedb/guides/storage/
|
||||
*/
|
||||
storageOptions?: Record<string, string>;
|
||||
/**
|
||||
* Set the size of the index cache, specified as a number of entries
|
||||
*
|
||||
* The exact meaning of an "entry" will depend on the type of index:
|
||||
* - IVF: there is one entry for each IVF partition
|
||||
* - BTREE: there is one entry for the entire index
|
||||
*
|
||||
* This cache applies to the entire opened table, across all indices.
|
||||
* Setting this value higher will increase performance on larger datasets
|
||||
* at the expense of more RAM
|
||||
*/
|
||||
indexCacheSize?: number;
|
||||
}
|
||||
|
||||
export interface TableNamesOptions {
|
||||
@@ -109,8 +165,15 @@ export class Connection {
|
||||
* Open a table in the database.
|
||||
* @param {string} name - The name of the table
|
||||
*/
|
||||
async openTable(name: string): Promise<Table> {
|
||||
const innerTable = await this.inner.openTable(name);
|
||||
async openTable(
|
||||
name: string,
|
||||
options?: Partial<OpenTableOptions>,
|
||||
): Promise<Table> {
|
||||
const innerTable = await this.inner.openTable(
|
||||
name,
|
||||
cleanseStorageOptions(options?.storageOptions),
|
||||
options?.indexCacheSize,
|
||||
);
|
||||
return new Table(innerTable);
|
||||
}
|
||||
|
||||
@@ -139,7 +202,12 @@ export class Connection {
|
||||
table = makeArrowTable(data);
|
||||
}
|
||||
const buf = await fromTableToBuffer(table);
|
||||
const innerTable = await this.inner.createTable(name, buf, mode);
|
||||
const innerTable = await this.inner.createTable(
|
||||
name,
|
||||
buf,
|
||||
mode,
|
||||
cleanseStorageOptions(options?.storageOptions),
|
||||
);
|
||||
return new Table(innerTable);
|
||||
}
|
||||
|
||||
@@ -162,7 +230,12 @@ export class Connection {
|
||||
|
||||
const table = makeEmptyTable(schema);
|
||||
const buf = await fromTableToBuffer(table);
|
||||
const innerTable = await this.inner.createEmptyTable(name, buf, mode);
|
||||
const innerTable = await this.inner.createEmptyTable(
|
||||
name,
|
||||
buf,
|
||||
mode,
|
||||
cleanseStorageOptions(options?.storageOptions),
|
||||
);
|
||||
return new Table(innerTable);
|
||||
}
|
||||
|
||||
@@ -174,3 +247,43 @@ export class Connection {
|
||||
return this.inner.dropTable(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes storage options and makes all the keys snake case.
|
||||
*/
|
||||
function cleanseStorageOptions(
|
||||
options?: Record<string, string>,
|
||||
): Record<string, string> | undefined {
|
||||
if (options === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const result: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(options)) {
|
||||
if (value !== undefined) {
|
||||
const newKey = camelToSnakeCase(key);
|
||||
result[newKey] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string to snake case. It might already be snake case, in which case it is
|
||||
* returned unchanged.
|
||||
*/
|
||||
function camelToSnakeCase(camel: string): string {
|
||||
if (camel.includes("_")) {
|
||||
// Assume if there is at least one underscore, it is already snake case
|
||||
return camel;
|
||||
}
|
||||
if (camel.toLocaleUpperCase() === camel) {
|
||||
// Assume if the string is all uppercase, it is already snake case
|
||||
return camel;
|
||||
}
|
||||
|
||||
let result = camel.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
||||
if (result.startsWith("_")) {
|
||||
result = result.slice(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Connection } from "./connection";
|
||||
import {
|
||||
Connection as LanceDbConnection,
|
||||
ConnectionOptions,
|
||||
} from "./native.js";
|
||||
|
||||
export {
|
||||
WriteOptions,
|
||||
WriteMode,
|
||||
@@ -32,6 +26,7 @@ export {
|
||||
VectorColumnOptions,
|
||||
} from "./arrow";
|
||||
export {
|
||||
connect,
|
||||
Connection,
|
||||
CreateTableOptions,
|
||||
TableNamesOptions,
|
||||
@@ -46,24 +41,3 @@ export {
|
||||
export { Index, IndexOptions, IvfPqOptions } from "./indices";
|
||||
export { Table, AddDataOptions, IndexConfig, UpdateOptions } from "./table";
|
||||
export * as embedding from "./embedding";
|
||||
|
||||
/**
|
||||
* Connect to a LanceDB instance at the given URI.
|
||||
*
|
||||
* Accpeted formats:
|
||||
*
|
||||
* - `/path/to/database` - local database
|
||||
* - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
|
||||
* - `db://host:port` - remote database (LanceDB cloud)
|
||||
* @param {string} uri - The uri of the database. If the database uri starts
|
||||
* with `db://` then it connects to a remote database.
|
||||
* @see {@link ConnectionOptions} for more details on the URI format.
|
||||
*/
|
||||
export async function connect(
|
||||
uri: string,
|
||||
opts?: Partial<ConnectionOptions>,
|
||||
): Promise<Connection> {
|
||||
opts = opts ?? {};
|
||||
const nativeConn = await LanceDbConnection.new(uri, opts);
|
||||
return new Connection(nativeConn);
|
||||
}
|
||||
|
||||
@@ -169,17 +169,20 @@ export class Table {
|
||||
* // If the column has a vector (fixed size list) data type then
|
||||
* // an IvfPq vector index will be created.
|
||||
* const table = await conn.openTable("my_table");
|
||||
* await table.createIndex(["vector"]);
|
||||
* await table.createIndex("vector");
|
||||
* @example
|
||||
* // For advanced control over vector index creation you can specify
|
||||
* // the index type and options.
|
||||
* const table = await conn.openTable("my_table");
|
||||
* await table.createIndex(["vector"], I)
|
||||
* .ivf_pq({ num_partitions: 128, num_sub_vectors: 16 })
|
||||
* .build();
|
||||
* await table.createIndex("vector", {
|
||||
* config: lancedb.Index.ivfPq({
|
||||
* numPartitions: 128,
|
||||
* numSubVectors: 16,
|
||||
* }),
|
||||
* });
|
||||
* @example
|
||||
* // Or create a Scalar index
|
||||
* await table.createIndex("my_float_col").build();
|
||||
* await table.createIndex("my_float_col");
|
||||
*/
|
||||
async createIndex(column: string, options?: Partial<IndexOptions>) {
|
||||
// Bit of a hack to get around the fact that TS has no package-scope.
|
||||
@@ -197,8 +200,7 @@ export class Table {
|
||||
* vector similarity, sorting, and more.
|
||||
*
|
||||
* Note: By default, all columns are returned. For best performance, you should
|
||||
* only fetch the columns you need. See [`Query::select_with_projection`] for
|
||||
* more details.
|
||||
* only fetch the columns you need.
|
||||
*
|
||||
* When appropriate, various indices and statistics based pruning will be used to
|
||||
* accelerate the query.
|
||||
@@ -206,10 +208,13 @@ export class Table {
|
||||
* // SQL-style filtering
|
||||
* //
|
||||
* // This query will return up to 1000 rows whose value in the `id` column
|
||||
* // is greater than 5. LanceDb supports a broad set of filtering functions.
|
||||
* for await (const batch of table.query()
|
||||
* .filter("id > 1").select(["id"]).limit(20)) {
|
||||
* console.log(batch);
|
||||
* // is greater than 5. LanceDb supports a broad set of filtering functions.
|
||||
* for await (const batch of table
|
||||
* .query()
|
||||
* .where("id > 1")
|
||||
* .select(["id"])
|
||||
* .limit(20)) {
|
||||
* console.log(batch);
|
||||
* }
|
||||
* @example
|
||||
* // Vector Similarity Search
|
||||
@@ -218,13 +223,14 @@ export class Table {
|
||||
* // closest to the query vector [1.0, 2.0, 3.0]. If an index has been created
|
||||
* // on the "vector" column then this will perform an ANN search.
|
||||
* //
|
||||
* // The `refine_factor` and `nprobes` methods are used to control the recall /
|
||||
* // The `refineFactor` and `nprobes` methods are used to control the recall /
|
||||
* // latency tradeoff of the search.
|
||||
* for await (const batch of table.query()
|
||||
* .nearestTo([1, 2, 3])
|
||||
* .refineFactor(5).nprobe(10)
|
||||
* .limit(10)) {
|
||||
* console.log(batch);
|
||||
* for await (const batch of table
|
||||
* .query()
|
||||
* .where("id > 1")
|
||||
* .select(["id"])
|
||||
* .limit(20)) {
|
||||
* console.log(batch);
|
||||
* }
|
||||
* @example
|
||||
* // Scan the full dataset
|
||||
@@ -286,43 +292,45 @@ export class Table {
|
||||
await this.inner.dropColumns(columnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the version of the table
|
||||
*
|
||||
* LanceDb supports versioning. Every operation that modifies the table increases
|
||||
* version. As long as a version hasn't been deleted you can `[Self::checkout]` that
|
||||
* version to view the data at that point. In addition, you can `[Self::restore]` the
|
||||
* version to replace the current table with a previous version.
|
||||
*/
|
||||
/** Retrieve the version of the table */
|
||||
async version(): Promise<number> {
|
||||
return await this.inner.version();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks out a specific version of the Table
|
||||
* Checks out a specific version of the table _This is an in-place operation._
|
||||
*
|
||||
* Any read operation on the table will now access the data at the checked out version.
|
||||
* As a consequence, calling this method will disable any read consistency interval
|
||||
* that was previously set.
|
||||
* This allows viewing previous versions of the table. If you wish to
|
||||
* keep writing to the dataset starting from an old version, then use
|
||||
* the `restore` function.
|
||||
*
|
||||
* This is a read-only operation that turns the table into a sort of "view"
|
||||
* or "detached head". Other table instances will not be affected. To make the change
|
||||
* permanent you can use the `[Self::restore]` method.
|
||||
* Calling this method will set the table into time-travel mode. If you
|
||||
* wish to return to standard mode, call `checkoutLatest`.
|
||||
* @param {number} version The version to checkout
|
||||
* @example
|
||||
* ```typescript
|
||||
* import * as lancedb from "@lancedb/lancedb"
|
||||
* const db = await lancedb.connect("./.lancedb");
|
||||
* const table = await db.createTable("my_table", [
|
||||
* { vector: [1.1, 0.9], type: "vector" },
|
||||
* ]);
|
||||
*
|
||||
* Any operation that modifies the table will fail while the table is in a checked
|
||||
* out state.
|
||||
*
|
||||
* To return the table to a normal state use `[Self::checkout_latest]`
|
||||
* console.log(await table.version()); // 1
|
||||
* console.log(table.display());
|
||||
* await table.add([{ vector: [0.5, 0.2], type: "vector" }]);
|
||||
* await table.checkout(1);
|
||||
* console.log(await table.version()); // 2
|
||||
* ```
|
||||
*/
|
||||
async checkout(version: number): Promise<void> {
|
||||
await this.inner.checkout(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the table is pointing at the latest version
|
||||
* Checkout the latest version of the table. _This is an in-place operation._
|
||||
*
|
||||
* This can be used to manually update a table when the read_consistency_interval is None
|
||||
* It can also be used to undo a `[Self::checkout]` operation
|
||||
* The table will be set back into standard mode, and will track the latest
|
||||
* version of the table.
|
||||
*/
|
||||
async checkoutLatest(): Promise<void> {
|
||||
await this.inner.checkoutLatest();
|
||||
@@ -344,9 +352,7 @@ export class Table {
|
||||
await this.inner.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* List all indices that have been created with Self::create_index
|
||||
*/
|
||||
/** List all indices that have been created with {@link Table.createIndex} */
|
||||
async listIndices(): Promise<IndexConfig[]> {
|
||||
return await this.inner.listIndices();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-darwin-arm64",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.19",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-darwin-x64",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.19",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-arm64-gnu",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.19",
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-x64-gnu",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.19",
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-win32-x64-msvc",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.14",
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
|
||||
1707
nodejs/package-lock.json
generated
1707
nodejs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.19",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"napi": {
|
||||
@@ -18,6 +18,8 @@
|
||||
},
|
||||
"license": "Apache 2.0",
|
||||
"devDependencies": {
|
||||
"@aws-sdk/client-s3": "^3.33.0",
|
||||
"@aws-sdk/client-kms": "^3.33.0",
|
||||
"@napi-rs/cli": "^2.18.0",
|
||||
"@types/jest": "^29.1.2",
|
||||
"@types/tmp": "^0.2.6",
|
||||
@@ -59,20 +61,15 @@
|
||||
"build": "npm run build:debug && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts",
|
||||
"build-release": "npm run build:release && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts",
|
||||
"chkformat": "prettier . --check",
|
||||
"docs": "typedoc --plugin typedoc-plugin-markdown lancedb/index.ts",
|
||||
"lint": "eslint lancedb && eslint __test__",
|
||||
"docs": "typedoc --plugin typedoc-plugin-markdown --out ../docs/src/js lancedb/index.ts",
|
||||
"lint": "eslint lancedb __test__",
|
||||
"lint-fix": "eslint lancedb __test__ --fix",
|
||||
"prepublishOnly": "napi prepublish -t npm",
|
||||
"test": "npm run build && jest --verbose",
|
||||
"integration": "S3_TEST=1 npm run test",
|
||||
"universal": "napi universal",
|
||||
"version": "napi version"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@lancedb/lancedb-darwin-arm64": "0.4.3",
|
||||
"@lancedb/lancedb-darwin-x64": "0.4.3",
|
||||
"@lancedb/lancedb-linux-arm64-gnu": "0.4.3",
|
||||
"@lancedb/lancedb-linux-x64-gnu": "0.4.3",
|
||||
"@lancedb/lancedb-win32-x64-msvc": "0.4.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"openai": "^4.29.2",
|
||||
"apache-arrow": "^15.0.0"
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use napi::bindgen_prelude::*;
|
||||
use napi_derive::*;
|
||||
|
||||
@@ -64,6 +66,11 @@ impl Connection {
|
||||
builder =
|
||||
builder.read_consistency_interval(std::time::Duration::from_secs_f64(interval));
|
||||
}
|
||||
if let Some(storage_options) = options.storage_options {
|
||||
for (key, value) in storage_options {
|
||||
builder = builder.storage_option(key, value);
|
||||
}
|
||||
}
|
||||
Ok(Self::inner_new(
|
||||
builder
|
||||
.execute()
|
||||
@@ -118,14 +125,18 @@ impl Connection {
|
||||
name: String,
|
||||
buf: Buffer,
|
||||
mode: String,
|
||||
storage_options: Option<HashMap<String, String>>,
|
||||
) -> napi::Result<Table> {
|
||||
let batches = ipc_file_to_batches(buf.to_vec())
|
||||
.map_err(|e| napi::Error::from_reason(format!("Failed to read IPC file: {}", e)))?;
|
||||
let mode = Self::parse_create_mode_str(&mode)?;
|
||||
let tbl = self
|
||||
.get_inner()?
|
||||
.create_table(&name, batches)
|
||||
.mode(mode)
|
||||
let mut builder = self.get_inner()?.create_table(&name, batches).mode(mode);
|
||||
if let Some(storage_options) = storage_options {
|
||||
for (key, value) in storage_options {
|
||||
builder = builder.storage_option(key, value);
|
||||
}
|
||||
}
|
||||
let tbl = builder
|
||||
.execute()
|
||||
.await
|
||||
.map_err(|e| napi::Error::from_reason(format!("{}", e)))?;
|
||||
@@ -138,15 +149,22 @@ impl Connection {
|
||||
name: String,
|
||||
schema_buf: Buffer,
|
||||
mode: String,
|
||||
storage_options: Option<HashMap<String, String>>,
|
||||
) -> napi::Result<Table> {
|
||||
let schema = ipc_file_to_schema(schema_buf.to_vec()).map_err(|e| {
|
||||
napi::Error::from_reason(format!("Failed to marshal schema from JS to Rust: {}", e))
|
||||
})?;
|
||||
let mode = Self::parse_create_mode_str(&mode)?;
|
||||
let tbl = self
|
||||
let mut builder = self
|
||||
.get_inner()?
|
||||
.create_empty_table(&name, schema)
|
||||
.mode(mode)
|
||||
.mode(mode);
|
||||
if let Some(storage_options) = storage_options {
|
||||
for (key, value) in storage_options {
|
||||
builder = builder.storage_option(key, value);
|
||||
}
|
||||
}
|
||||
let tbl = builder
|
||||
.execute()
|
||||
.await
|
||||
.map_err(|e| napi::Error::from_reason(format!("{}", e)))?;
|
||||
@@ -154,10 +172,22 @@ impl Connection {
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub async fn open_table(&self, name: String) -> napi::Result<Table> {
|
||||
let tbl = self
|
||||
.get_inner()?
|
||||
.open_table(&name)
|
||||
pub async fn open_table(
|
||||
&self,
|
||||
name: String,
|
||||
storage_options: Option<HashMap<String, String>>,
|
||||
index_cache_size: Option<u32>,
|
||||
) -> napi::Result<Table> {
|
||||
let mut builder = self.get_inner()?.open_table(&name);
|
||||
if let Some(storage_options) = storage_options {
|
||||
for (key, value) in storage_options {
|
||||
builder = builder.storage_option(key, value);
|
||||
}
|
||||
}
|
||||
if let Some(index_cache_size) = index_cache_size {
|
||||
builder = builder.index_cache_size(index_cache_size);
|
||||
}
|
||||
let tbl = builder
|
||||
.execute()
|
||||
.await
|
||||
.map_err(|e| napi::Error::from_reason(format!("{}", e)))?;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use connection::Connection;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use napi_derive::*;
|
||||
|
||||
mod connection;
|
||||
@@ -38,6 +39,10 @@ pub struct ConnectionOptions {
|
||||
/// Note: this consistency only applies to read operations. Write operations are
|
||||
/// always consistent.
|
||||
pub read_consistency_interval: Option<f64>,
|
||||
/// (For LanceDB OSS only): configuration for object storage.
|
||||
///
|
||||
/// The available options are described at https://lancedb.github.io/lancedb/guides/storage/
|
||||
pub storage_options: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
/// Write mode for writing a table.
|
||||
@@ -54,7 +59,7 @@ pub struct WriteOptions {
|
||||
pub mode: Option<WriteMode>,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub async fn connect(uri: String, options: ConnectionOptions) -> napi::Result<Connection> {
|
||||
Connection::new(uri, options).await
|
||||
#[napi(object)]
|
||||
pub struct OpenTableOptions {
|
||||
pub storage_options: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
10
nodejs/typedoc.json
Normal file
10
nodejs/typedoc.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"intentionallyNotExported": [
|
||||
"lancedb/native.d.ts:Connection",
|
||||
"lancedb/native.d.ts:Index",
|
||||
"lancedb/native.d.ts:Query",
|
||||
"lancedb/native.d.ts:VectorQuery",
|
||||
"lancedb/native.d.ts:RecordBatchIterator",
|
||||
"lancedb/native.d.ts:Table"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.6.5
|
||||
current_version = 0.6.12
|
||||
commit = True
|
||||
message = [python] Bump version: {current_version} → {new_version}
|
||||
tag = True
|
||||
|
||||
@@ -14,7 +14,7 @@ name = "_lancedb"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
arrow = { version = "50.0.0", features = ["pyarrow"] }
|
||||
arrow = { version = "51.0.0", features = ["pyarrow"] }
|
||||
lancedb = { path = "../rust/lancedb" }
|
||||
env_logger = "0.10"
|
||||
pyo3 = { version = "0.20", features = ["extension-module", "abi3-py38"] }
|
||||
@@ -31,3 +31,6 @@ pyo3-build-config = { version = "0.20.3", features = [
|
||||
"extension-module",
|
||||
"abi3-py38",
|
||||
] }
|
||||
|
||||
[features]
|
||||
fp16kernels = ["lancedb/fp16kernels"]
|
||||
|
||||
@@ -41,7 +41,7 @@ To build the python package you can use maturin:
|
||||
```bash
|
||||
# This will build the rust bindings and place them in the appropriate place
|
||||
# in your venv or conda environment
|
||||
matruin develop
|
||||
maturin develop
|
||||
```
|
||||
|
||||
To run the unit tests:
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
[project]
|
||||
name = "lancedb"
|
||||
version = "0.6.5"
|
||||
version = "0.6.12"
|
||||
dependencies = [
|
||||
"deprecation",
|
||||
"pylance==0.10.5",
|
||||
"pylance==0.10.12",
|
||||
"ratelimiter~=1.0",
|
||||
"requests>=2.31.0",
|
||||
"retry>=0.9.2",
|
||||
"tqdm>=4.27.0",
|
||||
"pydantic>=1.10",
|
||||
"attrs>=21.3.0",
|
||||
"semver>=3.0",
|
||||
"cachetools",
|
||||
"pyyaml>=6.0",
|
||||
"click>=8.1.7",
|
||||
"requests>=2.31.0",
|
||||
"overrides>=0.7",
|
||||
]
|
||||
description = "lancedb"
|
||||
@@ -41,6 +39,7 @@ classifiers = [
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Topic :: Scientific/Engineering",
|
||||
]
|
||||
|
||||
@@ -50,6 +49,7 @@ repository = "https://github.com/lancedb/lancedb"
|
||||
[project.optional-dependencies]
|
||||
tests = [
|
||||
"aiohttp",
|
||||
"boto3",
|
||||
"pandas>=1.4",
|
||||
"pytest",
|
||||
"pytest-mock",
|
||||
@@ -57,6 +57,7 @@ tests = [
|
||||
"duckdb",
|
||||
"pytz",
|
||||
"polars>=0.19",
|
||||
"tantivy"
|
||||
]
|
||||
dev = ["ruff", "pre-commit"]
|
||||
docs = [
|
||||
@@ -64,7 +65,6 @@ docs = [
|
||||
"mkdocs-jupyter",
|
||||
"mkdocs-material",
|
||||
"mkdocstrings[python]",
|
||||
"mkdocs-ultralytics-plugin==0.0.44",
|
||||
]
|
||||
clip = ["torch", "pillow", "open-clip"]
|
||||
embeddings = [
|
||||
@@ -87,19 +87,17 @@ azure = ["adlfs>=2024.2.0"]
|
||||
python-source = "python"
|
||||
module-name = "lancedb._lancedb"
|
||||
|
||||
[project.scripts]
|
||||
lancedb = "lancedb.cli.cli:cli"
|
||||
|
||||
[build-system]
|
||||
requires = ["maturin>=1.4"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["F", "E", "W", "I", "G", "TCH", "PERF"]
|
||||
select = ["F", "E", "W", "G", "TCH", "PERF"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "--strict-markers --ignore-glob=lancedb/embeddings/*.py"
|
||||
markers = [
|
||||
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
||||
"asyncio",
|
||||
"s3_test"
|
||||
]
|
||||
|
||||
@@ -15,7 +15,7 @@ import importlib.metadata
|
||||
import os
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import timedelta
|
||||
from typing import Optional, Union
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
__version__ = importlib.metadata.version("lancedb")
|
||||
|
||||
@@ -25,7 +25,6 @@ from .db import AsyncConnection, DBConnection, LanceDBConnection
|
||||
from .remote.db import RemoteDBConnection
|
||||
from .schema import vector
|
||||
from .table import AsyncTable
|
||||
from .utils import sentry_log
|
||||
|
||||
|
||||
def connect(
|
||||
@@ -84,7 +83,7 @@ def connect(
|
||||
|
||||
>>> db = lancedb.connect("s3://my-bucket/lancedb")
|
||||
|
||||
Connect to LancdDB cloud:
|
||||
Connect to LanceDB cloud:
|
||||
|
||||
>>> db = lancedb.connect("db://my_database", api_key="ldb_...")
|
||||
|
||||
@@ -108,6 +107,9 @@ def connect(
|
||||
request_thread_pool=request_thread_pool,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
if kwargs:
|
||||
raise ValueError(f"Unknown keyword arguments: {kwargs}")
|
||||
return LanceDBConnection(uri, read_consistency_interval=read_consistency_interval)
|
||||
|
||||
|
||||
@@ -119,6 +121,7 @@ async def connect_async(
|
||||
host_override: Optional[str] = None,
|
||||
read_consistency_interval: Optional[timedelta] = None,
|
||||
request_thread_pool: Optional[Union[int, ThreadPoolExecutor]] = None,
|
||||
storage_options: Optional[Dict[str, str]] = None,
|
||||
) -> AsyncConnection:
|
||||
"""Connect to a LanceDB database.
|
||||
|
||||
@@ -145,6 +148,9 @@ async def connect_async(
|
||||
the last check, then the table will be checked for updates. Note: this
|
||||
consistency only applies to read operations. Write operations are
|
||||
always consistent.
|
||||
storage_options: dict, optional
|
||||
Additional options for the storage backend. See available options at
|
||||
https://lancedb.github.io/lancedb/guides/storage/
|
||||
|
||||
Examples
|
||||
--------
|
||||
@@ -173,6 +179,7 @@ async def connect_async(
|
||||
region,
|
||||
host_override,
|
||||
read_consistency_interval_secs,
|
||||
storage_options,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -184,7 +191,6 @@ __all__ = [
|
||||
"AsyncTable",
|
||||
"URI",
|
||||
"sanitize_uri",
|
||||
"sentry_log",
|
||||
"vector",
|
||||
"DBConnection",
|
||||
"LanceDBConnection",
|
||||
|
||||
@@ -19,10 +19,18 @@ class Connection(object):
|
||||
self, start_after: Optional[str], limit: Optional[int]
|
||||
) -> list[str]: ...
|
||||
async def create_table(
|
||||
self, name: str, mode: str, data: pa.RecordBatchReader
|
||||
self,
|
||||
name: str,
|
||||
mode: str,
|
||||
data: pa.RecordBatchReader,
|
||||
storage_options: Optional[Dict[str, str]] = None,
|
||||
) -> Table: ...
|
||||
async def create_empty_table(
|
||||
self, name: str, mode: str, schema: pa.Schema
|
||||
self,
|
||||
name: str,
|
||||
mode: str,
|
||||
schema: pa.Schema,
|
||||
storage_options: Optional[Dict[str, str]] = None,
|
||||
) -> Table: ...
|
||||
|
||||
class Table:
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# Copyright 2023 LanceDB Developers
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
@@ -1,47 +0,0 @@
|
||||
# Copyright 2023 LanceDB Developers
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import click
|
||||
|
||||
from lancedb.utils import CONFIG
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.version_option(help="LanceDB command line interface entry point")
|
||||
def cli():
|
||||
"LanceDB command line interface"
|
||||
|
||||
|
||||
diagnostics_help = """
|
||||
Enable or disable LanceDB diagnostics. When enabled, LanceDB will send anonymous events
|
||||
to help us improve LanceDB. These diagnostics are used only for error reporting and no
|
||||
data is collected. You can find more about diagnosis on our docs:
|
||||
https://lancedb.github.io/lancedb/cli_config/
|
||||
"""
|
||||
|
||||
|
||||
@cli.command(help=diagnostics_help)
|
||||
@click.option("--enabled/--disabled", default=True)
|
||||
def diagnostics(enabled):
|
||||
CONFIG.update({"diagnostics": True if enabled else False})
|
||||
click.echo("LanceDB diagnostics is %s" % ("enabled" if enabled else "disabled"))
|
||||
|
||||
|
||||
@cli.command(help="Show current LanceDB configuration")
|
||||
def config():
|
||||
# TODO: pretty print as table with colors and formatting
|
||||
click.echo("Current LanceDB configuration:")
|
||||
cfg = CONFIG.copy()
|
||||
cfg.pop("uuid") # Don't show uuid as it is not configurable
|
||||
for item, amount in cfg.items():
|
||||
click.echo("{} ({})".format(item, amount))
|
||||
@@ -18,14 +18,13 @@ import inspect
|
||||
import os
|
||||
from abc import abstractmethod
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Iterable, List, Literal, Optional, Union
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Literal, Optional, Union
|
||||
|
||||
import pyarrow as pa
|
||||
from overrides import EnforceOverrides, override
|
||||
from pyarrow import fs
|
||||
|
||||
from lancedb.common import data_to_reader, validate_schema
|
||||
from lancedb.utils.events import register_event
|
||||
|
||||
from ._lancedb import connect as lancedb_connect
|
||||
from .pydantic import LanceModel
|
||||
@@ -225,13 +224,23 @@ class DBConnection(EnforceOverrides):
|
||||
def __getitem__(self, name: str) -> LanceTable:
|
||||
return self.open_table(name)
|
||||
|
||||
def open_table(self, name: str) -> Table:
|
||||
def open_table(self, name: str, *, index_cache_size: Optional[int] = None) -> Table:
|
||||
"""Open a Lance Table in the database.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name: str
|
||||
The name of the table.
|
||||
index_cache_size: int, default 256
|
||||
Set the size of the index cache, specified as a number of entries
|
||||
|
||||
The exact meaning of an "entry" will depend on the type of index:
|
||||
* IVF - there is one entry for each IVF partition
|
||||
* BTREE - there is one entry for the entire index
|
||||
|
||||
This cache applies to the entire opened table, across all indices.
|
||||
Setting this value higher will increase performance on larger datasets
|
||||
at the expense of more RAM
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -249,6 +258,18 @@ class DBConnection(EnforceOverrides):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def rename_table(self, cur_name: str, new_name: str):
|
||||
"""Rename a table in the database.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
cur_name: str
|
||||
The current name of the table.
|
||||
new_name: str
|
||||
The new name of the table.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def drop_database(self):
|
||||
"""
|
||||
Drop database
|
||||
@@ -408,7 +429,9 @@ class LanceDBConnection(DBConnection):
|
||||
return tbl
|
||||
|
||||
@override
|
||||
def open_table(self, name: str) -> LanceTable:
|
||||
def open_table(
|
||||
self, name: str, *, index_cache_size: Optional[int] = None
|
||||
) -> LanceTable:
|
||||
"""Open a table in the database.
|
||||
|
||||
Parameters
|
||||
@@ -420,7 +443,7 @@ class LanceDBConnection(DBConnection):
|
||||
-------
|
||||
A LanceTable object representing the table.
|
||||
"""
|
||||
return LanceTable.open(self, name)
|
||||
return LanceTable.open(self, name, index_cache_size=index_cache_size)
|
||||
|
||||
@override
|
||||
def drop_table(self, name: str, ignore_missing: bool = False):
|
||||
@@ -534,6 +557,7 @@ class AsyncConnection(object):
|
||||
exist_ok: Optional[bool] = None,
|
||||
on_bad_vectors: Optional[str] = None,
|
||||
fill_value: Optional[float] = None,
|
||||
storage_options: Optional[Dict[str, str]] = None,
|
||||
) -> AsyncTable:
|
||||
"""Create an [AsyncTable][lancedb.table.AsyncTable] in the database.
|
||||
|
||||
@@ -571,6 +595,12 @@ class AsyncConnection(object):
|
||||
One of "error", "drop", "fill".
|
||||
fill_value: float
|
||||
The value to use when filling vectors. Only used if on_bad_vectors="fill".
|
||||
storage_options: dict, optional
|
||||
Additional options for the storage backend. Options already set on the
|
||||
connection will be inherited by the table, but can be overridden here.
|
||||
See available options at
|
||||
https://lancedb.github.io/lancedb/guides/storage/
|
||||
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -730,32 +760,53 @@ class AsyncConnection(object):
|
||||
mode = "exist_ok"
|
||||
|
||||
if data is None:
|
||||
new_table = await self._inner.create_empty_table(name, mode, schema)
|
||||
new_table = await self._inner.create_empty_table(
|
||||
name, mode, schema, storage_options=storage_options
|
||||
)
|
||||
else:
|
||||
data = data_to_reader(data, schema)
|
||||
new_table = await self._inner.create_table(
|
||||
name,
|
||||
mode,
|
||||
data,
|
||||
storage_options=storage_options,
|
||||
)
|
||||
|
||||
register_event("create_table")
|
||||
return AsyncTable(new_table)
|
||||
|
||||
async def open_table(self, name: str) -> Table:
|
||||
async def open_table(
|
||||
self,
|
||||
name: str,
|
||||
storage_options: Optional[Dict[str, str]] = None,
|
||||
index_cache_size: Optional[int] = None,
|
||||
) -> Table:
|
||||
"""Open a Lance Table in the database.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name: str
|
||||
The name of the table.
|
||||
storage_options: dict, optional
|
||||
Additional options for the storage backend. Options already set on the
|
||||
connection will be inherited by the table, but can be overridden here.
|
||||
See available options at
|
||||
https://lancedb.github.io/lancedb/guides/storage/
|
||||
index_cache_size: int, default 256
|
||||
Set the size of the index cache, specified as a number of entries
|
||||
|
||||
The exact meaning of an "entry" will depend on the type of index:
|
||||
* IVF - there is one entry for each IVF partition
|
||||
* BTREE - there is one entry for the entire index
|
||||
|
||||
This cache applies to the entire opened table, across all indices.
|
||||
Setting this value higher will increase performance on larger datasets
|
||||
at the expense of more RAM
|
||||
|
||||
Returns
|
||||
-------
|
||||
A LanceTable object representing the table.
|
||||
"""
|
||||
table = await self._inner.open_table(name)
|
||||
register_event("open_table")
|
||||
table = await self._inner.open_table(name, storage_options, index_cache_size)
|
||||
return AsyncTable(table)
|
||||
|
||||
async def drop_table(self, name: str):
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ruff: noqa: F401
|
||||
from .base import EmbeddingFunction, EmbeddingFunctionConfig, TextEmbeddingFunction
|
||||
from .bedrock import BedRockText
|
||||
@@ -21,4 +20,7 @@ from .open_clip import OpenClipEmbeddings
|
||||
from .openai import OpenAIEmbeddings
|
||||
from .registry import EmbeddingFunctionRegistry, get_registry
|
||||
from .sentence_transformers import SentenceTransformerEmbeddings
|
||||
from .gte import GteEmbeddings
|
||||
from .transformers import TransformersEmbeddingFunction, ColbertEmbeddings
|
||||
from .imagebind import ImageBindEmbeddings
|
||||
from .utils import with_embeddings
|
||||
|
||||
@@ -78,6 +78,9 @@ class BedRockText(TextEmbeddingFunction):
|
||||
|
||||
class Config:
|
||||
keep_untouched = (cached_property,)
|
||||
else:
|
||||
model_config = dict()
|
||||
model_config["ignored_types"] = (cached_property,)
|
||||
|
||||
def ndims(self):
|
||||
# return len(self._generate_embedding("test"))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user