@lancedb/lancedb 0.15.0 → 0.15.1-beta.3
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.
- package/README.md +1 -1
- package/dist/arrow.d.ts +29 -30
- package/dist/arrow.js +40 -45
- package/dist/connection.d.ts +3 -0
- package/dist/connection.js +32 -16
- package/dist/embedding/embedding_function.d.ts +3 -3
- package/dist/embedding/embedding_function.js +5 -16
- package/dist/embedding/index.d.ts +1 -1
- package/dist/embedding/index.js +2 -13
- package/dist/embedding/openai.js +2 -13
- package/dist/embedding/registry.d.ts +2 -5
- package/dist/embedding/registry.js +2 -15
- package/dist/embedding/transformers.js +2 -13
- package/dist/index.d.ts +11 -7
- package/dist/index.js +11 -22
- package/dist/indices.d.ts +0 -2
- package/dist/indices.js +2 -15
- package/dist/merge.d.ts +2 -2
- package/dist/merge.js +17 -5
- package/dist/native.d.ts +1 -11
- package/dist/native.js +1 -2
- package/dist/query.d.ts +37 -4
- package/dist/query.js +39 -17
- package/dist/rerankers/rrf.d.ts +2 -1
- package/dist/rerankers/rrf.js +2 -1
- package/dist/sanitize.js +2 -13
- package/dist/table.d.ts +24 -8
- package/dist/table.js +13 -40
- package/dist/util.js +2 -0
- package/license_header.txt +2 -0
- package/package.json +10 -10
- package/typedoc_post_process.js +22 -17
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
|
|
|
32
32
|
console.log(results);
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The [quickstart](
|
|
35
|
+
The [quickstart](https://lancedb.github.io/lancedb/basic/) contains a more complete example.
|
|
36
36
|
|
|
37
37
|
## Development
|
|
38
38
|
|
package/dist/arrow.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export declare class MakeArrowTableOptions {
|
|
|
112
112
|
* - Record<String, any> => Struct
|
|
113
113
|
* - Array<any> => List
|
|
114
114
|
* @example
|
|
115
|
+
* ```ts
|
|
115
116
|
* import { fromTableToBuffer, makeArrowTable } from "../arrow";
|
|
116
117
|
* import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
|
|
117
118
|
*
|
|
@@ -133,43 +134,41 @@ export declare class MakeArrowTableOptions {
|
|
|
133
134
|
* names and data types.
|
|
134
135
|
*
|
|
135
136
|
* ```ts
|
|
136
|
-
*
|
|
137
137
|
* const schema = new Schema([
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
138
|
+
* new Field("a", new Float64()),
|
|
139
|
+
* new Field("b", new Float64()),
|
|
140
|
+
* new Field(
|
|
141
|
+
* "vector",
|
|
142
|
+
* new FixedSizeList(3, new Field("item", new Float32()))
|
|
143
|
+
* ),
|
|
144
|
+
* ]);
|
|
145
|
+
* const table = makeArrowTable([
|
|
146
|
+
* { a: 1, b: 2, vector: [1, 2, 3] },
|
|
147
|
+
* { a: 4, b: 5, vector: [4, 5, 6] },
|
|
148
|
+
* { a: 7, b: 8, vector: [7, 8, 9] },
|
|
149
|
+
* ]);
|
|
150
|
+
* assert.deepEqual(table.schema, schema);
|
|
151
151
|
* ```
|
|
152
152
|
*
|
|
153
153
|
* You can specify the vector column types and names using the options as well
|
|
154
154
|
*
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
155
|
+
* ```ts
|
|
157
156
|
* const schema = new Schema([
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
* new Field('a', new Float64()),
|
|
158
|
+
* new Field('b', new Float64()),
|
|
159
|
+
* new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
|
|
160
|
+
* new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
|
|
161
|
+
* ]);
|
|
163
162
|
* const table = makeArrowTable([
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
* { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
|
|
164
|
+
* { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
|
|
165
|
+
* { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
|
|
166
|
+
* ], {
|
|
167
|
+
* vectorColumns: {
|
|
168
|
+
* vec1: { type: new Float16() },
|
|
169
|
+
* vec2: { type: new Float16() }
|
|
170
|
+
* }
|
|
171
|
+
* }
|
|
173
172
|
* assert.deepEqual(table.schema, schema)
|
|
174
173
|
* ```
|
|
175
174
|
*/
|
package/dist/arrow.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
5
|
if (k2 === undefined) k2 = k;
|
|
17
6
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -218,6 +207,7 @@ exports.MakeArrowTableOptions = MakeArrowTableOptions;
|
|
|
218
207
|
* - Record<String, any> => Struct
|
|
219
208
|
* - Array<any> => List
|
|
220
209
|
* @example
|
|
210
|
+
* ```ts
|
|
221
211
|
* import { fromTableToBuffer, makeArrowTable } from "../arrow";
|
|
222
212
|
* import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
|
|
223
213
|
*
|
|
@@ -239,43 +229,41 @@ exports.MakeArrowTableOptions = MakeArrowTableOptions;
|
|
|
239
229
|
* names and data types.
|
|
240
230
|
*
|
|
241
231
|
* ```ts
|
|
242
|
-
*
|
|
243
232
|
* const schema = new Schema([
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
233
|
+
* new Field("a", new Float64()),
|
|
234
|
+
* new Field("b", new Float64()),
|
|
235
|
+
* new Field(
|
|
236
|
+
* "vector",
|
|
237
|
+
* new FixedSizeList(3, new Field("item", new Float32()))
|
|
238
|
+
* ),
|
|
239
|
+
* ]);
|
|
240
|
+
* const table = makeArrowTable([
|
|
241
|
+
* { a: 1, b: 2, vector: [1, 2, 3] },
|
|
242
|
+
* { a: 4, b: 5, vector: [4, 5, 6] },
|
|
243
|
+
* { a: 7, b: 8, vector: [7, 8, 9] },
|
|
244
|
+
* ]);
|
|
245
|
+
* assert.deepEqual(table.schema, schema);
|
|
257
246
|
* ```
|
|
258
247
|
*
|
|
259
248
|
* You can specify the vector column types and names using the options as well
|
|
260
249
|
*
|
|
261
|
-
* ```
|
|
262
|
-
*
|
|
250
|
+
* ```ts
|
|
263
251
|
* const schema = new Schema([
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
252
|
+
* new Field('a', new Float64()),
|
|
253
|
+
* new Field('b', new Float64()),
|
|
254
|
+
* new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
|
|
255
|
+
* new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
|
|
256
|
+
* ]);
|
|
269
257
|
* const table = makeArrowTable([
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
258
|
+
* { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
|
|
259
|
+
* { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
|
|
260
|
+
* { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
|
|
261
|
+
* ], {
|
|
262
|
+
* vectorColumns: {
|
|
263
|
+
* vec1: { type: new Float16() },
|
|
264
|
+
* vec2: { type: new Float16() }
|
|
265
|
+
* }
|
|
266
|
+
* }
|
|
279
267
|
* assert.deepEqual(table.schema, schema)
|
|
280
268
|
* ```
|
|
281
269
|
*/
|
|
@@ -499,6 +487,12 @@ async function applyEmbeddings(table, embeddings, schema) {
|
|
|
499
487
|
else if (embeddings == null || embeddings === undefined) {
|
|
500
488
|
return table;
|
|
501
489
|
}
|
|
490
|
+
let schemaMetadata = schema?.metadata || new Map();
|
|
491
|
+
if (!(embeddings == null || embeddings === undefined)) {
|
|
492
|
+
const registry = (0, registry_1.getRegistry)();
|
|
493
|
+
const embeddingMetadata = registry.getTableMetadata([embeddings]);
|
|
494
|
+
schemaMetadata = new Map([...schemaMetadata, ...embeddingMetadata]);
|
|
495
|
+
}
|
|
502
496
|
// Convert from ArrowTable to Record<String, Vector>
|
|
503
497
|
const colEntries = [...Array(table.numCols).keys()].map((_, idx) => {
|
|
504
498
|
const name = table.schema.fields[idx].name;
|
|
@@ -553,13 +547,14 @@ async function applyEmbeddings(table, embeddings, schema) {
|
|
|
553
547
|
const destType = newVectorType(vectors[0].length, innerDestType);
|
|
554
548
|
newColumns[destColumn] = makeVector(vectors, destType);
|
|
555
549
|
}
|
|
556
|
-
|
|
550
|
+
let newTable = new apache_arrow_1.Table(newColumns);
|
|
557
551
|
if (schema != null) {
|
|
558
552
|
if (schema.fields.find((f) => f.name === destColumn) === undefined) {
|
|
559
553
|
throw new Error(`When using embedding functions and specifying a schema the schema should include the embedding column but the column ${destColumn} was missing`);
|
|
560
554
|
}
|
|
561
|
-
|
|
555
|
+
newTable = alignTable(newTable, schema);
|
|
562
556
|
}
|
|
557
|
+
newTable = new apache_arrow_1.Table(new apache_arrow_1.Schema(newTable.schema.fields, schemaMetadata), newTable.batches);
|
|
563
558
|
return newTable;
|
|
564
559
|
}
|
|
565
560
|
/**
|
package/dist/connection.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export interface TableNamesOptions {
|
|
|
105
105
|
*
|
|
106
106
|
* Any created tables are independent and will continue to work even if
|
|
107
107
|
* the underlying connection has been closed.
|
|
108
|
+
* @hideconstructor
|
|
108
109
|
*/
|
|
109
110
|
export declare abstract class Connection {
|
|
110
111
|
/**
|
|
@@ -167,8 +168,10 @@ export declare abstract class Connection {
|
|
|
167
168
|
*/
|
|
168
169
|
abstract dropTable(name: string): Promise<void>;
|
|
169
170
|
}
|
|
171
|
+
/** @hideconstructor */
|
|
170
172
|
export declare class LocalConnection extends Connection {
|
|
171
173
|
readonly inner: LanceDbConnection;
|
|
174
|
+
/** @hidden */
|
|
172
175
|
constructor(inner: LanceDbConnection);
|
|
173
176
|
isOpen(): boolean;
|
|
174
177
|
close(): void;
|
package/dist/connection.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.LocalConnection = exports.Connection = void 0;
|
|
17
6
|
exports.cleanseStorageOptions = cleanseStorageOptions;
|
|
18
7
|
const arrow_1 = require("./arrow");
|
|
8
|
+
const arrow_2 = require("./arrow");
|
|
19
9
|
const registry_1 = require("./embedding/registry");
|
|
10
|
+
const sanitize_1 = require("./sanitize");
|
|
20
11
|
const table_1 = require("./table");
|
|
21
12
|
/**
|
|
22
13
|
* A LanceDB Connection that allows you to open tables and create new ones.
|
|
@@ -35,6 +26,7 @@ const table_1 = require("./table");
|
|
|
35
26
|
*
|
|
36
27
|
* Any created tables are independent and will continue to work even if
|
|
37
28
|
* the underlying connection has been closed.
|
|
29
|
+
* @hideconstructor
|
|
38
30
|
*/
|
|
39
31
|
class Connection {
|
|
40
32
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
@@ -42,8 +34,10 @@ class Connection {
|
|
|
42
34
|
}
|
|
43
35
|
}
|
|
44
36
|
exports.Connection = Connection;
|
|
37
|
+
/** @hideconstructor */
|
|
45
38
|
class LocalConnection extends Connection {
|
|
46
39
|
inner;
|
|
40
|
+
/** @hidden */
|
|
47
41
|
constructor(inner) {
|
|
48
42
|
super();
|
|
49
43
|
this.inner = inner;
|
|
@@ -72,7 +66,7 @@ class LocalConnection extends Connection {
|
|
|
72
66
|
if (data === undefined) {
|
|
73
67
|
throw new Error("data is required");
|
|
74
68
|
}
|
|
75
|
-
const { buf, mode } = await
|
|
69
|
+
const { buf, mode } = await parseTableData(data, options);
|
|
76
70
|
let dataStorageVersion = "stable";
|
|
77
71
|
if (options?.dataStorageVersion !== undefined) {
|
|
78
72
|
dataStorageVersion = options.dataStorageVersion;
|
|
@@ -102,8 +96,8 @@ class LocalConnection extends Connection {
|
|
|
102
96
|
else if (options?.useLegacyFormat !== undefined) {
|
|
103
97
|
dataStorageVersion = options.useLegacyFormat ? "legacy" : "stable";
|
|
104
98
|
}
|
|
105
|
-
const table = (0,
|
|
106
|
-
const buf = await (0,
|
|
99
|
+
const table = (0, arrow_2.makeEmptyTable)(schema, metadata);
|
|
100
|
+
const buf = await (0, arrow_2.fromTableToBuffer)(table);
|
|
107
101
|
const innerTable = await this.inner.createEmptyTable(name, buf, mode, cleanseStorageOptions(options?.storageOptions), dataStorageVersion, options?.enableV2ManifestPaths);
|
|
108
102
|
return new table_1.LocalTable(innerTable);
|
|
109
103
|
}
|
|
@@ -147,3 +141,25 @@ function camelToSnakeCase(camel) {
|
|
|
147
141
|
}
|
|
148
142
|
return result;
|
|
149
143
|
}
|
|
144
|
+
async function parseTableData(data, options, streaming = false) {
|
|
145
|
+
let mode = options?.mode ?? "create";
|
|
146
|
+
const existOk = options?.existOk ?? false;
|
|
147
|
+
if (mode === "create" && existOk) {
|
|
148
|
+
mode = "exist_ok";
|
|
149
|
+
}
|
|
150
|
+
let table;
|
|
151
|
+
if ((0, arrow_1.isArrowTable)(data)) {
|
|
152
|
+
table = (0, sanitize_1.sanitizeTable)(data);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
table = (0, arrow_1.makeArrowTable)(data, options);
|
|
156
|
+
}
|
|
157
|
+
if (streaming) {
|
|
158
|
+
const buf = await (0, arrow_1.fromTableToStreamBuffer)(table, options?.embeddingFunction, options?.schema);
|
|
159
|
+
return { buf, mode };
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const buf = await (0, arrow_2.fromTableToBuffer)(table, options?.embeddingFunction, options?.schema);
|
|
163
|
+
return { buf, mode };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -50,15 +50,15 @@ export declare abstract class EmbeddingFunction<T = any, M extends FunctionOptio
|
|
|
50
50
|
*
|
|
51
51
|
* @param optionsOrDatatype - The options for the field or the datatype
|
|
52
52
|
*
|
|
53
|
-
* @see {@link
|
|
53
|
+
* @see {@link LanceSchema}
|
|
54
54
|
*/
|
|
55
55
|
sourceField(optionsOrDatatype: Partial<FieldOptions> | DataType): [DataType, Map<string, EmbeddingFunction>];
|
|
56
56
|
/**
|
|
57
57
|
* vectorField is used in combination with `LanceSchema` to provide a declarative data model
|
|
58
58
|
*
|
|
59
|
-
* @param
|
|
59
|
+
* @param optionsOrDatatype - The options for the field
|
|
60
60
|
*
|
|
61
|
-
* @see {@link
|
|
61
|
+
* @see {@link LanceSchema}
|
|
62
62
|
*/
|
|
63
63
|
vectorField(optionsOrDatatype?: Partial<FieldOptions> | DataType): [DataType, Map<string, EmbeddingFunction>];
|
|
64
64
|
/** The number of dimensions of the embeddings */
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0;
|
|
17
6
|
require("reflect-metadata");
|
|
@@ -32,7 +21,7 @@ class EmbeddingFunction {
|
|
|
32
21
|
*
|
|
33
22
|
* @param optionsOrDatatype - The options for the field or the datatype
|
|
34
23
|
*
|
|
35
|
-
* @see {@link
|
|
24
|
+
* @see {@link LanceSchema}
|
|
36
25
|
*/
|
|
37
26
|
sourceField(optionsOrDatatype) {
|
|
38
27
|
let datatype = "datatype" in optionsOrDatatype
|
|
@@ -49,9 +38,9 @@ class EmbeddingFunction {
|
|
|
49
38
|
/**
|
|
50
39
|
* vectorField is used in combination with `LanceSchema` to provide a declarative data model
|
|
51
40
|
*
|
|
52
|
-
* @param
|
|
41
|
+
* @param optionsOrDatatype - The options for the field
|
|
53
42
|
*
|
|
54
|
-
* @see {@link
|
|
43
|
+
* @see {@link LanceSchema}
|
|
55
44
|
*/
|
|
56
45
|
vectorField(optionsOrDatatype) {
|
|
57
46
|
let dtype;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "../arrow";
|
|
2
2
|
import { EmbeddingFunction } from "./embedding_function";
|
|
3
|
-
export { EmbeddingFunction, TextEmbeddingFunction } from "./embedding_function";
|
|
3
|
+
export { FieldOptions, EmbeddingFunction, TextEmbeddingFunction, FunctionOptions, EmbeddingFunctionConstructor, } from "./embedding_function";
|
|
4
4
|
export * from "./registry";
|
|
5
5
|
/**
|
|
6
6
|
* Create a schema with embedding functions.
|
package/dist/embedding/index.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
5
|
if (k2 === undefined) k2 = k;
|
|
17
6
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
package/dist/embedding/openai.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
16
5
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
6
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type EmbeddingFunction, type EmbeddingFunctionConstructor } from "./embedding_function";
|
|
2
2
|
import "reflect-metadata";
|
|
3
|
-
type CreateReturnType<T> = T extends {
|
|
3
|
+
export type CreateReturnType<T> = T extends {
|
|
4
4
|
init: () => Promise<void>;
|
|
5
5
|
} ? Promise<T> : T;
|
|
6
|
-
interface EmbeddingFunctionCreate<T extends EmbeddingFunction> {
|
|
6
|
+
export interface EmbeddingFunctionCreate<T extends EmbeddingFunction> {
|
|
7
7
|
create(options?: T["TOptions"]): CreateReturnType<T>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
@@ -20,8 +20,6 @@ export declare class EmbeddingFunctionRegistry {
|
|
|
20
20
|
length(): number;
|
|
21
21
|
/**
|
|
22
22
|
* Register an embedding function
|
|
23
|
-
* @param name The name of the function
|
|
24
|
-
* @param func The function to register
|
|
25
23
|
* @throws Error if the function is already registered
|
|
26
24
|
*/
|
|
27
25
|
register<T extends EmbeddingFunctionConstructor = EmbeddingFunctionConstructor>(this: EmbeddingFunctionRegistry, alias?: string): (ctor: T) => any;
|
|
@@ -52,4 +50,3 @@ export interface EmbeddingFunctionConfig {
|
|
|
52
50
|
vectorColumn?: string;
|
|
53
51
|
function: EmbeddingFunction;
|
|
54
52
|
}
|
|
55
|
-
export {};
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.EmbeddingFunctionRegistry = void 0;
|
|
17
6
|
exports.register = register;
|
|
@@ -33,8 +22,6 @@ class EmbeddingFunctionRegistry {
|
|
|
33
22
|
}
|
|
34
23
|
/**
|
|
35
24
|
* Register an embedding function
|
|
36
|
-
* @param name The name of the function
|
|
37
|
-
* @param func The function to register
|
|
38
25
|
* @throws Error if the function is already registered
|
|
39
26
|
*/
|
|
40
27
|
register(alias) {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
16
5
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
6
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Connection } from "./connection";
|
|
2
2
|
import { ConnectionOptions } from "./native.js";
|
|
3
|
-
export {
|
|
3
|
+
export { AddColumnsSql, ColumnAlteration, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, } from "./native.js";
|
|
4
4
|
export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
|
|
5
|
-
export { Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
|
|
6
|
-
export { ExecutableQuery, Query, QueryBase, VectorQuery, RecordBatchIterator, } from "./query";
|
|
7
|
-
export { Index, IndexOptions, IvfPqOptions } from "./indices";
|
|
8
|
-
export { Table, AddDataOptions, UpdateOptions, OptimizeOptions } from "./table";
|
|
5
|
+
export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
|
|
6
|
+
export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, } from "./query";
|
|
7
|
+
export { Index, IndexOptions, IvfPqOptions, HnswPqOptions, HnswSqOptions, FtsOptions, } from "./indices";
|
|
8
|
+
export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, } from "./table";
|
|
9
|
+
export { MergeInsertBuilder } from "./merge";
|
|
9
10
|
export * as embedding from "./embedding";
|
|
10
11
|
export * as rerankers from "./rerankers";
|
|
12
|
+
export { SchemaLike, TableLike, FieldLike, RecordBatchLike, DataLike, IntoVector, } from "./arrow";
|
|
13
|
+
export { IntoSql } from "./util";
|
|
11
14
|
/**
|
|
12
15
|
* Connect to a LanceDB instance at the given URI.
|
|
13
16
|
*
|
|
@@ -19,6 +22,7 @@ export * as rerankers from "./rerankers";
|
|
|
19
22
|
* @param {string} uri - The uri of the database. If the database uri starts
|
|
20
23
|
* with `db://` then it connects to a remote database.
|
|
21
24
|
* @see {@link ConnectionOptions} for more details on the URI format.
|
|
25
|
+
* @param options - The options to use when connecting to the database
|
|
22
26
|
* @example
|
|
23
27
|
* ```ts
|
|
24
28
|
* const conn = await connect("/path/to/database");
|
|
@@ -31,7 +35,7 @@ export * as rerankers from "./rerankers";
|
|
|
31
35
|
* });
|
|
32
36
|
* ```
|
|
33
37
|
*/
|
|
34
|
-
export declare function connect(uri: string,
|
|
38
|
+
export declare function connect(uri: string, options?: Partial<ConnectionOptions>): Promise<Connection>;
|
|
35
39
|
/**
|
|
36
40
|
* Connect to a LanceDB instance at the given URI.
|
|
37
41
|
*
|
|
@@ -50,6 +54,6 @@ export declare function connect(uri: string, opts?: Partial<ConnectionOptions>):
|
|
|
50
54
|
* });
|
|
51
55
|
* ```
|
|
52
56
|
*/
|
|
53
|
-
export declare function connect(
|
|
57
|
+
export declare function connect(options: Partial<ConnectionOptions> & {
|
|
54
58
|
uri: string;
|
|
55
59
|
}): Promise<Connection>;
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.rerankers = exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable =
|
|
5
|
+
exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
|
|
17
6
|
exports.connect = connect;
|
|
18
7
|
const connection_1 = require("./connection");
|
|
19
8
|
const native_js_1 = require("./native.js");
|
|
20
|
-
var native_js_2 = require("./native.js");
|
|
21
|
-
Object.defineProperty(exports, "WriteMode", { enumerable: true, get: function () { return native_js_2.WriteMode; } });
|
|
22
9
|
var arrow_1 = require("./arrow");
|
|
23
10
|
Object.defineProperty(exports, "makeArrowTable", { enumerable: true, get: function () { return arrow_1.makeArrowTable; } });
|
|
24
11
|
Object.defineProperty(exports, "MakeArrowTableOptions", { enumerable: true, get: function () { return arrow_1.MakeArrowTableOptions; } });
|
|
@@ -34,14 +21,16 @@ var indices_1 = require("./indices");
|
|
|
34
21
|
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return indices_1.Index; } });
|
|
35
22
|
var table_1 = require("./table");
|
|
36
23
|
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return table_1.Table; } });
|
|
24
|
+
var merge_1 = require("./merge");
|
|
25
|
+
Object.defineProperty(exports, "MergeInsertBuilder", { enumerable: true, get: function () { return merge_1.MergeInsertBuilder; } });
|
|
37
26
|
exports.embedding = require("./embedding");
|
|
38
27
|
exports.rerankers = require("./rerankers");
|
|
39
|
-
async function connect(uriOrOptions,
|
|
28
|
+
async function connect(uriOrOptions, options = {}) {
|
|
40
29
|
let uri;
|
|
41
30
|
if (typeof uriOrOptions !== "string") {
|
|
42
|
-
const { uri: uri_, ...
|
|
31
|
+
const { uri: uri_, ...opts } = uriOrOptions;
|
|
43
32
|
uri = uri_;
|
|
44
|
-
|
|
33
|
+
options = opts;
|
|
45
34
|
}
|
|
46
35
|
else {
|
|
47
36
|
uri = uriOrOptions;
|
|
@@ -49,8 +38,8 @@ async function connect(uriOrOptions, opts = {}) {
|
|
|
49
38
|
if (!uri) {
|
|
50
39
|
throw new Error("uri is required");
|
|
51
40
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const nativeConn = await native_js_1.Connection.new(uri,
|
|
41
|
+
options = options ?? {};
|
|
42
|
+
options.storageOptions = (0, connection_1.cleanseStorageOptions)(options.storageOptions);
|
|
43
|
+
const nativeConn = await native_js_1.Connection.new(uri, options);
|
|
55
44
|
return new connection_1.LocalConnection(nativeConn);
|
|
56
45
|
}
|
package/dist/indices.d.ts
CHANGED
|
@@ -426,8 +426,6 @@ export declare class Index {
|
|
|
426
426
|
* The results of a full text search are ordered by relevance measured by BM25.
|
|
427
427
|
*
|
|
428
428
|
* You can combine filters with full text search.
|
|
429
|
-
*
|
|
430
|
-
* For now, the full text search index only supports English, and doesn't support phrase search.
|
|
431
429
|
*/
|
|
432
430
|
static fts(options?: Partial<FtsOptions>): Index;
|
|
433
431
|
/**
|