@lancedb/lancedb 0.7.1 → 0.8.0

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 (86) hide show
  1. package/dist/arrow.d.ts +5 -3
  2. package/dist/arrow.js +1 -1
  3. package/dist/embedding/embedding_function.d.ts +4 -3
  4. package/dist/embedding/index.d.ts +1 -0
  5. package/dist/embedding/index.js +1 -0
  6. package/dist/embedding/registry.d.ts +9 -7
  7. package/dist/embedding/registry.js +24 -6
  8. package/dist/embedding/transformers.d.ts +37 -0
  9. package/dist/embedding/transformers.js +147 -0
  10. package/dist/query.js +15 -9
  11. package/dist/remote/client.d.ts +1 -1
  12. package/dist/remote/client.js +6 -8
  13. package/dist/remote/connection.d.ts +2 -3
  14. package/dist/remote/connection.js +2 -2
  15. package/dist/table.d.ts +3 -0
  16. package/dist/table.js +1 -1
  17. package/package.json +17 -14
  18. package/Cargo.toml +0 -28
  19. package/biome.json +0 -158
  20. package/build.rs +0 -5
  21. package/dist/native.d.ts +0 -208
  22. package/examples/ann_indexes.ts +0 -49
  23. package/examples/basic.ts +0 -149
  24. package/examples/embedding.ts +0 -83
  25. package/examples/filtering.ts +0 -34
  26. package/examples/jsconfig.json +0 -27
  27. package/examples/package-lock.json +0 -79
  28. package/examples/package.json +0 -18
  29. package/examples/search.ts +0 -37
  30. package/jest.config.js +0 -7
  31. package/lancedb/arrow.ts +0 -947
  32. package/lancedb/connection.ts +0 -333
  33. package/lancedb/embedding/embedding_function.ts +0 -194
  34. package/lancedb/embedding/index.ts +0 -113
  35. package/lancedb/embedding/openai.ts +0 -113
  36. package/lancedb/embedding/registry.ts +0 -188
  37. package/lancedb/index.ts +0 -142
  38. package/lancedb/indices.ts +0 -203
  39. package/lancedb/merge.ts +0 -70
  40. package/lancedb/query.ts +0 -507
  41. package/lancedb/remote/client.ts +0 -221
  42. package/lancedb/remote/connection.ts +0 -201
  43. package/lancedb/remote/index.ts +0 -3
  44. package/lancedb/remote/table.ts +0 -226
  45. package/lancedb/sanitize.ts +0 -588
  46. package/lancedb/table.ts +0 -669
  47. package/lancedb/util.ts +0 -69
  48. package/native.d.ts +0 -208
  49. package/nodejs-artifacts/arrow.d.ts +0 -250
  50. package/nodejs-artifacts/arrow.js +0 -768
  51. package/nodejs-artifacts/connection.d.ts +0 -171
  52. package/nodejs-artifacts/connection.js +0 -135
  53. package/nodejs-artifacts/embedding/embedding_function.d.ts +0 -79
  54. package/nodejs-artifacts/embedding/embedding_function.js +0 -112
  55. package/nodejs-artifacts/embedding/index.d.ts +0 -28
  56. package/nodejs-artifacts/embedding/index.js +0 -114
  57. package/nodejs-artifacts/embedding/openai.d.ts +0 -18
  58. package/nodejs-artifacts/embedding/openai.js +0 -105
  59. package/nodejs-artifacts/embedding/registry.d.ts +0 -53
  60. package/nodejs-artifacts/embedding/registry.js +0 -127
  61. package/nodejs-artifacts/index.d.ts +0 -55
  62. package/nodejs-artifacts/index.js +0 -57
  63. package/nodejs-artifacts/indices.d.ts +0 -165
  64. package/nodejs-artifacts/indices.js +0 -71
  65. package/nodejs-artifacts/merge.d.ts +0 -54
  66. package/nodejs-artifacts/merge.js +0 -64
  67. package/nodejs-artifacts/native.d.ts +0 -208
  68. package/nodejs-artifacts/native.js +0 -330
  69. package/nodejs-artifacts/query.d.ts +0 -283
  70. package/nodejs-artifacts/query.js +0 -448
  71. package/nodejs-artifacts/remote/client.d.ts +0 -28
  72. package/nodejs-artifacts/remote/client.js +0 -172
  73. package/nodejs-artifacts/remote/connection.d.ts +0 -25
  74. package/nodejs-artifacts/remote/connection.js +0 -110
  75. package/nodejs-artifacts/remote/index.d.ts +0 -3
  76. package/nodejs-artifacts/remote/index.js +0 -9
  77. package/nodejs-artifacts/remote/table.d.ts +0 -42
  78. package/nodejs-artifacts/remote/table.js +0 -179
  79. package/nodejs-artifacts/sanitize.d.ts +0 -31
  80. package/nodejs-artifacts/sanitize.js +0 -436
  81. package/nodejs-artifacts/table.d.ts +0 -395
  82. package/nodejs-artifacts/table.js +0 -230
  83. package/nodejs-artifacts/util.d.ts +0 -14
  84. package/nodejs-artifacts/util.js +0 -65
  85. package/tsconfig.json +0 -25
  86. package/typedoc.json +0 -10
