@lancedb/lancedb 0.4.3 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/arrow.d.ts +189 -0
  2. package/dist/arrow.js +539 -0
  3. package/dist/connection.d.ts +97 -0
  4. package/dist/connection.js +126 -0
  5. package/dist/embedding/embedding_function.d.ts +45 -0
  6. package/dist/embedding/embedding_function.js +27 -0
  7. package/dist/embedding/index.d.ts +2 -0
  8. package/dist/embedding/index.js +7 -0
  9. package/dist/embedding/openai.d.ts +8 -0
  10. package/dist/embedding/openai.js +53 -0
  11. package/dist/index.d.ts +22 -0
  12. package/dist/index.js +52 -0
  13. package/dist/indices.d.ts +165 -0
  14. package/dist/indices.js +71 -0
  15. package/dist/native.d.ts +147 -0
  16. package/dist/native.js +314 -0
  17. package/dist/query.d.ts +248 -0
  18. package/dist/query.js +346 -0
  19. package/dist/sanitize.d.ts +9 -0
  20. package/dist/sanitize.js +369 -0
  21. package/dist/table.d.ts +252 -0
  22. package/dist/table.js +298 -0
  23. package/nodejs-artifacts/arrow.d.ts +189 -0
  24. package/nodejs-artifacts/arrow.js +539 -0
  25. package/nodejs-artifacts/connection.d.ts +97 -0
  26. package/nodejs-artifacts/connection.js +126 -0
  27. package/nodejs-artifacts/embedding/embedding_function.d.ts +45 -0
  28. package/nodejs-artifacts/embedding/embedding_function.js +27 -0
  29. package/nodejs-artifacts/embedding/index.d.ts +2 -0
  30. package/nodejs-artifacts/embedding/index.js +7 -0
  31. package/nodejs-artifacts/embedding/openai.d.ts +8 -0
  32. package/nodejs-artifacts/embedding/openai.js +53 -0
  33. package/nodejs-artifacts/index.d.ts +22 -0
  34. package/nodejs-artifacts/index.js +52 -0
  35. package/nodejs-artifacts/indices.d.ts +165 -0
  36. package/nodejs-artifacts/indices.js +71 -0
  37. package/nodejs-artifacts/native.d.ts +147 -0
  38. package/nodejs-artifacts/native.js +314 -0
  39. package/nodejs-artifacts/query.d.ts +248 -0
  40. package/nodejs-artifacts/query.js +346 -0
  41. package/nodejs-artifacts/sanitize.d.ts +9 -0
  42. package/nodejs-artifacts/sanitize.js +369 -0
  43. package/nodejs-artifacts/table.d.ts +252 -0
  44. package/nodejs-artifacts/table.js +298 -0
  45. package/package.json +8 -10
  46. package/examples/js/index.mjs +0 -40
  47. package/examples/js/package.json +0 -14
  48. package/examples/js-openai/index.mjs +0 -43
  49. package/examples/js-openai/package-lock.json +0 -256
  50. package/examples/js-openai/package.json +0 -15
  51. package/examples/js-transformers/index.mjs +0 -65
  52. package/examples/js-transformers/package-lock.json +0 -1418
  53. package/examples/js-transformers/package.json +0 -15
  54. package/examples/js-youtube-transcripts/index.mjs +0 -135
  55. package/examples/js-youtube-transcripts/package.json +0 -15
  56. package/examples/ts/data/sample-lancedb/vectors.lance/_latest.manifest +0 -0
  57. package/examples/ts/data/sample-lancedb/vectors.lance/_transactions/0-adde4e05-fcfc-415c-86a6-5b252cb9e79a.txn +0 -0
  58. package/examples/ts/data/sample-lancedb/vectors.lance/_versions/1.manifest +0 -0
  59. package/examples/ts/data/sample-lancedb/vectors.lance/data/3618b33e-3eea-4b5e-a0fc-7d1f718d551e.lance +0 -0
  60. package/examples/ts/package-lock.json +0 -1340
  61. package/examples/ts/package.json +0 -22
  62. package/examples/ts/tsconfig.json +0 -10
