@lancedb/lancedb 0.5.1 → 0.5.2

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.
@@ -53,6 +53,11 @@ class Table {
53
53
  display() {
54
54
  return this.inner.display();
55
55
  }
56
+ async #getEmbeddingFunctions() {
57
+ const schema = await this.schema();
58
+ const registry = (0, registry_1.getRegistry)();
59
+ return registry.parseFunctions(schema.metadata);
60
+ }
56
61
  /** Get the schema of the table. */
57
62
  async schema() {
58
63
  const schemaBuf = await this.inner.schema();
@@ -68,7 +73,7 @@ class Table {
68
73
  const schema = await this.schema();
69
74
  const registry = (0, registry_1.getRegistry)();
70
75
  const functions = registry.parseFunctions(schema.metadata);
71
- const buffer = await (0, arrow_1.fromDataToBuffer)(data, functions.values().next().value);
76
+ const buffer = await (0, arrow_1.fromDataToBuffer)(data, functions.values().next().value, schema);
72
77
  await this.inner.add(buffer, mode);
73
78
  }
74
79
  /**
@@ -200,6 +205,24 @@ class Table {
200
205
  query() {
201
206
  return new query_1.Query(this.inner);
202
207
  }
208
+ search(query) {
209
+ if (typeof query !== "string") {
210
+ return this.vectorSearch(query);
211
+ }
212
+ else {
213
+ return this.#getEmbeddingFunctions().then(async (functions) => {
214
+ // TODO: Support multiple embedding functions
215
+ const embeddingFunc = functions
216
+ .values()
217
+ .next().value;
218
+ if (!embeddingFunc) {
219
+ return Promise.reject(new Error("No embedding functions are defined in the table"));
220
+ }
221
+ const embeddings = await embeddingFunc.function.computeQueryEmbeddings(query);
222
+ return this.query().nearestTo(embeddings);
223
+ });
224
+ }
225
+ }
203
226
  /**
204
227
  * Search the table with a given query vector.
205
228
  *
@@ -342,5 +365,9 @@ class Table {
342
365
  async listIndices() {
343
366
  return await this.inner.listIndices();
344
367
  }
368
+ /** Return the table as an arrow table */
369
+ async toArrow() {
370
+ return await this.query().toArrow();
371
+ }
345
372
  }
346
373
  exports.Table = Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancedb/lancedb",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -77,10 +77,10 @@
77
77
  "reflect-metadata": "^0.2.2"
78
78
  },
79
79
  "optionalDependencies": {
80
- "@lancedb/lancedb-darwin-arm64": "0.5.1",
81
- "@lancedb/lancedb-linux-arm64-gnu": "0.5.1",
82
- "@lancedb/lancedb-darwin-x64": "0.5.1",
83
- "@lancedb/lancedb-linux-x64-gnu": "0.5.1",
84
- "@lancedb/lancedb-win32-x64-msvc": "0.5.1"
80
+ "@lancedb/lancedb-darwin-arm64": "0.5.2",
81
+ "@lancedb/lancedb-linux-arm64-gnu": "0.5.2",
82
+ "@lancedb/lancedb-darwin-x64": "0.5.2",
83
+ "@lancedb/lancedb-linux-x64-gnu": "0.5.2",
84
+ "@lancedb/lancedb-win32-x64-msvc": "0.5.2"
85
85
  }
86
86
  }