@@ -1,283 +0,0 @@
1
- import { Table as ArrowTable, type IntoVector, RecordBatch } from "./arrow";
2
- import { type IvfPqOptions } from "./indices";
3
- import { RecordBatchIterator as NativeBatchIterator, Query as NativeQuery, Table as NativeTable, VectorQuery as NativeVectorQuery } from "./native";
4
- export declare class RecordBatchIterator implements AsyncIterator<RecordBatch> {
5
- private promisedInner?;
6
- private inner?;
7
- constructor(promise?: Promise<NativeBatchIterator>);
8
- next(): Promise<IteratorResult<RecordBatch<any>>>;
9
- }
10
- /**
11
- * Options that control the behavior of a particular query execution
12
- */
13
- export interface QueryExecutionOptions {
14
- /**
15
- * The maximum number of rows to return in a single batch
16
- *
17
- * Batches may have fewer rows if the underlying data is stored
18
- * in smaller chunks.
19
- */
20
- maxBatchLength?: number;
21
- }
22
- /** Common methods supported by all query types */
23
- export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery> implements AsyncIterable<RecordBatch> {
24
- protected inner: NativeQueryType | Promise<NativeQueryType>;
25
- protected constructor(inner: NativeQueryType | Promise<NativeQueryType>);
26
- protected doCall(fn: (inner: NativeQueryType) => void): void;
27
- /**
28
- * A filter statement to be applied to this query.
29
- *
30
- * The filter should be supplied as an SQL query string. For example:
31
- * @example
32
- * x > 10
33
- * y > 0 AND y < 100
34
- * x > 5 OR y = 'test'
35
- *
36
- * Filtering performance can often be improved by creating a scalar index
37
- * on the filter column(s).
38
- */
39
- where(predicate: string): this;
40
- /**
41
- * A filter statement to be applied to this query.
42
- * @alias where
43
- * @deprecated Use `where` instead
44
- */
45
- filter(predicate: string): this;
46
- /**
47
- * Return only the specified columns.
48
- *
49
- * By default a query will return all columns from the table. However, this can have
50
- * a very significant impact on latency. LanceDb stores data in a columnar fashion. This
51
- * means we can finely tune our I/O to select exactly the columns we need.
52
- *
53
- * As a best practice you should always limit queries to the columns that you need. If you
54
- * pass in an array of column names then only those columns will be returned.
55
- *
56
- * You can also use this method to create new "dynamic" columns based on your existing columns.
57
- * For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
58
- * seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
59
- *
60
- * To create dynamic columns you can pass in a Map<string, string>. A column will be returned
61
- * for each entry in the map. The key provides the name of the column. The value is
62
- * an SQL string used to specify how the column is calculated.
63
- *
64
- * For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
65
- * input to this method would be:
66
- * @example
67
- * new Map([["combined", "a + b"], ["c", "c"]])
68
- *
69
- * Columns will always be returned in the order given, even if that order is different than
70
- * the order used when adding the data.
71
- *
72
- * Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
73
- * uses `Object.entries` which should preserve the insertion order of the object. However,
74
- * object insertion order is easy to get wrong and `Map` is more foolproof.
75
- */
76
- select(columns: string[] | Map<string, string> | Record<string, string> | string): this;
77
- /**
78
- * Set the maximum number of results to return.
79
- *
80
- * By default, a plain search has no limit. If this method is not
81
- * called then every valid row from the table will be returned.
82
- */
83
- limit(limit: number): this;
84
- protected nativeExecute(options?: Partial<QueryExecutionOptions>): Promise<NativeBatchIterator>;
85
- /**
86
- * Execute the query and return the results as an @see {@link AsyncIterator}
87
- * of @see {@link RecordBatch}.
88
- *
89
- * By default, LanceDb will use many threads to calculate results and, when
90
- * the result set is large, multiple batches will be processed at one time.
91
- * This readahead is limited however and backpressure will be applied if this
92
- * stream is consumed slowly (this constrains the maximum memory used by a
93
- * single query)
94
- *
95
- */
96
- protected execute(options?: Partial<QueryExecutionOptions>): RecordBatchIterator;
97
- [Symbol.asyncIterator](): AsyncIterator<RecordBatch<any>>;
98
- /** Collect the results as an Arrow @see {@link ArrowTable}. */
99
- toArrow(options?: Partial<QueryExecutionOptions>): Promise<ArrowTable>;
100
- /** Collect the results as an array of objects. */
101
- toArray(options?: Partial<QueryExecutionOptions>): Promise<any[]>;
102
- /**
103
- * Generates an explanation of the query execution plan.
104
- *
105
- * @example
106
- * import * as lancedb from "@lancedb/lancedb"
107
- * const db = await lancedb.connect("./.lancedb");
108
- * const table = await db.createTable("my_table", [
109
- * { vector: [1.1, 0.9], id: "1" },
110
- * ]);
111
- * const plan = await table.query().nearestTo([0.5, 0.2]).explainPlan();
112
- *
113
- * @param verbose - If true, provides a more detailed explanation. Defaults to false.
114
- * @returns A Promise that resolves to a string containing the query execution plan explanation.
115
- */
116
- explainPlan(verbose?: boolean): Promise<string>;
117
- }
118
- /**
119
- * An interface for a query that can be executed
120
- *
121
- * Supported by all query types
122
- */
123
- export interface ExecutableQuery {
124
- }
125
- /**
126
- * A builder used to construct a vector search
127
- *
128
- * This builder can be reused to execute the query many times.
129
- */
130
- export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
131
- constructor(inner: NativeVectorQuery | Promise<NativeVectorQuery>);
132
- /**
133
- * Set the number of partitions to search (probe)
134
- *
135
- * This argument is only used when the vector column has an IVF PQ index.
136
- * If there is no index then this value is ignored.
137
- *
138
- * The IVF stage of IVF PQ divides the input into partitions (clusters) of
139
- * related values.
140
- *
141
- * The partition whose centroids are closest to the query vector will be
142
- * exhaustiely searched to find matches. This parameter controls how many
143
- * partitions should be searched.
144
- *
145
- * Increasing this value will increase the recall of your query but will
146
- * also increase the latency of your query. The default value is 20. This
147
- * default is good for many cases but the best value to use will depend on
148
- * your data and the recall that you need to achieve.
149
- *
150
- * For best results we recommend tuning this parameter with a benchmark against
151
- * your actual data to find the smallest possible value that will still give
152
- * you the desired recall.
153
- */
154
- nprobes(nprobes: number): VectorQuery;
155
- /**
156
- * Set the vector column to query
157
- *
158
- * This controls which column is compared to the query vector supplied in
159
- * the call to @see {@link Query#nearestTo}
160
- *
161
- * This parameter must be specified if the table has more than one column
162
- * whose data type is a fixed-size-list of floats.
163
- */
164
- column(column: string): VectorQuery;
165
- /**
166
- * Set the distance metric to use
167
- *
168
- * When performing a vector search we try and find the "nearest" vectors according
169
- * to some kind of distance metric. This parameter controls which distance metric to
170
- * use. See @see {@link IvfPqOptions.distanceType} for more details on the different
171
- * distance metrics available.
172
- *
173
- * Note: if there is a vector index then the distance type used MUST match the distance
174
- * type used to train the vector index. If this is not done then the results will be
175
- * invalid.
176
- *
177
- * By default "l2" is used.
178
- */
179
- distanceType(distanceType: Required<IvfPqOptions>["distanceType"]): VectorQuery;
180
- /**
181
- * A multiplier to control how many additional rows are taken during the refine step
182
- *
183
- * This argument is only used when the vector column has an IVF PQ index.
184
- * If there is no index then this value is ignored.
185
- *
186
- * An IVF PQ index stores compressed (quantized) values. They query vector is compared
187
- * against these values and, since they are compressed, the comparison is inaccurate.
188
- *
189
- * This parameter can be used to refine the results. It can improve both improve recall
190
- * and correct the ordering of the nearest results.
191
- *
192
- * To refine results LanceDb will first perform an ANN search to find the nearest
193
- * `limit` * `refine_factor` results. In other words, if `refine_factor` is 3 and
194
- * `limit` is the default (10) then the first 30 results will be selected. LanceDb
195
- * then fetches the full, uncompressed, values for these 30 results. The results are
196
- * then reordered by the true distance and only the nearest 10 are kept.
197
- *
198
- * Note: there is a difference between calling this method with a value of 1 and never
199
- * calling this method at all. Calling this method with any value will have an impact
200
- * on your search latency. When you call this method with a `refine_factor` of 1 then
201
- * LanceDb still needs to fetch the full, uncompressed, values so that it can potentially
202
- * reorder the results.
203
- *
204
- * Note: if this method is NOT called then the distances returned in the _distance column
205
- * will be approximate distances based on the comparison of the quantized query vector
206
- * and the quantized result vectors. This can be considerably different than the true
207
- * distance between the query vector and the actual uncompressed vector.
208
- */
209
- refineFactor(refineFactor: number): VectorQuery;
210
- /**
211
- * If this is called then filtering will happen after the vector search instead of
212
- * before.
213
- *
214
- * By default filtering will be performed before the vector search. This is how
215
- * filtering is typically understood to work. This prefilter step does add some
216
- * additional latency. Creating a scalar index on the filter column(s) can
217
- * often improve this latency. However, sometimes a filter is too complex or scalar
218
- * indices cannot be applied to the column. In these cases postfiltering can be
219
- * used instead of prefiltering to improve latency.
220
- *
221
- * Post filtering applies the filter to the results of the vector search. This means
222
- * we only run the filter on a much smaller set of data. However, it can cause the
223
- * query to return fewer than `limit` results (or even no results) if none of the nearest
224
- * results match the filter.
225
- *
226
- * Post filtering happens during the "refine stage" (described in more detail in
227
- * @see {@link VectorQuery#refineFactor}). This means that setting a higher refine
228
- * factor can often help restore some of the results lost by post filtering.
229
- */
230
- postfilter(): VectorQuery;
231
- /**
232
- * If this is called then any vector index is skipped
233
- *
234
- * An exhaustive (flat) search will be performed. The query vector will
235
- * be compared to every vector in the table. At high scales this can be
236
- * expensive. However, this is often still useful. For example, skipping
237
- * the vector index can give you ground truth results which you can use to
238
- * calculate your recall to select an appropriate value for nprobes.
239
- */
240
- bypassVectorIndex(): VectorQuery;
241
- }
242
- /** A builder for LanceDB queries. */
243
- export declare class Query extends QueryBase<NativeQuery> {
244
- constructor(tbl: NativeTable);
245
- /**
246
- * Find the nearest vectors to the given query vector.
247
- *
248
- * This converts the query from a plain query to a vector query.
249
- *
250
- * This method will attempt to convert the input to the query vector
251
- * expected by the embedding model. If the input cannot be converted
252
- * then an error will be thrown.
253
- *
254
- * By default, there is no embedding model, and the input should be
255
- * an array-like object of numbers (something that can be used as input
256
- * to Float32Array.from)
257
- *
258
- * If there is only one vector column (a column whose data type is a
259
- * fixed size list of floats) then the column does not need to be specified.
260
- * If there is more than one vector column you must use
261
- * @see {@link VectorQuery#column} to specify which column you would like
262
- * to compare with.
263
- *
264
- * If no index has been created on the vector column then a vector query
265
- * will perform a distance comparison between the query vector and every
266
- * vector in the database and then sort the results. This is sometimes
267
- * called a "flat search"
268
- *
269
- * For small databases, with a few hundred thousand vectors or less, this can
270
- * be reasonably fast. In larger databases you should create a vector index
271
- * on the column. If there is a vector index then an "approximate" nearest
272
- * neighbor search (frequently called an ANN search) will be performed. This
273
- * search is much faster, but the results will be approximate.
274
- *
275
- * The query can be further parameterized using the returned builder. There
276
- * are various ANN search parameters that will let you fine tune your recall
277
- * accuracy vs search latency.
278
- *
279
- * Vector searches always have a `limit`. If `limit` has not been called then
280
- * a default `limit` of 10 will be used. @see {@link Query#limit}
281
- */
282
- nearestTo(vector: IntoVector): VectorQuery;
283
- }