@@ -0,0 +1,147 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ /** A description of an index currently configured on a column */
7
+ export interface IndexConfig {
8
+ /** The type of the index */
9
+ indexType: string
10
+ /**
11
+ * The columns in the index
12
+ *
13
+ * Currently this is always an array of size 1. In the future there may
14
+ * be more columns to represent composite indices.
15
+ */
16
+ columns: Array<string>
17
+ }
18
+ /**
19
+ * A definition of a column alteration. The alteration changes the column at
20
+ * `path` to have the new name `name`, to be nullable if `nullable` is true,
21
+ * and to have the data type `data_type`. At least one of `rename` or `nullable`
22
+ * must be provided.
23
+ */
24
+ export interface ColumnAlteration {
25
+ /**
26
+ * The path to the column to alter. This is a dot-separated path to the column.
27
+ * If it is a top-level column then it is just the name of the column. If it is
28
+ * a nested column then it is the path to the column, e.g. "a.b.c" for a column
29
+ * `c` nested inside a column `b` nested inside a column `a`.
30
+ */
31
+ path: string
32
+ /**
33
+ * The new name of the column. If not provided then the name will not be changed.
34
+ * This must be distinct from the names of all other columns in the table.
35
+ */
36
+ rename?: string
37
+ /** Set the new nullability. Note that a nullable column cannot be made non-nullable. */
38
+ nullable?: boolean
39
+ }
40
+ /** A definition of a new column to add to a table. */
41
+ export interface AddColumnsSql {
42
+ /** The name of the new column. */
43
+ name: string
44
+ /**
45
+ * The values to populate the new column with, as a SQL expression.
46
+ * The expression can reference other columns in the table.
47
+ */
48
+ valueSql: string
49
+ }
50
+ export interface ConnectionOptions {
51
+ apiKey?: string
52
+ hostOverride?: string
53
+ /**
54
+ * (For LanceDB OSS only): The interval, in seconds, at which to check for
55
+ * updates to the table from other processes. If None, then consistency is not
56
+ * checked. For performance reasons, this is the default. For strong
57
+ * consistency, set this to zero seconds. Then every read will check for
58
+ * updates from other processes. As a compromise, you can set this to a
59
+ * non-zero value for eventual consistency. If more than that interval
60
+ * has passed since the last check, then the table will be checked for updates.
61
+ * Note: this consistency only applies to read operations. Write operations are
62
+ * always consistent.
63
+ */
64
+ readConsistencyInterval?: number
65
+ }
66
+ /** Write mode for writing a table. */
67
+ export const enum WriteMode {
68
+ Create = 'Create',
69
+ Append = 'Append',
70
+ Overwrite = 'Overwrite'
71
+ }
72
+ /** Write options when creating a Table. */
73
+ export interface WriteOptions {
74
+ mode?: WriteMode
75
+ }
76
+ export function connect(uri: string, options: ConnectionOptions): Promise<Connection>
77
+ export class Connection {
78
+ /** Create a new Connection instance from the given URI. */
79
+ static new(uri: string, options: ConnectionOptions): Promise<Connection>
80
+ display(): string
81
+ isOpen(): boolean
82
+ close(): void
83
+ /** List all tables in the dataset. */
84
+ tableNames(startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
85
+ /**
86
+ * Create table from a Apache Arrow IPC (file) buffer.
87
+ *
88
+ * Parameters:
89
+ * - name: The name of the table.
90
+ * - buf: The buffer containing the IPC file.
91
+ *
92
+ */
93
+ createTable(name: string, buf: Buffer, mode: string): Promise<Table>
94
+ createEmptyTable(name: string, schemaBuf: Buffer, mode: string): Promise<Table>
95
+ openTable(name: string): Promise<Table>
96
+ /** Drop table with the name. Or raise an error if the table does not exist. */
97
+ dropTable(name: string): Promise<void>
98
+ }
99
+ export class Index {
100
+ static ivfPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
101
+ static btree(): Index
102
+ }
103
+ /** Typescript-style Async Iterator over RecordBatches */
104
+ export class RecordBatchIterator {
105
+ next(): Promise<Buffer | null>
106
+ }
107
+ export class Query {
108
+ onlyIf(predicate: string): void
109
+ select(columns: Array<[string, string]>): void
110
+ limit(limit: number): void
111
+ nearestTo(vector: Float32Array): VectorQuery
112
+ execute(): Promise<RecordBatchIterator>
113
+ }
114
+ export class VectorQuery {
115
+ column(column: string): void
116
+ distanceType(distanceType: string): void
117
+ postfilter(): void
118
+ refineFactor(refineFactor: number): void
119
+ nprobes(nprobe: number): void
120
+ bypassVectorIndex(): void
121
+ onlyIf(predicate: string): void
122
+ select(columns: Array<[string, string]>): void
123
+ limit(limit: number): void
124
+ execute(): Promise<RecordBatchIterator>
125
+ }
126
+ export class Table {
127
+ display(): string
128
+ isOpen(): boolean
129
+ close(): void
130
+ /** Return Schema as empty Arrow IPC file. */
131
+ schema(): Promise<Buffer>
132
+ add(buf: Buffer, mode: string): Promise<void>
133
+ countRows(filter?: string | undefined | null): Promise<number>
134
+ delete(predicate: string): Promise<void>
135
+ createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null): Promise<void>
136
+ update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<void>
137
+ query(): Query
138
+ vectorSearch(vector: Float32Array): VectorQuery
139
+ addColumns(transforms: Array<AddColumnsSql>): Promise<void>
140
+ alterColumns(alterations: Array<ColumnAlteration>): Promise<void>
141
+ dropColumns(columns: Array<string>): Promise<void>
142
+ version(): Promise<number>
143
+ checkout(version: number): Promise<void>
144
+ checkoutLatest(): Promise<void>
145
+ restore(): Promise<void>
146
+ listIndices(): Promise<Array<IndexConfig>>
147
+ }
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /* prettier-ignore */
5
+ /* auto-generated by NAPI-RS */
6
+ const { existsSync, readFileSync } = require('fs');
7
+ const { join } = require('path');
8
+ const { platform, arch } = process;
9
+ let nativeBinding = null;
10
+ let localFileExisted = false;
11
+ let loadError = null;
12
+ function isMusl() {
13
+ // For Node 10
14
+ if (!process.report || typeof process.report.getReport !== 'function') {
15
+ try {
16
+ const lddPath = require('child_process').execSync('which ldd').toString().trim();
17
+ return readFileSync(lddPath, 'utf8').includes('musl');
18
+ }
19
+ catch (e) {
20
+ return true;
21
+ }
22
+ }
23
+ else {
24
+ const { glibcVersionRuntime } = process.report.getReport().header;
25
+ return !glibcVersionRuntime;
26
+ }
27
+ }
28
+ switch (platform) {
29
+ case 'android':
30
+ switch (arch) {
31
+ case 'arm64':
32
+ localFileExisted = existsSync(join(__dirname, 'lancedb.android-arm64.node'));
33
+ try {
34
+ if (localFileExisted) {
35
+ nativeBinding = require('./lancedb.android-arm64.node');
36
+ }
37
+ else {
38
+ nativeBinding = require('@lancedb/lancedb-android-arm64');
39
+ }
40
+ }
41
+ catch (e) {
42
+ loadError = e;
43
+ }
44
+ break;
45
+ case 'arm':
46
+ localFileExisted = existsSync(join(__dirname, 'lancedb.android-arm-eabi.node'));
47
+ try {
48
+ if (localFileExisted) {
49
+ nativeBinding = require('./lancedb.android-arm-eabi.node');
50
+ }
51
+ else {
52
+ nativeBinding = require('@lancedb/lancedb-android-arm-eabi');
53
+ }
54
+ }
55
+ catch (e) {
56
+ loadError = e;
57
+ }
58
+ break;
59
+ default:
60
+ throw new Error(`Unsupported architecture on Android ${arch}`);
61
+ }
62
+ break;
63
+ case 'win32':
64
+ switch (arch) {
65
+ case 'x64':
66
+ localFileExisted = existsSync(join(__dirname, 'lancedb.win32-x64-msvc.node'));
67
+ try {
68
+ if (localFileExisted) {
69
+ nativeBinding = require('./lancedb.win32-x64-msvc.node');
70
+ }
71
+ else {
72
+ nativeBinding = require('@lancedb/lancedb-win32-x64-msvc');
73
+ }
74
+ }
75
+ catch (e) {
76
+ loadError = e;
77
+ }
78
+ break;
79
+ case 'ia32':
80
+ localFileExisted = existsSync(join(__dirname, 'lancedb.win32-ia32-msvc.node'));
81
+ try {
82
+ if (localFileExisted) {
83
+ nativeBinding = require('./lancedb.win32-ia32-msvc.node');
84
+ }
85
+ else {
86
+ nativeBinding = require('@lancedb/lancedb-win32-ia32-msvc');
87
+ }
88
+ }
89
+ catch (e) {
90
+ loadError = e;
91
+ }
92
+ break;
93
+ case 'arm64':
94
+ localFileExisted = existsSync(join(__dirname, 'lancedb.win32-arm64-msvc.node'));
95
+ try {
96
+ if (localFileExisted) {
97
+ nativeBinding = require('./lancedb.win32-arm64-msvc.node');
98
+ }
99
+ else {
100
+ nativeBinding = require('@lancedb/lancedb-win32-arm64-msvc');
101
+ }
102
+ }
103
+ catch (e) {
104
+ loadError = e;
105
+ }
106
+ break;
107
+ default:
108
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
109
+ }
110
+ break;
111
+ case 'darwin':
112
+ localFileExisted = existsSync(join(__dirname, 'lancedb.darwin-universal.node'));
113
+ try {
114
+ if (localFileExisted) {
115
+ nativeBinding = require('./lancedb.darwin-universal.node');
116
+ }
117
+ else {
118
+ nativeBinding = require('@lancedb/lancedb-darwin-universal');
119
+ }
120
+ break;
121
+ }
122
+ catch { }
123
+ switch (arch) {
124
+ case 'x64':
125
+ localFileExisted = existsSync(join(__dirname, 'lancedb.darwin-x64.node'));
126
+ try {
127
+ if (localFileExisted) {
128
+ nativeBinding = require('./lancedb.darwin-x64.node');
129
+ }
130
+ else {
131
+ nativeBinding = require('@lancedb/lancedb-darwin-x64');
132
+ }
133
+ }
134
+ catch (e) {
135
+ loadError = e;
136
+ }
137
+ break;
138
+ case 'arm64':
139
+ localFileExisted = existsSync(join(__dirname, 'lancedb.darwin-arm64.node'));
140
+ try {
141
+ if (localFileExisted) {
142
+ nativeBinding = require('./lancedb.darwin-arm64.node');
143
+ }
144
+ else {
145
+ nativeBinding = require('@lancedb/lancedb-darwin-arm64');
146
+ }
147
+ }
148
+ catch (e) {
149
+ loadError = e;
150
+ }
151
+ break;
152
+ default:
153
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
154
+ }
155
+ break;
156
+ case 'freebsd':
157
+ if (arch !== 'x64') {
158
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
159
+ }
160
+ localFileExisted = existsSync(join(__dirname, 'lancedb.freebsd-x64.node'));
161
+ try {
162
+ if (localFileExisted) {
163
+ nativeBinding = require('./lancedb.freebsd-x64.node');
164
+ }
165
+ else {
166
+ nativeBinding = require('@lancedb/lancedb-freebsd-x64');
167
+ }
168
+ }
169
+ catch (e) {
170
+ loadError = e;
171
+ }
172
+ break;
173
+ case 'linux':
174
+ switch (arch) {
175
+ case 'x64':
176
+ if (isMusl()) {
177
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-x64-musl.node'));
178
+ try {
179
+ if (localFileExisted) {
180
+ nativeBinding = require('./lancedb.linux-x64-musl.node');
181
+ }
182
+ else {
183
+ nativeBinding = require('@lancedb/lancedb-linux-x64-musl');
184
+ }
185
+ }
186
+ catch (e) {
187
+ loadError = e;
188
+ }
189
+ }
190
+ else {
191
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-x64-gnu.node'));
192
+ try {
193
+ if (localFileExisted) {
194
+ nativeBinding = require('./lancedb.linux-x64-gnu.node');
195
+ }
196
+ else {
197
+ nativeBinding = require('@lancedb/lancedb-linux-x64-gnu');
198
+ }
199
+ }
200
+ catch (e) {
201
+ loadError = e;
202
+ }
203
+ }
204
+ break;
205
+ case 'arm64':
206
+ if (isMusl()) {
207
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-arm64-musl.node'));
208
+ try {
209
+ if (localFileExisted) {
210
+ nativeBinding = require('./lancedb.linux-arm64-musl.node');
211
+ }
212
+ else {
213
+ nativeBinding = require('@lancedb/lancedb-linux-arm64-musl');
214
+ }
215
+ }
216
+ catch (e) {
217
+ loadError = e;
218
+ }
219
+ }
220
+ else {
221
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-arm64-gnu.node'));
222
+ try {
223
+ if (localFileExisted) {
224
+ nativeBinding = require('./lancedb.linux-arm64-gnu.node');
225
+ }
226
+ else {
227
+ nativeBinding = require('@lancedb/lancedb-linux-arm64-gnu');
228
+ }
229
+ }
230
+ catch (e) {
231
+ loadError = e;
232
+ }
233
+ }
234
+ break;
235
+ case 'arm':
236
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-arm-gnueabihf.node'));
237
+ try {
238
+ if (localFileExisted) {
239
+ nativeBinding = require('./lancedb.linux-arm-gnueabihf.node');
240
+ }
241
+ else {
242
+ nativeBinding = require('@lancedb/lancedb-linux-arm-gnueabihf');
243
+ }
244
+ }
245
+ catch (e) {
246
+ loadError = e;
247
+ }
248
+ break;
249
+ case 'riscv64':
250
+ if (isMusl()) {
251
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-riscv64-musl.node'));
252
+ try {
253
+ if (localFileExisted) {
254
+ nativeBinding = require('./lancedb.linux-riscv64-musl.node');
255
+ }
256
+ else {
257
+ nativeBinding = require('@lancedb/lancedb-linux-riscv64-musl');
258
+ }
259
+ }
260
+ catch (e) {
261
+ loadError = e;
262
+ }
263
+ }
264
+ else {
265
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-riscv64-gnu.node'));
266
+ try {
267
+ if (localFileExisted) {
268
+ nativeBinding = require('./lancedb.linux-riscv64-gnu.node');
269
+ }
270
+ else {
271
+ nativeBinding = require('@lancedb/lancedb-linux-riscv64-gnu');
272
+ }
273
+ }
274
+ catch (e) {
275
+ loadError = e;
276
+ }
277
+ }
278
+ break;
279
+ case 's390x':
280
+ localFileExisted = existsSync(join(__dirname, 'lancedb.linux-s390x-gnu.node'));
281
+ try {
282
+ if (localFileExisted) {
283
+ nativeBinding = require('./lancedb.linux-s390x-gnu.node');
284
+ }
285
+ else {
286
+ nativeBinding = require('@lancedb/lancedb-linux-s390x-gnu');
287
+ }
288
+ }
289
+ catch (e) {
290
+ loadError = e;
291
+ }
292
+ break;
293
+ default:
294
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
295
+ }
296
+ break;
297
+ default:
298
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
299
+ }
300
+ if (!nativeBinding) {
301
+ if (loadError) {
302
+ throw loadError;
303
+ }
304
+ throw new Error(`Failed to load native binding`);
305
+ }
306
+ const { Connection, Index, RecordBatchIterator, Query, VectorQuery, Table, WriteMode, connect } = nativeBinding;
307
+ module.exports.Connection = Connection;
308
+ module.exports.Index = Index;
309
+ module.exports.RecordBatchIterator = RecordBatchIterator;
310
+ module.exports.Query = Query;
311
+ module.exports.VectorQuery = VectorQuery;
312
+ module.exports.Table = Table;
313
+ module.exports.WriteMode = WriteMode;
314
+ module.exports.connect = connect;