From 69295548ccabce0c60b1298578f3d1d737754324 Mon Sep 17 00:00:00 2001 From: Cory Grinstead Date: Mon, 22 Jul 2024 12:26:49 -0500 Subject: [PATCH] docs: minor updates for js migration guides (#1451) Co-authored-by: Will Jones --- docs/mkdocs.yml | 4 +- docs/src/api_reference.md | 2 +- docs/src/basic_legacy.ts | 79 ++- docs/src/guides/tables.md | 30 +- docs/src/js/README.md | 23 +- docs/src/js/classes/Connection.md | 207 +++--- docs/src/js/classes/Index.md | 73 +- docs/src/js/classes/MakeArrowTableOptions.md | 58 +- docs/src/js/classes/Query.md | 285 ++++---- docs/src/js/classes/QueryBase.md | 261 +++---- docs/src/js/classes/RecordBatchIterator.md | 67 +- docs/src/js/classes/Table.md | 640 ++++++++++-------- docs/src/js/classes/VectorColumnOptions.md | 34 +- docs/src/js/classes/VectorQuery.md | 356 +++++----- .../embedding.OpenAIEmbeddingFunction.md | 111 --- docs/src/js/enumerations/WriteMode.md | 27 + docs/src/js/enums/WriteMode.md | 43 -- docs/src/js/functions/connect.md | 82 +++ .../makeArrowTable.md} | 121 +--- docs/src/js/globals.md | 51 ++ docs/src/js/interfaces/AddColumnsSql.md | 27 +- docs/src/js/interfaces/AddDataOptions.md | 18 +- docs/src/js/interfaces/ColumnAlteration.md | 40 +- docs/src/js/interfaces/ConnectionOptions.md | 48 +- docs/src/js/interfaces/CreateTableOptions.md | 58 +- docs/src/js/interfaces/ExecutableQuery.md | 6 +- docs/src/js/interfaces/IndexConfig.md | 33 +- docs/src/js/interfaces/IndexMetadata.md | 19 + docs/src/js/interfaces/IndexOptions.md | 31 +- docs/src/js/interfaces/IndexStatistics.md | 39 ++ docs/src/js/interfaces/IvfPqOptions.md | 64 +- docs/src/js/interfaces/TableNamesOptions.md | 31 +- docs/src/js/interfaces/UpdateOptions.md | 18 +- docs/src/js/interfaces/WriteOptions.md | 20 +- .../interfaces/embedding.EmbeddingFunction.md | 129 ---- docs/src/js/modules/embedding.md | 45 -- docs/src/js/namespaces/embedding/README.md | 29 + .../embedding/classes/EmbeddingFunction.md | 162 +++++ .../classes/EmbeddingFunctionRegistry.md | 124 ++++ .../classes/OpenAIEmbeddingFunction.md | 196 ++++++ .../embedding/functions/LanceSchema.md | 39 ++ .../embedding/functions/getRegistry.md | 23 + .../embedding/functions/register.md | 25 + .../interfaces/EmbeddingFunctionConfig.md | 25 + .../embedding/type-aliases/OpenAIOptions.md | 19 + docs/src/js/type-aliases/Data.md | 11 + docs/src/migration.md | 101 ++- nodejs/examples/basic.ts | 37 +- nodejs/package-lock.json | 227 ++++--- nodejs/package.json | 4 +- nodejs/typedoc.json | 4 +- 51 files changed, 2353 insertions(+), 1853 deletions(-) delete mode 100644 docs/src/js/classes/embedding.OpenAIEmbeddingFunction.md create mode 100644 docs/src/js/enumerations/WriteMode.md delete mode 100644 docs/src/js/enums/WriteMode.md create mode 100644 docs/src/js/functions/connect.md rename docs/src/js/{modules.md => functions/makeArrowTable.md} (50%) create mode 100644 docs/src/js/globals.md create mode 100644 docs/src/js/interfaces/IndexMetadata.md create mode 100644 docs/src/js/interfaces/IndexStatistics.md delete mode 100644 docs/src/js/interfaces/embedding.EmbeddingFunction.md delete mode 100644 docs/src/js/modules/embedding.md create mode 100644 docs/src/js/namespaces/embedding/README.md create mode 100644 docs/src/js/namespaces/embedding/classes/EmbeddingFunction.md create mode 100644 docs/src/js/namespaces/embedding/classes/EmbeddingFunctionRegistry.md create mode 100644 docs/src/js/namespaces/embedding/classes/OpenAIEmbeddingFunction.md create mode 100644 docs/src/js/namespaces/embedding/functions/LanceSchema.md create mode 100644 docs/src/js/namespaces/embedding/functions/getRegistry.md create mode 100644 docs/src/js/namespaces/embedding/functions/register.md create mode 100644 docs/src/js/namespaces/embedding/interfaces/EmbeddingFunctionConfig.md create mode 100644 docs/src/js/namespaces/embedding/type-aliases/OpenAIOptions.md create mode 100644 docs/src/js/type-aliases/Data.md diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index a11d5071..e8b730a4 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -157,7 +157,7 @@ nav: - ⚙️ API reference: - 🐍 Python: python/python.md - 👾 JavaScript (vectordb): javascript/modules.md - - 👾 JavaScript (lancedb): javascript/modules.md + - 👾 JavaScript (lancedb): js/globals.md - 🦀 Rust: https://docs.rs/lancedb/latest/lancedb/ - ☁️ LanceDB Cloud: - Overview: cloud/index.md @@ -231,7 +231,7 @@ nav: - Overview: api_reference.md - Python: python/python.md - Javascript (vectordb): javascript/modules.md - - Javascript (lancedb): js/modules.md + - Javascript (lancedb): js/globals.md - Rust: https://docs.rs/lancedb/latest/lancedb/index.html - LanceDB Cloud: - Overview: cloud/index.md diff --git a/docs/src/api_reference.md b/docs/src/api_reference.md index 4157fba2..0eb22a83 100644 --- a/docs/src/api_reference.md +++ b/docs/src/api_reference.md @@ -4,5 +4,5 @@ The API reference for the LanceDB client SDKs are available at the following loc - [Python](python/python.md) - [JavaScript (legacy vectordb package)](javascript/modules.md) -- [JavaScript (newer @lancedb/lancedb package)](js/modules.md) +- [JavaScript (newer @lancedb/lancedb package)](js/globals.md) - [Rust](https://docs.rs/lancedb/latest/lancedb/index.html) diff --git a/docs/src/basic_legacy.ts b/docs/src/basic_legacy.ts index 646e6002..e95527cd 100644 --- a/docs/src/basic_legacy.ts +++ b/docs/src/basic_legacy.ts @@ -1,6 +1,14 @@ // --8<-- [start:import] import * as lancedb from "vectordb"; -import { Schema, Field, Float32, FixedSizeList, Int32, Float16 } from "apache-arrow"; +import { + Schema, + Field, + Float32, + FixedSizeList, + Int32, + Float16, +} from "apache-arrow"; +import * as arrow from "apache-arrow"; // --8<-- [end:import] import * as fs from "fs"; import { Table as ArrowTable, Utf8 } from "apache-arrow"; @@ -20,10 +28,33 @@ const example = async () => { { vector: [3.1, 4.1], item: "foo", price: 10.0 }, { vector: [5.9, 26.5], item: "bar", price: 20.0 }, ], - { writeMode: lancedb.WriteMode.Overwrite } + { writeMode: lancedb.WriteMode.Overwrite }, ); // --8<-- [end:create_table] - + { + // --8<-- [start:create_table_with_schema] + const schema = new arrow.Schema([ + new arrow.Field( + "vector", + new arrow.FixedSizeList( + 2, + new arrow.Field("item", new arrow.Float32(), true), + ), + ), + new arrow.Field("item", new arrow.Utf8(), true), + new arrow.Field("price", new arrow.Float32(), true), + ]); + const data = [ + { vector: [3.1, 4.1], item: "foo", price: 10.0 }, + { vector: [5.9, 26.5], item: "bar", price: 20.0 }, + ]; + const tbl = await db.createTable({ + name: "myTableWithSchema", + data, + schema, + }); + // --8<-- [end:create_table_with_schema] + } // --8<-- [start:add] const newData = Array.from({ length: 500 }, (_, i) => ({ @@ -43,33 +74,35 @@ const example = async () => { // --8<-- [end:create_index] // --8<-- [start:create_empty_table] - const schema = new Schema([ - new Field("id", new Int32()), - new Field("name", new Utf8()), + const schema = new arrow.Schema([ + new arrow.Field("id", new arrow.Int32()), + new arrow.Field("name", new arrow.Utf8()), ]); + const empty_tbl = await db.createTable({ name: "empty_table", schema }); // --8<-- [end:create_empty_table] - - // --8<-- [start:create_f16_table] - const dim = 16 - const total = 10 - const f16_schema = new Schema([ - new Field('id', new Int32()), + { + // --8<-- [start:create_f16_table] + const dim = 16; + const total = 10; + const schema = new Schema([ + new Field("id", new Int32()), new Field( - 'vector', - new FixedSizeList(dim, new Field('item', new Float16(), true)), - false - ) - ]) - const data = lancedb.makeArrowTable( + "vector", + new FixedSizeList(dim, new Field("item", new Float16(), true)), + false, + ), + ]); + const data = lancedb.makeArrowTable( Array.from(Array(total), (_, i) => ({ id: i, - vector: Array.from(Array(dim), Math.random) + vector: Array.from(Array(dim), Math.random), })), - { f16_schema } - ) - const table = await db.createTable('f16_tbl', data) - // --8<-- [end:create_f16_table] + { schema }, + ); + const table = await db.createTable("f16_tbl", data); + // --8<-- [end:create_f16_table] + } // --8<-- [start:search] const query = await tbl.search([100, 100]).limit(2).execute(); diff --git a/docs/src/guides/tables.md b/docs/src/guides/tables.md index cf58079b..4be12858 100644 --- a/docs/src/guides/tables.md +++ b/docs/src/guides/tables.md @@ -35,6 +35,7 @@ Initialize a LanceDB connection and create a table ```typescript const lancedb = require("vectordb"); + const arrow = require("apache-arrow"); const uri = "data/sample-lancedb"; const db = await lancedb.connect(uri); @@ -98,7 +99,6 @@ Initialize a LanceDB connection and create a table and the table exists, then it simply opens the existing table. The data you passed in will NOT be appended to the table in that case. - ```ts --8<-- "nodejs/examples/basic.ts:create_table_exists_ok" ``` @@ -116,14 +116,32 @@ Initialize a LanceDB connection and create a table --8<-- "docs/src/basic_legacy.ts:create_table" ``` - !!! warning - `existsOk` option is not supported in `vectordb` + This will infer the schema from the provided data. If you want to explicitly provide a schema, you can use apache-arrow to declare a schema + - Sometimes you want to make sure that you start fresh. If you want to - overwrite the table, you can pass in mode: "overwrite" to the createTable function. ```ts - const table = await con.createTable(tableName, data, { writeMode: WriteMode.Overwrite }) + --8<-- "docs/src/basic_legacy.ts:create_table_with_schema" + ``` + + !!! warning + `existsOk` is not available in `vectordb` + + + + If the table already exists, vectordb will raise an error by default. + You can use `writeMode: WriteMode.Overwrite` to overwrite the table. + But this will delete the existing table and create a new one with the same name. + + + Sometimes you want to make sure that you start fresh. + + If you want to overwrite the table, you can pass in `writeMode: lancedb.WriteMode.Overwrite` to the createTable function. + + ```ts + const table = await con.createTable(tableName, data, { + writeMode: WriteMode.Overwrite + }) ``` ### From a Pandas DataFrame diff --git a/docs/src/js/README.md b/docs/src/js/README.md index 74fc3e95..895872c3 100644 --- a/docs/src/js/README.md +++ b/docs/src/js/README.md @@ -1,4 +1,6 @@ -@lancedb/lancedb / [Exports](modules.md) +**@lancedb/lancedb** • [**Docs**](globals.md) + +*** # LanceDB JavaScript SDK @@ -45,29 +47,20 @@ 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: +LanceDb uses [biome](https://biomejs.dev/) for linting and formatting. if you are using VSCode you will need to install the official [Biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) extension. +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: +to automatically fix all fixable issues: ```sh -npm run chkformat +npm run lint-fix ``` -If you need to manually format your code you can run: - -```sh -npx prettier --write . -``` +If you do not have your workspace root set to the `nodejs` directory, unfortunately the extension will not work. You can still run the linting and formatting commands manually. ### Generating docs diff --git a/docs/src/js/classes/Connection.md b/docs/src/js/classes/Connection.md index 512f27b7..3ce77acd 100644 --- a/docs/src/js/classes/Connection.md +++ b/docs/src/js/classes/Connection.md @@ -1,6 +1,10 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Connection +[**@lancedb/lancedb**](../README.md) • **Docs** -# Class: Connection +*** + +[@lancedb/lancedb](../globals.md) / Connection + +# Class: `abstract` Connection A LanceDB Connection that allows you to open tables and create new ones. @@ -19,62 +23,21 @@ 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() -• **new Connection**(`inner`): [`Connection`](Connection.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `inner` | `Connection` | +> **new Connection**(): [`Connection`](Connection.md) #### 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() -▸ **close**(): `void` +> `abstract` **close**(): `void` Close the connection, releasing any underlying resources. @@ -86,63 +49,78 @@ Any attempt to use the connection after it is closed will result in an error. `void` -#### Defined in +*** -[connection.ts:88](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L88) +### createEmptyTable() -___ - -### createEmptyTable - -▸ **createEmptyTable**(`name`, `schema`, `options?`): `Promise`\<[`Table`](Table.md)\> +> `abstract` **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)\> | - | +• **name**: `string` + +The name of the table. + +• **schema**: `SchemaLike` + +The schema of the table + +• **options?**: `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)> #### Returns -`Promise`\<[`Table`](Table.md)\> +`Promise`<[`Table`](Table.md)> -#### Defined in +*** -[connection.ts:151](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L151) +### createTable() -___ +#### createTable(options) -### createTable - -▸ **createTable**(`name`, `data`, `options?`): `Promise`\<[`Table`](Table.md)\> +> `abstract` **createTable**(`options`): `Promise`<[`Table`](Table.md)> Creates a new Table and initialize it with new data. -#### Parameters +##### 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)\> | - | +• **options**: `object` & `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)> -#### Returns +The options object. -`Promise`\<[`Table`](Table.md)\> +##### Returns -#### Defined in +`Promise`<[`Table`](Table.md)> -[connection.ts:123](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L123) +#### createTable(name, data, options) -___ +> `abstract` **createTable**(`name`, `data`, `options`?): `Promise`<[`Table`](Table.md)> -### display +Creates a new Table and initialize it with new data. -▸ **display**(): `string` +##### Parameters + +• **name**: `string` + +The name of the table. + +• **data**: `TableLike` \| `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)> + +*** + +### display() + +> `abstract` **display**(): `string` Return a brief description of the connection @@ -150,37 +128,29 @@ Return a brief description of the connection `string` -#### Defined in +*** -[connection.ts:93](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L93) +### dropTable() -___ - -### dropTable - -▸ **dropTable**(`name`): `Promise`\<`void`\> +> `abstract` **dropTable**(`name`): `Promise`<`void`> Drop an existing table. #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `name` | `string` | The name of the table to drop. | +• **name**: `string` + +The name of the table to drop. #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +*** -[connection.ts:173](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L173) +### isOpen() -___ - -### isOpen - -▸ **isOpen**(): `boolean` +> `abstract` **isOpen**(): `boolean` Return true if the connection has not been closed @@ -188,37 +158,31 @@ Return true if the connection has not been closed `boolean` -#### Defined in +*** -[connection.ts:77](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L77) +### openTable() -___ - -### openTable - -▸ **openTable**(`name`): `Promise`\<[`Table`](Table.md)\> +> `abstract` **openTable**(`name`, `options`?): `Promise`<[`Table`](Table.md)> Open a table in the database. #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `name` | `string` | The name of the table | +• **name**: `string` + +The name of the table + +• **options?**: `Partial`<`OpenTableOptions`> #### Returns -`Promise`\<[`Table`](Table.md)\> +`Promise`<[`Table`](Table.md)> -#### Defined in +*** -[connection.ts:112](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/connection.ts#L112) +### tableNames() -___ - -### tableNames - -▸ **tableNames**(`options?`): `Promise`\<`string`[]\> +> `abstract` **tableNames**(`options`?): `Promise`<`string`[]> List all the table names in this database. @@ -226,14 +190,11 @@ Tables will be returned in lexicographical order. #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `options?` | `Partial`\<[`TableNamesOptions`](../interfaces/TableNamesOptions.md)\> | options to control the paging / start point | +• **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) +`Promise`<`string`[]> diff --git a/docs/src/js/classes/Index.md b/docs/src/js/classes/Index.md index bdfc839b..1fcdacb0 100644 --- a/docs/src/js/classes/Index.md +++ b/docs/src/js/classes/Index.md @@ -1,57 +1,16 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Index +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.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() -▸ **btree**(): [`Index`](Index.md) +> `static` **btree**(): [`Index`](Index.md) Create a btree index @@ -75,15 +34,11 @@ block size may be added in the future. [`Index`](Index.md) -#### Defined in +*** -[indices.ts:175](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/indices.ts#L175) +### ivfPq() -___ - -### ivfPq - -▸ **ivfPq**(`options?`): [`Index`](Index.md) +> `static` **ivfPq**(`options`?): [`Index`](Index.md) Create an IvfPq index @@ -108,14 +63,8 @@ currently is also a memory intensive operation. #### Parameters -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`\<[`IvfPqOptions`](../interfaces/IvfPqOptions.md)\> | +• **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) diff --git a/docs/src/js/classes/MakeArrowTableOptions.md b/docs/src/js/classes/MakeArrowTableOptions.md index e23ca4c8..490ff59a 100644 --- a/docs/src/js/classes/MakeArrowTableOptions.md +++ b/docs/src/js/classes/MakeArrowTableOptions.md @@ -1,46 +1,32 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / MakeArrowTableOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.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() -• **new MakeArrowTableOptions**(`values?`): [`MakeArrowTableOptions`](MakeArrowTableOptions.md) +> **new MakeArrowTableOptions**(`values`?): [`MakeArrowTableOptions`](MakeArrowTableOptions.md) #### Parameters -| Name | Type | -| :------ | :------ | -| `values?` | `Partial`\<[`MakeArrowTableOptions`](MakeArrowTableOptions.md)\> | +• **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` +> **dictionaryEncodeStrings**: `boolean` = `false` If true then string columns will be encoded with dictionary encoding @@ -50,26 +36,26 @@ 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) +### embeddingFunction? -___ +> `optional` **embeddingFunction**: [`EmbeddingFunctionConfig`](../namespaces/embedding/interfaces/EmbeddingFunctionConfig.md) -### schema +*** -• `Optional` **schema**: `Schema`\<`any`\> +### embeddings? -#### Defined in +> `optional` **embeddings**: [`EmbeddingFunction`](../namespaces/embedding/classes/EmbeddingFunction.md)<`unknown`, `FunctionOptions`> -[arrow.ts:67](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L67) +*** -___ +### schema? + +> `optional` **schema**: `SchemaLike` + +*** ### vectorColumns -• **vectorColumns**: `Record`\<`string`, [`VectorColumnOptions`](VectorColumnOptions.md)\> - -#### Defined in - -[arrow.ts:85](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L85) +> **vectorColumns**: `Record`<`string`, [`VectorColumnOptions`](VectorColumnOptions.md)> diff --git a/docs/src/js/classes/Query.md b/docs/src/js/classes/Query.md index 05620c28..0189ce25 100644 --- a/docs/src/js/classes/Query.md +++ b/docs/src/js/classes/Query.md @@ -1,48 +1,26 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Query +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / Query # Class: Query A builder for LanceDB queries. -## Hierarchy +## Extends -- [`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) +- [`QueryBase`](QueryBase.md)<`NativeQuery`> ## Constructors -### constructor +### new Query() -• **new Query**(`tbl`): [`Query`](Query.md) +> **new Query**(`tbl`): [`Query`](Query.md) #### Parameters -| Name | Type | -| :------ | :------ | -| `tbl` | `Table` | +• **tbl**: `Table` #### Returns @@ -50,57 +28,67 @@ A builder for LanceDB queries. #### 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) +[`QueryBase`](QueryBase.md).[`constructor`](QueryBase.md#constructors) ## Properties ### inner -• `Protected` **inner**: `Query` +> `protected` **inner**: `Query` \| `Promise`<`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) +[`QueryBase`](QueryBase.md).[`inner`](QueryBase.md#inner) ## Methods -### [asyncIterator] +### \[asyncIterator\]() -▸ **[asyncIterator]**(): `AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\> +> **\[asyncIterator\]**(): `AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`> #### Returns -`AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\> +`AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`> #### Inherited from -[QueryBase](QueryBase.md).[[asyncIterator]](QueryBase.md#[asynciterator]) +[`QueryBase`](QueryBase.md).[`[asyncIterator]`](QueryBase.md#%5Basynciterator%5D) -#### Defined in +*** -[query.ts:154](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L154) +### doCall() -___ +> `protected` **doCall**(`fn`): `void` -### execute +#### Parameters -▸ **execute**(): [`RecordBatchIterator`](RecordBatchIterator.md) +• **fn** + +#### Returns + +`void` + +#### Inherited from + +[`QueryBase`](QueryBase.md).[`doCall`](QueryBase.md#docall) + +*** + +### execute() + +> `protected` **execute**(`options`?): [`RecordBatchIterator`](RecordBatchIterator.md) Execute the query and return the results as an +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns [`RecordBatchIterator`](RecordBatchIterator.md) -**`See`** +#### See - AsyncIterator of @@ -114,17 +102,76 @@ single query) #### Inherited from -[QueryBase](QueryBase.md).[execute](QueryBase.md#execute) +[`QueryBase`](QueryBase.md).[`execute`](QueryBase.md#execute) -#### Defined in +*** -[query.ts:149](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L149) +### explainPlan() -___ +> **explainPlan**(`verbose`): `Promise`<`string`> -### limit +Generates an explanation of the query execution plan. -▸ **limit**(`limit`): [`Query`](Query.md) +#### Parameters + +• **verbose**: `boolean` = `false` + +If true, provides a more detailed explanation. Defaults to false. + +#### Returns + +`Promise`<`string`> + +A Promise that resolves to a string containing the query execution plan explanation. + +#### Example + +```ts +import * as lancedb from "@lancedb/lancedb" +const db = await lancedb.connect("./.lancedb"); +const table = await db.createTable("my_table", [ + { vector: [1.1, 0.9], id: "1" }, +]); +const plan = await table.query().nearestTo([0.5, 0.2]).explainPlan(); +``` + +#### Inherited from + +[`QueryBase`](QueryBase.md).[`explainPlan`](QueryBase.md#explainplan) + +*** + +### ~~filter()~~ + +> **filter**(`predicate`): `this` + +A filter statement to be applied to this query. + +#### Parameters + +• **predicate**: `string` + +#### Returns + +`this` + +#### Alias + +where + +#### Deprecated + +Use `where` instead + +#### Inherited from + +[`QueryBase`](QueryBase.md).[`filter`](QueryBase.md#filter) + +*** + +### limit() + +> **limit**(`limit`): `this` Set the maximum number of results to return. @@ -133,45 +180,39 @@ called then every valid row from the table will be returned. #### Parameters -| Name | Type | -| :------ | :------ | -| `limit` | `number` | +• **limit**: `number` #### Returns -[`Query`](Query.md) +`this` #### Inherited from -[QueryBase](QueryBase.md).[limit](QueryBase.md#limit) +[`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() -___ +> `protected` **nativeExecute**(`options`?): `Promise`<`RecordBatchIterator`> -### nativeExecute +#### Parameters -▸ **nativeExecute**(): `Promise`\<`RecordBatchIterator`\> +• **options?**: `Partial`<`QueryExecutionOptions`> #### Returns -`Promise`\<`RecordBatchIterator`\> +`Promise`<`RecordBatchIterator`> #### Inherited from -[QueryBase](QueryBase.md).[nativeExecute](QueryBase.md#nativeexecute) +[`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 - -▸ **nearestTo**(`vector`): [`VectorQuery`](VectorQuery.md) +> **nearestTo**(`vector`): [`VectorQuery`](VectorQuery.md) Find the nearest vectors to the given query vector. @@ -191,15 +232,13 @@ If there is more than one vector column you must use #### Parameters -| Name | Type | -| :------ | :------ | -| `vector` | `unknown` | +• **vector**: `IntoVector` #### Returns [`VectorQuery`](VectorQuery.md) -**`See`** +#### See - [VectorQuery#column](VectorQuery.md#column) to specify which column you would like to compare with. @@ -223,15 +262,11 @@ 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 - -▸ **select**(`columns`): [`Query`](Query.md) +> **select**(`columns`): `this` Return only the specified columns. @@ -255,15 +290,13 @@ input to this method would be: #### Parameters -| Name | Type | -| :------ | :------ | -| `columns` | `string`[] \| `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> | +• **columns**: `string` \| `string`[] \| `Record`<`string`, `string`> \| `Map`<`string`, `string`> #### Returns -[`Query`](Query.md) +`this` -**`Example`** +#### Example ```ts new Map([["combined", "a + b"], ["c", "c"]]) @@ -278,61 +311,57 @@ object insertion order is easy to get wrong and `Map` is more foolproof. #### Inherited from -[QueryBase](QueryBase.md).[select](QueryBase.md#select) +[`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 - -▸ **toArray**(): `Promise`\<`unknown`[]\> +> **toArray**(`options`?): `Promise`<`any`[]> Collect the results as an array of objects. +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns -`Promise`\<`unknown`[]\> +`Promise`<`any`[]> #### Inherited from -[QueryBase](QueryBase.md).[toArray](QueryBase.md#toarray) +[`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 - -▸ **toArrow**(): `Promise`\<`Table`\<`any`\>\> +> **toArrow**(`options`?): `Promise`<`Table`<`any`>> Collect the results as an Arrow +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns -`Promise`\<`Table`\<`any`\>\> +`Promise`<`Table`<`any`>> -**`See`** +#### See ArrowTable. #### Inherited from -[QueryBase](QueryBase.md).[toArrow](QueryBase.md#toarrow) +[`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 - -▸ **where**(`predicate`): [`Query`](Query.md) +> **where**(`predicate`): `this` A filter statement to be applied to this query. @@ -340,15 +369,13 @@ The filter should be supplied as an SQL query string. For example: #### Parameters -| Name | Type | -| :------ | :------ | -| `predicate` | `string` | +• **predicate**: `string` #### Returns -[`Query`](Query.md) +`this` -**`Example`** +#### Example ```ts x > 10 @@ -361,8 +388,4 @@ 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) +[`QueryBase`](QueryBase.md).[`where`](QueryBase.md#where) diff --git a/docs/src/js/classes/QueryBase.md b/docs/src/js/classes/QueryBase.md index 7057baae..a62eb49e 100644 --- a/docs/src/js/classes/QueryBase.md +++ b/docs/src/js/classes/QueryBase.md @@ -1,117 +1,91 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / QueryBase +[**@lancedb/lancedb**](../README.md) • **Docs** -# Class: QueryBase\ +*** + +[@lancedb/lancedb](../globals.md) / QueryBase + +# Class: QueryBase<NativeQueryType> Common methods supported by all query types -## Type parameters +## Extended by -| Name | Type | -| :------ | :------ | -| `NativeQueryType` | extends `NativeQuery` \| `NativeVectorQuery` | -| `QueryType` | `QueryType` | +- [`Query`](Query.md) +- [`VectorQuery`](VectorQuery.md) -## Hierarchy +## Type Parameters -- **`QueryBase`** - - ↳ [`Query`](Query.md) - - ↳ [`VectorQuery`](VectorQuery.md) +• **NativeQueryType** *extends* `NativeQuery` \| `NativeVectorQuery` ## 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) +- `AsyncIterable`<`RecordBatch`> ## Constructors -### constructor +### new QueryBase() -• **new QueryBase**\<`NativeQueryType`, `QueryType`\>(`inner`): [`QueryBase`](QueryBase.md)\<`NativeQueryType`, `QueryType`\> - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `NativeQueryType` | extends `Query` \| `VectorQuery` | -| `QueryType` | `QueryType` | +> `protected` **new QueryBase**<`NativeQueryType`>(`inner`): [`QueryBase`](QueryBase.md)<`NativeQueryType`> #### Parameters -| Name | Type | -| :------ | :------ | -| `inner` | `NativeQueryType` | +• **inner**: `NativeQueryType` \| `Promise`<`NativeQueryType`> #### Returns -[`QueryBase`](QueryBase.md)\<`NativeQueryType`, `QueryType`\> - -#### Defined in - -[query.ts:59](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L59) +[`QueryBase`](QueryBase.md)<`NativeQueryType`> ## Properties ### inner -• `Protected` **inner**: `NativeQueryType` - -#### Defined in - -[query.ts:59](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L59) +> `protected` **inner**: `NativeQueryType` \| `Promise`<`NativeQueryType`> ## Methods -### [asyncIterator] +### \[asyncIterator\]() -▸ **[asyncIterator]**(): `AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\> +> **\[asyncIterator\]**(): `AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`> #### Returns -`AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\> +`AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`> #### Implementation of -AsyncIterable.[asyncIterator] +`AsyncIterable.[asyncIterator]` -#### Defined in +*** -[query.ts:154](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L154) +### doCall() -___ +> `protected` **doCall**(`fn`): `void` -### execute +#### Parameters -▸ **execute**(): [`RecordBatchIterator`](RecordBatchIterator.md) +• **fn** + +#### Returns + +`void` + +*** + +### execute() + +> `protected` **execute**(`options`?): [`RecordBatchIterator`](RecordBatchIterator.md) Execute the query and return the results as an +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns [`RecordBatchIterator`](RecordBatchIterator.md) -**`See`** +#### See - AsyncIterator of @@ -123,15 +97,66 @@ 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) +### explainPlan() -___ +> **explainPlan**(`verbose`): `Promise`<`string`> -### limit +Generates an explanation of the query execution plan. -▸ **limit**(`limit`): `QueryType` +#### Parameters + +• **verbose**: `boolean` = `false` + +If true, provides a more detailed explanation. Defaults to false. + +#### Returns + +`Promise`<`string`> + +A Promise that resolves to a string containing the query execution plan explanation. + +#### Example + +```ts +import * as lancedb from "@lancedb/lancedb" +const db = await lancedb.connect("./.lancedb"); +const table = await db.createTable("my_table", [ + { vector: [1.1, 0.9], id: "1" }, +]); +const plan = await table.query().nearestTo([0.5, 0.2]).explainPlan(); +``` + +*** + +### ~~filter()~~ + +> **filter**(`predicate`): `this` + +A filter statement to be applied to this query. + +#### Parameters + +• **predicate**: `string` + +#### Returns + +`this` + +#### Alias + +where + +#### Deprecated + +Use `where` instead + +*** + +### limit() + +> **limit**(`limit`): `this` Set the maximum number of results to return. @@ -140,37 +165,31 @@ called then every valid row from the table will be returned. #### Parameters -| Name | Type | -| :------ | :------ | -| `limit` | `number` | +• **limit**: `number` #### Returns -`QueryType` +`this` -#### Defined in +*** -[query.ts:129](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L129) +### nativeExecute() -___ +> `protected` **nativeExecute**(`options`?): `Promise`<`RecordBatchIterator`> -### nativeExecute +#### Parameters -▸ **nativeExecute**(): `Promise`\<`RecordBatchIterator`\> +• **options?**: `Partial`<`QueryExecutionOptions`> #### Returns -`Promise`\<`RecordBatchIterator`\> +`Promise`<`RecordBatchIterator`> -#### Defined in +*** -[query.ts:134](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L134) +### select() -___ - -### select - -▸ **select**(`columns`): `QueryType` +> **select**(`columns`): `this` Return only the specified columns. @@ -194,15 +213,13 @@ input to this method would be: #### Parameters -| Name | Type | -| :------ | :------ | -| `columns` | `string`[] \| `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> | +• **columns**: `string` \| `string`[] \| `Record`<`string`, `string`> \| `Map`<`string`, `string`> #### Returns -`QueryType` +`this` -**`Example`** +#### Example ```ts new Map([["combined", "a + b"], ["c", "c"]]) @@ -215,51 +232,47 @@ uses `Object.entries` which should preserve the insertion order of the object. 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 - -▸ **toArray**(): `Promise`\<`unknown`[]\> +> **toArray**(`options`?): `Promise`<`any`[]> Collect the results as an array of objects. +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns -`Promise`\<`unknown`[]\> +`Promise`<`any`[]> -#### Defined in +*** -[query.ts:169](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L169) +### toArrow() -___ - -### toArrow - -▸ **toArrow**(): `Promise`\<`Table`\<`any`\>\> +> **toArrow**(`options`?): `Promise`<`Table`<`any`>> Collect the results as an Arrow +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns -`Promise`\<`Table`\<`any`\>\> +`Promise`<`Table`<`any`>> -**`See`** +#### See ArrowTable. -#### Defined in +*** -[query.ts:160](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L160) +### where() -___ - -### where - -▸ **where**(`predicate`): `QueryType` +> **where**(`predicate`): `this` A filter statement to be applied to this query. @@ -267,15 +280,13 @@ The filter should be supplied as an SQL query string. For example: #### Parameters -| Name | Type | -| :------ | :------ | -| `predicate` | `string` | +• **predicate**: `string` #### Returns -`QueryType` +`this` -**`Example`** +#### Example ```ts x > 10 @@ -285,7 +296,3 @@ 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) diff --git a/docs/src/js/classes/RecordBatchIterator.md b/docs/src/js/classes/RecordBatchIterator.md index 2a1b843d..e655029c 100644 --- a/docs/src/js/classes/RecordBatchIterator.md +++ b/docs/src/js/classes/RecordBatchIterator.md @@ -1,80 +1,39 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / RecordBatchIterator +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.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) +- `AsyncIterator`<`RecordBatch`> ## Constructors -### constructor +### new RecordBatchIterator() -• **new RecordBatchIterator**(`promise?`): [`RecordBatchIterator`](RecordBatchIterator.md) +> **new RecordBatchIterator**(`promise`?): [`RecordBatchIterator`](RecordBatchIterator.md) #### Parameters -| Name | Type | -| :------ | :------ | -| `promise?` | `Promise`\<`RecordBatchIterator`\> | +• **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() -▸ **next**(): `Promise`\<`IteratorResult`\<`RecordBatch`\<`any`\>, `any`\>\> +> **next**(): `Promise`<`IteratorResult`<`RecordBatch`<`any`>, `any`>> #### Returns -`Promise`\<`IteratorResult`\<`RecordBatch`\<`any`\>, `any`\>\> +`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) +`AsyncIterator.next` diff --git a/docs/src/js/classes/Table.md b/docs/src/js/classes/Table.md index 9e2ef123..76ce592f 100644 --- a/docs/src/js/classes/Table.md +++ b/docs/src/js/classes/Table.md @@ -1,6 +1,10 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / Table +[**@lancedb/lancedb**](../README.md) • **Docs** -# Class: Table +*** + +[@lancedb/lancedb](../globals.md) / Table + +# Class: `abstract` Table A Table is a collection of Records in a LanceDB Database. @@ -13,196 +17,149 @@ 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() -• **new Table**(`inner`): [`Table`](Table.md) - -Construct a Table. Internal use only. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `inner` | `Table` | +> **new Table**(): [`Table`](Table.md) #### Returns [`Table`](Table.md) -#### Defined in +## Accessors -[table.ts:69](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L69) +### name -## Properties +> `get` `abstract` **name**(): `string` -### inner +Returns the name of the table -• `Private` `Readonly` **inner**: `Table` +#### Returns -#### Defined in - -[table.ts:66](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L66) +`string` ## Methods -### add +### add() -▸ **add**(`data`, `options?`): `Promise`\<`void`\> +> `abstract` **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)\> | - | +• **data**: [`Data`](../type-aliases/Data.md) + +Records to be inserted into the Table + +• **options?**: `Partial`<[`AddDataOptions`](../interfaces/AddDataOptions.md)> #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:105](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L105) +### addColumns() -___ - -### addColumns - -▸ **addColumns**(`newColumnTransforms`): `Promise`\<`void`\> +> `abstract` **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. | +• **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`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:261](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L261) +### alterColumns() -___ - -### alterColumns - -▸ **alterColumns**(`columnAlterations`): `Promise`\<`void`\> +> `abstract` **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. | +• **columnAlterations**: [`ColumnAlteration`](../interfaces/ColumnAlteration.md)[] + +One or more alterations to +apply to columns. #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:270](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L270) +### checkout() -___ +> `abstract` **checkout**(`version`): `Promise`<`void`> -### checkout +Checks out a specific version of the table _This is an in-place operation._ -▸ **checkout**(`version`): `Promise`\<`void`\> +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. -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]` +Calling this method will set the table into time-travel mode. If you +wish to return to standard mode, call `checkoutLatest`. #### Parameters -| Name | Type | -| :------ | :------ | -| `version` | `number` | +• **version**: `number` + +The version to checkout #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +#### Example -[table.ts:317](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L317) +```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" }, +]); -___ +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 +``` -### checkoutLatest +*** -▸ **checkoutLatest**(): `Promise`\<`void`\> +### checkoutLatest() -Ensures the table is pointing at the latest version +> `abstract` **checkoutLatest**(): `Promise`<`void`> -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 +Checkout the latest version of the table. _This is an in-place operation._ + +The table will be set back into standard mode, and will track the latest +version of the table. #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:327](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L327) +### close() -___ - -### close - -▸ **close**(): `void` +> `abstract` **close**(): `void` Close the table, releasing any underlying resources. @@ -214,37 +171,27 @@ Any attempt to use the table after it is closed will result in an error. `void` -#### Defined in +*** -[table.ts:85](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L85) +### countRows() -___ - -### countRows - -▸ **countRows**(`filter?`): `Promise`\<`number`\> +> `abstract` **countRows**(`filter`?): `Promise`<`number`> Count the total number of rows in the dataset. #### Parameters -| Name | Type | -| :------ | :------ | -| `filter?` | `string` | +• **filter?**: `string` #### Returns -`Promise`\<`number`\> +`Promise`<`number`> -#### Defined in +*** -[table.ts:152](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L152) +### createIndex() -___ - -### createIndex - -▸ **createIndex**(`column`, `options?`): `Promise`\<`void`\> +> `abstract` **createIndex**(`column`, `options`?): `Promise`<`void`> Create an index to speed up queries. @@ -255,73 +202,66 @@ vector and non-vector searches) #### Parameters -| Name | Type | -| :------ | :------ | -| `column` | `string` | -| `options?` | `Partial`\<[`IndexOptions`](../interfaces/IndexOptions.md)\> | +• **column**: `string` + +• **options?**: `Partial`<[`IndexOptions`](../interfaces/IndexOptions.md)> #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -**`Example`** +#### Note + +We currently don't support custom named indexes, +The index name will always be `${column}_idx` + +#### Examples ```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"]); +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(); +await table.createIndex("vector", { + config: lancedb.Index.ivfPq({ + numPartitions: 128, + numSubVectors: 16, + }), +}); ``` -**`Example`** - ```ts // Or create a Scalar index -await table.createIndex("my_float_col").build(); +await table.createIndex("my_float_col"); ``` -#### Defined in +*** -[table.ts:184](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L184) +### delete() -___ - -### delete - -▸ **delete**(`predicate`): `Promise`\<`void`\> +> `abstract` **delete**(`predicate`): `Promise`<`void`> Delete the rows that satisfy the predicate. #### Parameters -| Name | Type | -| :------ | :------ | -| `predicate` | `string` | +• **predicate**: `string` #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:157](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L157) +### display() -___ - -### display - -▸ **display**(): `string` +> `abstract` **display**(): `string` Return a brief description of the table @@ -329,15 +269,11 @@ Return a brief description of the table `string` -#### Defined in +*** -[table.ts:90](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L90) +### dropColumns() -___ - -### dropColumns - -▸ **dropColumns**(`columnNames`): `Promise`\<`void`\> +> `abstract` **dropColumns**(`columnNames`): `Promise`<`void`> Drop one or more columns from the dataset @@ -348,23 +284,41 @@ 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"). | +• **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`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:285](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L285) +### indexStats() -___ +> `abstract` **indexStats**(`name`): `Promise`<`undefined` \| [`IndexStatistics`](../interfaces/IndexStatistics.md)> -### isOpen +List all the stats of a specified index -▸ **isOpen**(): `boolean` +#### Parameters + +• **name**: `string` + +The name of the index. + +#### Returns + +`Promise`<`undefined` \| [`IndexStatistics`](../interfaces/IndexStatistics.md)> + +The stats of the index. If the index does not exist, it will return undefined + +*** + +### isOpen() + +> `abstract` **isOpen**(): `boolean` Return true if the table has not been closed @@ -372,31 +326,79 @@ Return true if the table has not been closed `boolean` -#### Defined in +*** -[table.ts:74](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L74) +### listIndices() -___ +> `abstract` **listIndices**(): `Promise`<[`IndexConfig`](../interfaces/IndexConfig.md)[]> -### listIndices - -▸ **listIndices**(): `Promise`\<[`IndexConfig`](../interfaces/IndexConfig.md)[]\> - -List all indices that have been created with Self::create_index +List all indices that have been created with [Table.createIndex](Table.md#createindex) #### Returns -`Promise`\<[`IndexConfig`](../interfaces/IndexConfig.md)[]\> +`Promise`<[`IndexConfig`](../interfaces/IndexConfig.md)[]> -#### Defined in +*** -[table.ts:350](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L350) +### mergeInsert() -___ +> `abstract` **mergeInsert**(`on`): `MergeInsertBuilder` -### query +#### Parameters -▸ **query**(): [`Query`](Query.md) +• **on**: `string` \| `string`[] + +#### Returns + +`MergeInsertBuilder` + +*** + +### optimize() + +> `abstract` **optimize**(`options`?): `Promise`<`OptimizeStats`> + +Optimize the on-disk data and indices for better performance. + +Modeled after ``VACUUM`` in PostgreSQL. + + Optimization covers three operations: + + - Compaction: Merges small files into larger ones + - Prune: Removes old versions of the dataset + - Index: Optimizes the indices, adding new data to existing indices + + Experimental API + ---------------- + + The optimization process is undergoing active development and may change. + Our goal with these changes is to improve the performance of optimization and + reduce the complexity. + + That being said, it is essential today to run optimize if you want the best + performance. It should be stable and safe to use in production, but it our + hope that the API may be simplified (or not even need to be called) in the + future. + + The frequency an application shoudl call optimize is based on the frequency of + data modifications. If data is frequently added, deleted, or updated then + optimize should be run frequently. A good rule of thumb is to run optimize if + you have added or modified 100,000 or more records or run more than 20 data + modification operations. + +#### Parameters + +• **options?**: `Partial`<`OptimizeOptions`> + +#### Returns + +`Promise`<`OptimizeStats`> + +*** + +### query() + +> `abstract` **query**(): [`Query`](Query.md) Create a [Query](Query.md) Builder. @@ -406,8 +408,7 @@ 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. +only fetch the columns you need. When appropriate, various indices and statistics based pruning will be used to accelerate the query. @@ -418,21 +419,22 @@ accelerate the query. A builder that can be used to parameterize the query -**`Example`** +#### Examples ```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); +// 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`** - ```ts // Vector Similarity Search // @@ -440,18 +442,17 @@ for await (const batch of table.query() // 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`** - ```ts // Scan the full dataset // @@ -461,15 +462,11 @@ for await (const batch of table.query()) { } ``` -#### Defined in +*** -[table.ts:238](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L238) +### restore() -___ - -### restore - -▸ **restore**(): `Promise`\<`void`\> +> `abstract` **restore**(): `Promise`<`void`> Restore the table to the currently checked out version @@ -484,33 +481,121 @@ out state and the read_consistency_interval, if any, will apply. #### Returns -`Promise`\<`void`\> +`Promise`<`void`> -#### Defined in +*** -[table.ts:343](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L343) +### schema() -___ - -### schema - -▸ **schema**(): `Promise`\<`Schema`\<`any`\>\> +> `abstract` **schema**(): `Promise`<`Schema`<`any`>> Get the schema of the table. #### Returns -`Promise`\<`Schema`\<`any`\>\> +`Promise`<`Schema`<`any`>> -#### Defined in +*** -[table.ts:95](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L95) +### search() -___ +#### search(query) -### update +> `abstract` **search**(`query`): [`VectorQuery`](VectorQuery.md) -▸ **update**(`updates`, `options?`): `Promise`\<`void`\> +Create a search query to find the nearest neighbors +of the given query vector + +##### Parameters + +• **query**: `string` + +the query. This will be converted to a vector using the table's provided embedding function + +##### Returns + +[`VectorQuery`](VectorQuery.md) + +##### Note + +If no embedding functions are defined in the table, this will error when collecting the results. + +#### search(query) + +> `abstract` **search**(`query`): [`VectorQuery`](VectorQuery.md) + +Create a search query to find the nearest neighbors +of the given query vector + +##### Parameters + +• **query**: `IntoVector` + +the query vector + +##### Returns + +[`VectorQuery`](VectorQuery.md) + +*** + +### toArrow() + +> `abstract` **toArrow**(): `Promise`<`Table`<`any`>> + +Return the table as an arrow table + +#### Returns + +`Promise`<`Table`<`any`>> + +*** + +### update() + +#### update(opts) + +> `abstract` **update**(`opts`): `Promise`<`void`> + +Update existing records in the Table + +##### Parameters + +• **opts**: `object` & `Partial`<[`UpdateOptions`](../interfaces/UpdateOptions.md)> + +##### Returns + +`Promise`<`void`> + +##### Example + +```ts +table.update({where:"x = 2", values:{"vector": [10, 10]}}) +``` + +#### update(opts) + +> `abstract` **update**(`opts`): `Promise`<`void`> + +Update existing records in the Table + +##### Parameters + +• **opts**: `object` & `Partial`<[`UpdateOptions`](../interfaces/UpdateOptions.md)> + +##### Returns + +`Promise`<`void`> + +##### Example + +```ts +table.update({where:"x = 2", valuesSql:{"x": "x + 1"}}) +``` + +#### update(updates, options) + +> `abstract` **update**(`updates`, `options`?): `Promise`<`void`> Update existing records in the Table @@ -527,26 +612,32 @@ 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 +##### 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 | +• **updates**: `Record`<`string`, `string`> \| `Map`<`string`, `string`> -#### Returns +the +columns to update -`Promise`\<`void`\> +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") -#### Defined in +• **options?**: `Partial`<[`UpdateOptions`](../interfaces/UpdateOptions.md)> -[table.ts:137](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L137) +additional options to control +the update behavior -___ +##### Returns -### vectorSearch +`Promise`<`void`> -▸ **vectorSearch**(`vector`): [`VectorQuery`](VectorQuery.md) +*** + +### vectorSearch() + +> `abstract` **vectorSearch**(`vector`): [`VectorQuery`](VectorQuery.md) Search the table with a given query vector. @@ -556,39 +647,50 @@ by `query`. #### Parameters -| Name | Type | -| :------ | :------ | -| `vector` | `unknown` | +• **vector**: `IntoVector` #### Returns [`VectorQuery`](VectorQuery.md) -**`See`** +#### 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 - -▸ **version**(): `Promise`\<`number`\> +> `abstract` **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`> + +*** + +### parseTableData() + +> `static` **parseTableData**(`data`, `options`?, `streaming`?): `Promise`<`object`> + +#### Parameters + +• **data**: `TableLike` \| `Record`<`string`, `unknown`>[] + +• **options?**: `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)> + +• **streaming?**: `boolean` = `false` #### Returns -`Promise`\<`number`\> +`Promise`<`object`> -#### Defined in +##### buf -[table.ts:297](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/table.ts#L297) +> **buf**: `Buffer` + +##### mode + +> **mode**: `string` diff --git a/docs/src/js/classes/VectorColumnOptions.md b/docs/src/js/classes/VectorColumnOptions.md index 814bbe68..ae79d110 100644 --- a/docs/src/js/classes/VectorColumnOptions.md +++ b/docs/src/js/classes/VectorColumnOptions.md @@ -1,45 +1,29 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / VectorColumnOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / VectorColumnOptions # Class: VectorColumnOptions -## Table of contents - -### Constructors - -- [constructor](VectorColumnOptions.md#constructor) - -### Properties - -- [type](VectorColumnOptions.md#type) - ## Constructors -### constructor +### new VectorColumnOptions() -• **new VectorColumnOptions**(`values?`): [`VectorColumnOptions`](VectorColumnOptions.md) +> **new VectorColumnOptions**(`values`?): [`VectorColumnOptions`](VectorColumnOptions.md) #### Parameters -| Name | Type | -| :------ | :------ | -| `values?` | `Partial`\<[`VectorColumnOptions`](VectorColumnOptions.md)\> | +• **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`\> +> **type**: `Float`<`Floats`> Vector column type. - -#### Defined in - -[arrow.ts:47](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L47) diff --git a/docs/src/js/classes/VectorQuery.md b/docs/src/js/classes/VectorQuery.md index 62a55f1d..2be8b037 100644 --- a/docs/src/js/classes/VectorQuery.md +++ b/docs/src/js/classes/VectorQuery.md @@ -1,4 +1,8 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / VectorQuery +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / VectorQuery # Class: VectorQuery @@ -6,50 +10,19 @@ A builder used to construct a vector search This builder can be reused to execute the query many times. -## Hierarchy +## Extends -- [`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) +- [`QueryBase`](QueryBase.md)<`NativeVectorQuery`> ## Constructors -### constructor +### new VectorQuery() -• **new VectorQuery**(`inner`): [`VectorQuery`](VectorQuery.md) +> **new VectorQuery**(`inner`): [`VectorQuery`](VectorQuery.md) #### Parameters -| Name | Type | -| :------ | :------ | -| `inner` | `VectorQuery` | +• **inner**: `VectorQuery` \| `Promise`<`VectorQuery`> #### Returns @@ -57,49 +30,37 @@ This builder can be reused to execute the query many times. #### 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) +[`QueryBase`](QueryBase.md).[`constructor`](QueryBase.md#constructors) ## Properties ### inner -• `Protected` **inner**: `VectorQuery` +> `protected` **inner**: `VectorQuery` \| `Promise`<`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) +[`QueryBase`](QueryBase.md).[`inner`](QueryBase.md#inner) ## Methods -### [asyncIterator] +### \[asyncIterator\]() -▸ **[asyncIterator]**(): `AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\> +> **\[asyncIterator\]**(): `AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`> #### Returns -`AsyncIterator`\<`RecordBatch`\<`any`\>, `any`, `undefined`\> +`AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`> #### Inherited from -[QueryBase](QueryBase.md).[[asyncIterator]](QueryBase.md#[asynciterator]) +[`QueryBase`](QueryBase.md).[`[asyncIterator]`](QueryBase.md#%5Basynciterator%5D) -#### Defined in +*** -[query.ts:154](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L154) +### bypassVectorIndex() -___ - -### bypassVectorIndex - -▸ **bypassVectorIndex**(): [`VectorQuery`](VectorQuery.md) +> **bypassVectorIndex**(): [`VectorQuery`](VectorQuery.md) If this is called then any vector index is skipped @@ -113,15 +74,11 @@ calculate your recall to select an appropriate value for nprobes. [`VectorQuery`](VectorQuery.md) -#### Defined in +*** -[query.ts:321](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L321) +### column() -___ - -### column - -▸ **column**(`column`): [`VectorQuery`](VectorQuery.md) +> **column**(`column`): [`VectorQuery`](VectorQuery.md) Set the vector column to query @@ -130,30 +87,24 @@ the call to #### Parameters -| Name | Type | -| :------ | :------ | -| `column` | `string` | +• **column**: `string` #### Returns [`VectorQuery`](VectorQuery.md) -**`See`** +#### 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**(`distanceType`): [`VectorQuery`](VectorQuery.md) +> **distanceType**(`distanceType`): [`VectorQuery`](VectorQuery.md) Set the distance metric to use @@ -163,15 +114,13 @@ use. See #### Parameters -| Name | Type | -| :------ | :------ | -| `distanceType` | `string` | +• **distanceType**: `"l2"` \| `"cosine"` \| `"dot"` #### Returns [`VectorQuery`](VectorQuery.md) -**`See`** +#### See [IvfPqOptions.distanceType](../interfaces/IvfPqOptions.md#distancetype) for more details on the different distance metrics available. @@ -182,23 +131,41 @@ invalid. By default "l2" is used. -#### Defined in +*** -[query.ts:248](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L248) +### doCall() -___ +> `protected` **doCall**(`fn`): `void` -### execute +#### Parameters -▸ **execute**(): [`RecordBatchIterator`](RecordBatchIterator.md) +• **fn** + +#### Returns + +`void` + +#### Inherited from + +[`QueryBase`](QueryBase.md).[`doCall`](QueryBase.md#docall) + +*** + +### execute() + +> `protected` **execute**(`options`?): [`RecordBatchIterator`](RecordBatchIterator.md) Execute the query and return the results as an +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns [`RecordBatchIterator`](RecordBatchIterator.md) -**`See`** +#### See - AsyncIterator of @@ -212,17 +179,76 @@ single query) #### Inherited from -[QueryBase](QueryBase.md).[execute](QueryBase.md#execute) +[`QueryBase`](QueryBase.md).[`execute`](QueryBase.md#execute) -#### Defined in +*** -[query.ts:149](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/query.ts#L149) +### explainPlan() -___ +> **explainPlan**(`verbose`): `Promise`<`string`> -### limit +Generates an explanation of the query execution plan. -▸ **limit**(`limit`): [`VectorQuery`](VectorQuery.md) +#### Parameters + +• **verbose**: `boolean` = `false` + +If true, provides a more detailed explanation. Defaults to false. + +#### Returns + +`Promise`<`string`> + +A Promise that resolves to a string containing the query execution plan explanation. + +#### Example + +```ts +import * as lancedb from "@lancedb/lancedb" +const db = await lancedb.connect("./.lancedb"); +const table = await db.createTable("my_table", [ + { vector: [1.1, 0.9], id: "1" }, +]); +const plan = await table.query().nearestTo([0.5, 0.2]).explainPlan(); +``` + +#### Inherited from + +[`QueryBase`](QueryBase.md).[`explainPlan`](QueryBase.md#explainplan) + +*** + +### ~~filter()~~ + +> **filter**(`predicate`): `this` + +A filter statement to be applied to this query. + +#### Parameters + +• **predicate**: `string` + +#### Returns + +`this` + +#### Alias + +where + +#### Deprecated + +Use `where` instead + +#### Inherited from + +[`QueryBase`](QueryBase.md).[`filter`](QueryBase.md#filter) + +*** + +### limit() + +> **limit**(`limit`): `this` Set the maximum number of results to return. @@ -231,45 +257,39 @@ called then every valid row from the table will be returned. #### Parameters -| Name | Type | -| :------ | :------ | -| `limit` | `number` | +• **limit**: `number` #### Returns -[`VectorQuery`](VectorQuery.md) +`this` #### Inherited from -[QueryBase](QueryBase.md).[limit](QueryBase.md#limit) +[`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() -___ +> `protected` **nativeExecute**(`options`?): `Promise`<`RecordBatchIterator`> -### nativeExecute +#### Parameters -▸ **nativeExecute**(): `Promise`\<`RecordBatchIterator`\> +• **options?**: `Partial`<`QueryExecutionOptions`> #### Returns -`Promise`\<`RecordBatchIterator`\> +`Promise`<`RecordBatchIterator`> #### Inherited from -[QueryBase](QueryBase.md).[nativeExecute](QueryBase.md#nativeexecute) +[`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**(`nprobes`): [`VectorQuery`](VectorQuery.md) +> **nprobes**(`nprobes`): [`VectorQuery`](VectorQuery.md) Set the number of partitions to search (probe) @@ -294,23 +314,17 @@ you the desired recall. #### Parameters -| Name | Type | -| :------ | :------ | -| `nprobes` | `number` | +• **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 - -▸ **postfilter**(): [`VectorQuery`](VectorQuery.md) +> **postfilter**(): [`VectorQuery`](VectorQuery.md) If this is called then filtering will happen after the vector search instead of before. @@ -333,20 +347,16 @@ Post filtering happens during the "refine stage" (described in more detail in [`VectorQuery`](VectorQuery.md) -**`See`** +#### 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**(`refineFactor`): [`VectorQuery`](VectorQuery.md) +> **refineFactor**(`refineFactor`): [`VectorQuery`](VectorQuery.md) A multiplier to control how many additional rows are taken during the refine step @@ -378,23 +388,17 @@ distance between the query vector and the actual uncompressed vector. #### Parameters -| Name | Type | -| :------ | :------ | -| `refineFactor` | `number` | +• **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 - -▸ **select**(`columns`): [`VectorQuery`](VectorQuery.md) +> **select**(`columns`): `this` Return only the specified columns. @@ -418,15 +422,13 @@ input to this method would be: #### Parameters -| Name | Type | -| :------ | :------ | -| `columns` | `string`[] \| `Record`\<`string`, `string`\> \| `Map`\<`string`, `string`\> | +• **columns**: `string` \| `string`[] \| `Record`<`string`, `string`> \| `Map`<`string`, `string`> #### Returns -[`VectorQuery`](VectorQuery.md) +`this` -**`Example`** +#### Example ```ts new Map([["combined", "a + b"], ["c", "c"]]) @@ -441,61 +443,57 @@ object insertion order is easy to get wrong and `Map` is more foolproof. #### Inherited from -[QueryBase](QueryBase.md).[select](QueryBase.md#select) +[`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 - -▸ **toArray**(): `Promise`\<`unknown`[]\> +> **toArray**(`options`?): `Promise`<`any`[]> Collect the results as an array of objects. +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns -`Promise`\<`unknown`[]\> +`Promise`<`any`[]> #### Inherited from -[QueryBase](QueryBase.md).[toArray](QueryBase.md#toarray) +[`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 - -▸ **toArrow**(): `Promise`\<`Table`\<`any`\>\> +> **toArrow**(`options`?): `Promise`<`Table`<`any`>> Collect the results as an Arrow +#### Parameters + +• **options?**: `Partial`<`QueryExecutionOptions`> + #### Returns -`Promise`\<`Table`\<`any`\>\> +`Promise`<`Table`<`any`>> -**`See`** +#### See ArrowTable. #### Inherited from -[QueryBase](QueryBase.md).[toArrow](QueryBase.md#toarrow) +[`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 - -▸ **where**(`predicate`): [`VectorQuery`](VectorQuery.md) +> **where**(`predicate`): `this` A filter statement to be applied to this query. @@ -503,15 +501,13 @@ The filter should be supplied as an SQL query string. For example: #### Parameters -| Name | Type | -| :------ | :------ | -| `predicate` | `string` | +• **predicate**: `string` #### Returns -[`VectorQuery`](VectorQuery.md) +`this` -**`Example`** +#### Example ```ts x > 10 @@ -524,8 +520,4 @@ 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) +[`QueryBase`](QueryBase.md).[`where`](QueryBase.md#where) diff --git a/docs/src/js/classes/embedding.OpenAIEmbeddingFunction.md b/docs/src/js/classes/embedding.OpenAIEmbeddingFunction.md deleted file mode 100644 index 448abc4c..00000000 --- a/docs/src/js/classes/embedding.OpenAIEmbeddingFunction.md +++ /dev/null @@ -1,111 +0,0 @@ -[@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) diff --git a/docs/src/js/enumerations/WriteMode.md b/docs/src/js/enumerations/WriteMode.md new file mode 100644 index 00000000..3c834f2f --- /dev/null +++ b/docs/src/js/enumerations/WriteMode.md @@ -0,0 +1,27 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / WriteMode + +# Enumeration: WriteMode + +Write mode for writing a table. + +## Enumeration Members + +### Append + +> **Append**: `"Append"` + +*** + +### Create + +> **Create**: `"Create"` + +*** + +### Overwrite + +> **Overwrite**: `"Overwrite"` diff --git a/docs/src/js/enums/WriteMode.md b/docs/src/js/enums/WriteMode.md deleted file mode 100644 index 59147229..00000000 --- a/docs/src/js/enums/WriteMode.md +++ /dev/null @@ -1,43 +0,0 @@ -[@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 diff --git a/docs/src/js/functions/connect.md b/docs/src/js/functions/connect.md new file mode 100644 index 00000000..c2c5dcf3 --- /dev/null +++ b/docs/src/js/functions/connect.md @@ -0,0 +1,82 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / connect + +# Function: connect() + +## connect(uri, opts) + +> **connect**(`uri`, `opts`?): `Promise`<[`Connection`](../classes/Connection.md)> + +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) + +### Parameters + +• **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) \| `RemoteConnectionOptions`> + +### Returns + +`Promise`<[`Connection`](../classes/Connection.md)> + +### See + +[ConnectionOptions](../interfaces/ConnectionOptions.md) for more details on the URI format. + +### Examples + +```ts +const conn = await connect("/path/to/database"); +``` + +```ts +const conn = await connect( + "s3://bucket/path/to/database", + {storageOptions: {timeout: "60s"} +}); +``` + +## connect(opts) + +> **connect**(`opts`): `Promise`<[`Connection`](../classes/Connection.md)> + +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) + +### Parameters + +• **opts**: `Partial`<[`ConnectionOptions`](../interfaces/ConnectionOptions.md) \| `RemoteConnectionOptions`> & `object` + +### Returns + +`Promise`<[`Connection`](../classes/Connection.md)> + +### See + +[ConnectionOptions](../interfaces/ConnectionOptions.md) for more details on the URI format. + +### Example + +```ts +const conn = await connect({ + uri: "/path/to/database", + storageOptions: {timeout: "60s"} +}); +``` diff --git a/docs/src/js/modules.md b/docs/src/js/functions/makeArrowTable.md similarity index 50% rename from docs/src/js/modules.md rename to docs/src/js/functions/makeArrowTable.md index c98890bc..1ac154d3 100644 --- a/docs/src/js/modules.md +++ b/docs/src/js/functions/makeArrowTable.md @@ -1,103 +1,12 @@ -[@lancedb/lancedb](README.md) / Exports +[**@lancedb/lancedb**](../README.md) • **Docs** -# @lancedb/lancedb +*** -## Table of contents +[@lancedb/lancedb](../globals.md) / makeArrowTable -### Namespaces +# Function: makeArrowTable() -- [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` +> **makeArrowTable**(`data`, `options`?, `metadata`?): `ArrowTable` An enhanced version of the makeTable function from Apache Arrow that supports nested fields and embeddings columns. @@ -129,20 +38,20 @@ rules are as follows: - Record => Struct - Array => List -#### Parameters +## Parameters -| Name | Type | -| :------ | :------ | -| `data` | `Record`\<`string`, `unknown`\>[] | -| `options?` | `Partial`\<[`MakeArrowTableOptions`](classes/MakeArrowTableOptions.md)\> | +• **data**: `Record`<`string`, `unknown`>[] -#### Returns +• **options?**: `Partial`<[`MakeArrowTableOptions`](../classes/MakeArrowTableOptions.md)> + +• **metadata?**: `Map`<`string`, `string`> + +## Returns `ArrowTable` -**`Example`** +## Example -```ts import { fromTableToBuffer, makeArrowTable } from "../arrow"; import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow"; @@ -203,7 +112,3 @@ const table = makeArrowTable([ } assert.deepEqual(table.schema, schema) ``` - -#### Defined in - -[arrow.ts:197](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/arrow.ts#L197) diff --git a/docs/src/js/globals.md b/docs/src/js/globals.md new file mode 100644 index 00000000..16d7236c --- /dev/null +++ b/docs/src/js/globals.md @@ -0,0 +1,51 @@ +[**@lancedb/lancedb**](README.md) • **Docs** + +*** + +# @lancedb/lancedb + +## Namespaces + +- [embedding](namespaces/embedding/README.md) + +## Enumerations + +- [WriteMode](enumerations/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) +- [IndexMetadata](interfaces/IndexMetadata.md) +- [IndexOptions](interfaces/IndexOptions.md) +- [IndexStatistics](interfaces/IndexStatistics.md) +- [IvfPqOptions](interfaces/IvfPqOptions.md) +- [TableNamesOptions](interfaces/TableNamesOptions.md) +- [UpdateOptions](interfaces/UpdateOptions.md) +- [WriteOptions](interfaces/WriteOptions.md) + +## Type Aliases + +- [Data](type-aliases/Data.md) + +## Functions + +- [connect](functions/connect.md) +- [makeArrowTable](functions/makeArrowTable.md) diff --git a/docs/src/js/interfaces/AddColumnsSql.md b/docs/src/js/interfaces/AddColumnsSql.md index 9a1f7b6b..4fa9474c 100644 --- a/docs/src/js/interfaces/AddColumnsSql.md +++ b/docs/src/js/interfaces/AddColumnsSql.md @@ -1,37 +1,26 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / AddColumnsSql +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.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` +> **name**: `string` The name of the new column. -#### Defined in - -native.d.ts:43 - -___ +*** ### valueSql -• **valueSql**: `string` +> **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 diff --git a/docs/src/js/interfaces/AddDataOptions.md b/docs/src/js/interfaces/AddDataOptions.md index b285a49a..cf7262c9 100644 --- a/docs/src/js/interfaces/AddDataOptions.md +++ b/docs/src/js/interfaces/AddDataOptions.md @@ -1,25 +1,19 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / AddDataOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / AddDataOptions # Interface: AddDataOptions Options for adding data to a table. -## Table of contents - -### Properties - -- [mode](AddDataOptions.md#mode) - ## Properties ### mode -• **mode**: ``"append"`` \| ``"overwrite"`` +> **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) diff --git a/docs/src/js/interfaces/ColumnAlteration.md b/docs/src/js/interfaces/ColumnAlteration.md index 144a2baa..17fd93ce 100644 --- a/docs/src/js/interfaces/ColumnAlteration.md +++ b/docs/src/js/interfaces/ColumnAlteration.md @@ -1,4 +1,8 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / ColumnAlteration +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / ColumnAlteration # Interface: ColumnAlteration @@ -7,50 +11,30 @@ A definition of a column alteration. The alteration changes the column at 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 +### nullable? -• `Optional` **nullable**: `boolean` +> `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` +> **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? -___ - -### rename - -• `Optional` **rename**: `string` +> `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 diff --git a/docs/src/js/interfaces/ConnectionOptions.md b/docs/src/js/interfaces/ConnectionOptions.md index b2979eae..7a973223 100644 --- a/docs/src/js/interfaces/ConnectionOptions.md +++ b/docs/src/js/interfaces/ConnectionOptions.md @@ -1,40 +1,16 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / ConnectionOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / ConnectionOptions # Interface: ConnectionOptions -## Table of contents - -### Properties - -- [apiKey](ConnectionOptions.md#apikey) -- [hostOverride](ConnectionOptions.md#hostoverride) -- [readConsistencyInterval](ConnectionOptions.md#readconsistencyinterval) - ## Properties -### apiKey +### readConsistencyInterval? -• `Optional` **apiKey**: `string` - -#### Defined in - -native.d.ts:51 - -___ - -### hostOverride - -• `Optional` **hostOverride**: `string` - -#### Defined in - -native.d.ts:52 - -___ - -### readConsistencyInterval - -• `Optional` **readConsistencyInterval**: `number` +> `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 @@ -46,6 +22,12 @@ 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 +### storageOptions? + +> `optional` **storageOptions**: `Record`<`string`, `string`> + +(For LanceDB OSS only): configuration for object storage. + +The available options are described at https://lancedb.github.io/lancedb/guides/storage/ diff --git a/docs/src/js/interfaces/CreateTableOptions.md b/docs/src/js/interfaces/CreateTableOptions.md index e27a6f40..11a46bc7 100644 --- a/docs/src/js/interfaces/CreateTableOptions.md +++ b/docs/src/js/interfaces/CreateTableOptions.md @@ -1,32 +1,31 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / CreateTableOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / CreateTableOptions # Interface: CreateTableOptions -## Table of contents - -### Properties - -- [existOk](CreateTableOptions.md#existok) -- [mode](CreateTableOptions.md#mode) - ## Properties +### embeddingFunction? + +> `optional` **embeddingFunction**: [`EmbeddingFunctionConfig`](../namespaces/embedding/interfaces/EmbeddingFunctionConfig.md) + +*** + ### existOk -• **existOk**: `boolean` +> **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"`` +> **mode**: `"overwrite"` \| `"create"` The mode to use when creating the table. @@ -36,6 +35,31 @@ 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) +### schema? + +> `optional` **schema**: `SchemaLike` + +*** + +### storageOptions? + +> `optional` **storageOptions**: `Record`<`string`, `string`> + +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/ + +*** + +### useLegacyFormat? + +> `optional` **useLegacyFormat**: `boolean` + +If true then data files will be written with the legacy format + +The default is true while the new format is in beta diff --git a/docs/src/js/interfaces/ExecutableQuery.md b/docs/src/js/interfaces/ExecutableQuery.md index 9853d80d..6cc6a18a 100644 --- a/docs/src/js/interfaces/ExecutableQuery.md +++ b/docs/src/js/interfaces/ExecutableQuery.md @@ -1,4 +1,8 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / ExecutableQuery +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / ExecutableQuery # Interface: ExecutableQuery diff --git a/docs/src/js/interfaces/IndexConfig.md b/docs/src/js/interfaces/IndexConfig.md index 6916e10f..3297d632 100644 --- a/docs/src/js/interfaces/IndexConfig.md +++ b/docs/src/js/interfaces/IndexConfig.md @@ -1,39 +1,36 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / IndexConfig +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.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`[] +> **columns**: `string`[] The columns in the index -Currently this is always an array of size 1. In the future there may +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` +> **indexType**: `string` The type of the index -#### Defined in +*** -native.d.ts:9 +### name + +> **name**: `string` + +The name of the index diff --git a/docs/src/js/interfaces/IndexMetadata.md b/docs/src/js/interfaces/IndexMetadata.md new file mode 100644 index 00000000..3816df4d --- /dev/null +++ b/docs/src/js/interfaces/IndexMetadata.md @@ -0,0 +1,19 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / IndexMetadata + +# Interface: IndexMetadata + +## Properties + +### indexType? + +> `optional` **indexType**: `string` + +*** + +### metricType? + +> `optional` **metricType**: `string` diff --git a/docs/src/js/interfaces/IndexOptions.md b/docs/src/js/interfaces/IndexOptions.md index fdf5a581..d0f6cdb7 100644 --- a/docs/src/js/interfaces/IndexOptions.md +++ b/docs/src/js/interfaces/IndexOptions.md @@ -1,19 +1,16 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / IndexOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / IndexOptions # Interface: IndexOptions -## Table of contents - -### Properties - -- [config](IndexOptions.md#config) -- [replace](IndexOptions.md#replace) - ## Properties -### config +### config? -• `Optional` **config**: [`Index`](../classes/Index.md) +> `optional` **config**: [`Index`](../classes/Index.md) Advanced index configuration @@ -25,15 +22,11 @@ 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? -___ - -### replace - -• `Optional` **replace**: `boolean` +> `optional` **replace**: `boolean` Whether to replace the existing index @@ -42,7 +35,3 @@ 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) diff --git a/docs/src/js/interfaces/IndexStatistics.md b/docs/src/js/interfaces/IndexStatistics.md new file mode 100644 index 00000000..85d1e483 --- /dev/null +++ b/docs/src/js/interfaces/IndexStatistics.md @@ -0,0 +1,39 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / IndexStatistics + +# Interface: IndexStatistics + +## Properties + +### indexType? + +> `optional` **indexType**: `string` + +The type of the index + +*** + +### indices + +> **indices**: [`IndexMetadata`](IndexMetadata.md)[] + +The metadata for each index + +*** + +### numIndexedRows + +> **numIndexedRows**: `number` + +The number of rows indexed by the index + +*** + +### numUnindexedRows + +> **numUnindexedRows**: `number` + +The number of rows not indexed diff --git a/docs/src/js/interfaces/IvfPqOptions.md b/docs/src/js/interfaces/IvfPqOptions.md index 1bf9b67d..ce39408a 100644 --- a/docs/src/js/interfaces/IvfPqOptions.md +++ b/docs/src/js/interfaces/IvfPqOptions.md @@ -1,24 +1,18 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / IvfPqOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.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 +### distanceType? -• `Optional` **distanceType**: ``"l2"`` \| ``"cosine"`` \| ``"dot"`` +> `optional` **distanceType**: `"l2"` \| `"cosine"` \| `"dot"` Distance type to use to build the index. @@ -52,15 +46,11 @@ never be returned from a vector search. 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? -___ - -### maxIterations - -• `Optional` **maxIterations**: `number` +> `optional` **maxIterations**: `number` Max iteration to train IVF kmeans. @@ -72,15 +62,11 @@ 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? -___ - -### numPartitions - -• `Optional` **numPartitions**: `number` +> `optional` **numPartitions**: `number` The number of IVF partitions to create. @@ -92,15 +78,11 @@ 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? -___ - -### numSubVectors - -• `Optional` **numSubVectors**: `number` +> `optional` **numSubVectors**: `number` Number of sub-vectors of PQ. @@ -115,15 +97,11 @@ 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? -___ - -### sampleRate - -• `Optional` **sampleRate**: `number` +> `optional` **sampleRate**: `number` The number of vectors, per partition, to sample when training IVF kmeans. @@ -138,7 +116,3 @@ Increasing this value might improve the quality of the index but in most cases t 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) diff --git a/docs/src/js/interfaces/TableNamesOptions.md b/docs/src/js/interfaces/TableNamesOptions.md index 502a72a3..98bb5f91 100644 --- a/docs/src/js/interfaces/TableNamesOptions.md +++ b/docs/src/js/interfaces/TableNamesOptions.md @@ -1,38 +1,27 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / TableNamesOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / TableNamesOptions # Interface: TableNamesOptions -## Table of contents - -### Properties - -- [limit](TableNamesOptions.md#limit) -- [startAfter](TableNamesOptions.md#startafter) - ## Properties -### limit +### limit? -• `Optional` **limit**: `number` +> `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? -___ - -### startAfter - -• `Optional` **startAfter**: `string` +> `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) diff --git a/docs/src/js/interfaces/UpdateOptions.md b/docs/src/js/interfaces/UpdateOptions.md index 49e14344..42b68679 100644 --- a/docs/src/js/interfaces/UpdateOptions.md +++ b/docs/src/js/interfaces/UpdateOptions.md @@ -1,18 +1,16 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / UpdateOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / UpdateOptions # Interface: UpdateOptions -## Table of contents - -### Properties - -- [where](UpdateOptions.md#where) - ## Properties ### where -• **where**: `string` +> **where**: `string` A filter that limits the scope of the update. @@ -22,7 +20,3 @@ 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) diff --git a/docs/src/js/interfaces/WriteOptions.md b/docs/src/js/interfaces/WriteOptions.md index 0215a8f1..56bf58df 100644 --- a/docs/src/js/interfaces/WriteOptions.md +++ b/docs/src/js/interfaces/WriteOptions.md @@ -1,21 +1,17 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / WriteOptions +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / WriteOptions # Interface: WriteOptions Write options when creating a Table. -## Table of contents - -### Properties - -- [mode](WriteOptions.md#mode) - ## Properties -### mode +### mode? -• `Optional` **mode**: [`WriteMode`](../enums/WriteMode.md) +> `optional` **mode**: [`WriteMode`](../enumerations/WriteMode.md) -#### Defined in - -native.d.ts:74 +Write mode for writing to a table. diff --git a/docs/src/js/interfaces/embedding.EmbeddingFunction.md b/docs/src/js/interfaces/embedding.EmbeddingFunction.md deleted file mode 100644 index 40f6bd24..00000000 --- a/docs/src/js/interfaces/embedding.EmbeddingFunction.md +++ /dev/null @@ -1,129 +0,0 @@ -[@lancedb/lancedb](../README.md) / [Exports](../modules.md) / [embedding](../modules/embedding.md) / EmbeddingFunction - -# Interface: EmbeddingFunction\ - -[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) diff --git a/docs/src/js/modules/embedding.md b/docs/src/js/modules/embedding.md deleted file mode 100644 index b0ed0725..00000000 --- a/docs/src/js/modules/embedding.md +++ /dev/null @@ -1,45 +0,0 @@ -[@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\ - -Test if the input seems to be an embedding function - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `unknown` | - -#### Returns - -value is EmbeddingFunction\ - -#### Defined in - -[embedding/embedding_function.ts:66](https://github.com/lancedb/lancedb/blob/9d178c7/nodejs/lancedb/embedding/embedding_function.ts#L66) diff --git a/docs/src/js/namespaces/embedding/README.md b/docs/src/js/namespaces/embedding/README.md new file mode 100644 index 00000000..a8b594fb --- /dev/null +++ b/docs/src/js/namespaces/embedding/README.md @@ -0,0 +1,29 @@ +[**@lancedb/lancedb**](../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../globals.md) / embedding + +# embedding + +## Index + +### Classes + +- [EmbeddingFunction](classes/EmbeddingFunction.md) +- [EmbeddingFunctionRegistry](classes/EmbeddingFunctionRegistry.md) +- [OpenAIEmbeddingFunction](classes/OpenAIEmbeddingFunction.md) + +### Interfaces + +- [EmbeddingFunctionConfig](interfaces/EmbeddingFunctionConfig.md) + +### Type Aliases + +- [OpenAIOptions](type-aliases/OpenAIOptions.md) + +### Functions + +- [LanceSchema](functions/LanceSchema.md) +- [getRegistry](functions/getRegistry.md) +- [register](functions/register.md) diff --git a/docs/src/js/namespaces/embedding/classes/EmbeddingFunction.md b/docs/src/js/namespaces/embedding/classes/EmbeddingFunction.md new file mode 100644 index 00000000..113de90f --- /dev/null +++ b/docs/src/js/namespaces/embedding/classes/EmbeddingFunction.md @@ -0,0 +1,162 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / EmbeddingFunction + +# Class: `abstract` EmbeddingFunction<T, M> + +An embedding function that automatically creates vector representation for a given column. + +## Extended by + +- [`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md) + +## Type Parameters + +• **T** = `any` + +• **M** *extends* `FunctionOptions` = `FunctionOptions` + +## Constructors + +### new EmbeddingFunction() + +> **new EmbeddingFunction**<`T`, `M`>(): [`EmbeddingFunction`](EmbeddingFunction.md)<`T`, `M`> + +#### Returns + +[`EmbeddingFunction`](EmbeddingFunction.md)<`T`, `M`> + +## Methods + +### computeQueryEmbeddings() + +> **computeQueryEmbeddings**(`data`): `Promise`<`number`[] \| `Float32Array` \| `Float64Array`> + +Compute the embeddings for a single query + +#### Parameters + +• **data**: `T` + +#### Returns + +`Promise`<`number`[] \| `Float32Array` \| `Float64Array`> + +*** + +### computeSourceEmbeddings() + +> `abstract` **computeSourceEmbeddings**(`data`): `Promise`<`number`[][] \| `Float32Array`[] \| `Float64Array`[]> + +Creates a vector representation for the given values. + +#### Parameters + +• **data**: `T`[] + +#### Returns + +`Promise`<`number`[][] \| `Float32Array`[] \| `Float64Array`[]> + +*** + +### embeddingDataType() + +> `abstract` **embeddingDataType**(): `Float`<`Floats`> + +The datatype of the embeddings + +#### Returns + +`Float`<`Floats`> + +*** + +### ndims() + +> **ndims**(): `undefined` \| `number` + +The number of dimensions of the embeddings + +#### Returns + +`undefined` \| `number` + +*** + +### sourceField() + +> **sourceField**(`optionsOrDatatype`): [`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +sourceField is used in combination with `LanceSchema` to provide a declarative data model + +#### Parameters + +• **optionsOrDatatype**: `DataType`<`Type`, `any`> \| `Partial`<`FieldOptions`<`DataType`<`Type`, `any`>>> + +The options for the field or the datatype + +#### Returns + +[`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +#### See + +lancedb.LanceSchema + +*** + +### toJSON() + +> `abstract` **toJSON**(): `Partial`<`M`> + +Convert the embedding function to a JSON object +It is used to serialize the embedding function to the schema +It's important that any object returned by this method contains all the necessary +information to recreate the embedding function + +It should return the same object that was passed to the constructor +If it does not, the embedding function will not be able to be recreated, or could be recreated incorrectly + +#### Returns + +`Partial`<`M`> + +#### Example + +```ts +class MyEmbeddingFunction extends EmbeddingFunction { + constructor(options: {model: string, timeout: number}) { + super(); + this.model = options.model; + this.timeout = options.timeout; + } + toJSON() { + return { + model: this.model, + timeout: this.timeout, + }; +} +``` + +*** + +### vectorField() + +> **vectorField**(`optionsOrDatatype`?): [`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +vectorField is used in combination with `LanceSchema` to provide a declarative data model + +#### Parameters + +• **optionsOrDatatype?**: `DataType`<`Type`, `any`> \| `Partial`<`FieldOptions`<`DataType`<`Type`, `any`>>> + +#### Returns + +[`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +#### See + +lancedb.LanceSchema diff --git a/docs/src/js/namespaces/embedding/classes/EmbeddingFunctionRegistry.md b/docs/src/js/namespaces/embedding/classes/EmbeddingFunctionRegistry.md new file mode 100644 index 00000000..38c7a841 --- /dev/null +++ b/docs/src/js/namespaces/embedding/classes/EmbeddingFunctionRegistry.md @@ -0,0 +1,124 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / EmbeddingFunctionRegistry + +# Class: EmbeddingFunctionRegistry + +This is a singleton class used to register embedding functions +and fetch them by name. It also handles serializing and deserializing. +You can implement your own embedding function by subclassing EmbeddingFunction +or TextEmbeddingFunction and registering it with the registry + +## Constructors + +### new EmbeddingFunctionRegistry() + +> **new EmbeddingFunctionRegistry**(): [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) + +#### Returns + +[`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) + +## Methods + +### functionToMetadata() + +> **functionToMetadata**(`conf`): `Record`<`string`, `any`> + +#### Parameters + +• **conf**: [`EmbeddingFunctionConfig`](../interfaces/EmbeddingFunctionConfig.md) + +#### Returns + +`Record`<`string`, `any`> + +*** + +### get() + +> **get**<`T`, `Name`>(`name`): `Name` *extends* `"openai"` ? `EmbeddingFunctionCreate`<[`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md)> : `undefined` \| `EmbeddingFunctionCreate`<`T`> + +Fetch an embedding function by name + +#### Type Parameters + +• **T** *extends* [`EmbeddingFunction`](EmbeddingFunction.md)<`unknown`, `FunctionOptions`> + +• **Name** *extends* `string` = `""` + +#### Parameters + +• **name**: `Name` *extends* `"openai"` ? `"openai"` : `string` + +The name of the function + +#### Returns + +`Name` *extends* `"openai"` ? `EmbeddingFunctionCreate`<[`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md)> : `undefined` \| `EmbeddingFunctionCreate`<`T`> + +*** + +### getTableMetadata() + +> **getTableMetadata**(`functions`): `Map`<`string`, `string`> + +#### Parameters + +• **functions**: [`EmbeddingFunctionConfig`](../interfaces/EmbeddingFunctionConfig.md)[] + +#### Returns + +`Map`<`string`, `string`> + +*** + +### register() + +> **register**<`T`>(`this`, `alias`?): (`ctor`) => `any` + +Register an embedding function + +#### Type Parameters + +• **T** *extends* `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>> = `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>> + +#### Parameters + +• **this**: [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) + +• **alias?**: `string` + +#### Returns + +`Function` + +##### Parameters + +• **ctor**: `T` + +##### Returns + +`any` + +#### Throws + +Error if the function is already registered + +*** + +### reset() + +> **reset**(`this`): `void` + +reset the registry to the initial state + +#### Parameters + +• **this**: [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) + +#### Returns + +`void` diff --git a/docs/src/js/namespaces/embedding/classes/OpenAIEmbeddingFunction.md b/docs/src/js/namespaces/embedding/classes/OpenAIEmbeddingFunction.md new file mode 100644 index 00000000..84a272c0 --- /dev/null +++ b/docs/src/js/namespaces/embedding/classes/OpenAIEmbeddingFunction.md @@ -0,0 +1,196 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / OpenAIEmbeddingFunction + +# Class: OpenAIEmbeddingFunction + +An embedding function that automatically creates vector representation for a given column. + +## Extends + +- [`EmbeddingFunction`](EmbeddingFunction.md)<`string`, `Partial`<[`OpenAIOptions`](../type-aliases/OpenAIOptions.md)>> + +## Constructors + +### new OpenAIEmbeddingFunction() + +> **new OpenAIEmbeddingFunction**(`options`): [`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md) + +#### Parameters + +• **options**: `Partial`<[`OpenAIOptions`](../type-aliases/OpenAIOptions.md)> = `...` + +#### Returns + +[`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md) + +#### Overrides + +[`EmbeddingFunction`](EmbeddingFunction.md).[`constructor`](EmbeddingFunction.md#constructors) + +## Methods + +### computeQueryEmbeddings() + +> **computeQueryEmbeddings**(`data`): `Promise`<`number`[]> + +Compute the embeddings for a single query + +#### Parameters + +• **data**: `string` + +#### Returns + +`Promise`<`number`[]> + +#### Overrides + +[`EmbeddingFunction`](EmbeddingFunction.md).[`computeQueryEmbeddings`](EmbeddingFunction.md#computequeryembeddings) + +*** + +### computeSourceEmbeddings() + +> **computeSourceEmbeddings**(`data`): `Promise`<`number`[][]> + +Creates a vector representation for the given values. + +#### Parameters + +• **data**: `string`[] + +#### Returns + +`Promise`<`number`[][]> + +#### Overrides + +[`EmbeddingFunction`](EmbeddingFunction.md).[`computeSourceEmbeddings`](EmbeddingFunction.md#computesourceembeddings) + +*** + +### embeddingDataType() + +> **embeddingDataType**(): `Float`<`Floats`> + +The datatype of the embeddings + +#### Returns + +`Float`<`Floats`> + +#### Overrides + +[`EmbeddingFunction`](EmbeddingFunction.md).[`embeddingDataType`](EmbeddingFunction.md#embeddingdatatype) + +*** + +### ndims() + +> **ndims**(): `number` + +The number of dimensions of the embeddings + +#### Returns + +`number` + +#### Overrides + +[`EmbeddingFunction`](EmbeddingFunction.md).[`ndims`](EmbeddingFunction.md#ndims) + +*** + +### sourceField() + +> **sourceField**(`optionsOrDatatype`): [`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +sourceField is used in combination with `LanceSchema` to provide a declarative data model + +#### Parameters + +• **optionsOrDatatype**: `DataType`<`Type`, `any`> \| `Partial`<`FieldOptions`<`DataType`<`Type`, `any`>>> + +The options for the field or the datatype + +#### Returns + +[`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +#### See + +lancedb.LanceSchema + +#### Inherited from + +[`EmbeddingFunction`](EmbeddingFunction.md).[`sourceField`](EmbeddingFunction.md#sourcefield) + +*** + +### toJSON() + +> **toJSON**(): `object` + +Convert the embedding function to a JSON object +It is used to serialize the embedding function to the schema +It's important that any object returned by this method contains all the necessary +information to recreate the embedding function + +It should return the same object that was passed to the constructor +If it does not, the embedding function will not be able to be recreated, or could be recreated incorrectly + +#### Returns + +`object` + +##### model + +> **model**: `string` & `object` \| `"text-embedding-ada-002"` \| `"text-embedding-3-small"` \| `"text-embedding-3-large"` + +#### Example + +```ts +class MyEmbeddingFunction extends EmbeddingFunction { + constructor(options: {model: string, timeout: number}) { + super(); + this.model = options.model; + this.timeout = options.timeout; + } + toJSON() { + return { + model: this.model, + timeout: this.timeout, + }; +} +``` + +#### Overrides + +[`EmbeddingFunction`](EmbeddingFunction.md).[`toJSON`](EmbeddingFunction.md#tojson) + +*** + +### vectorField() + +> **vectorField**(`optionsOrDatatype`?): [`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +vectorField is used in combination with `LanceSchema` to provide a declarative data model + +#### Parameters + +• **optionsOrDatatype?**: `DataType`<`Type`, `any`> \| `Partial`<`FieldOptions`<`DataType`<`Type`, `any`>>> + +#### Returns + +[`DataType`<`Type`, `any`>, `Map`<`string`, [`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>] + +#### See + +lancedb.LanceSchema + +#### Inherited from + +[`EmbeddingFunction`](EmbeddingFunction.md).[`vectorField`](EmbeddingFunction.md#vectorfield) diff --git a/docs/src/js/namespaces/embedding/functions/LanceSchema.md b/docs/src/js/namespaces/embedding/functions/LanceSchema.md new file mode 100644 index 00000000..974a1c18 --- /dev/null +++ b/docs/src/js/namespaces/embedding/functions/LanceSchema.md @@ -0,0 +1,39 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / LanceSchema + +# Function: LanceSchema() + +> **LanceSchema**(`fields`): `Schema` + +Create a schema with embedding functions. + +## Parameters + +• **fields**: `Record`<`string`, `object` \| [`object`, `Map`<`string`, [`EmbeddingFunction`](../classes/EmbeddingFunction.md)<`any`, `FunctionOptions`>>]> + +## Returns + +`Schema` + +Schema + +## Example + +```ts +class MyEmbeddingFunction extends EmbeddingFunction { +// ... +} +const func = new MyEmbeddingFunction(); +const schema = LanceSchema({ + id: new Int32(), + text: func.sourceField(new Utf8()), + vector: func.vectorField(), + // optional: specify the datatype and/or dimensions + vector2: func.vectorField({ datatype: new Float32(), dims: 3}), +}); + +const table = await db.createTable("my_table", data, { schema }); +``` diff --git a/docs/src/js/namespaces/embedding/functions/getRegistry.md b/docs/src/js/namespaces/embedding/functions/getRegistry.md new file mode 100644 index 00000000..ffdbe50d --- /dev/null +++ b/docs/src/js/namespaces/embedding/functions/getRegistry.md @@ -0,0 +1,23 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / getRegistry + +# Function: getRegistry() + +> **getRegistry**(): [`EmbeddingFunctionRegistry`](../classes/EmbeddingFunctionRegistry.md) + +Utility function to get the global instance of the registry + +## Returns + +[`EmbeddingFunctionRegistry`](../classes/EmbeddingFunctionRegistry.md) + +`EmbeddingFunctionRegistry` The global instance of the registry + +## Example + +```ts +const registry = getRegistry(); +const openai = registry.get("openai").create(); diff --git a/docs/src/js/namespaces/embedding/functions/register.md b/docs/src/js/namespaces/embedding/functions/register.md new file mode 100644 index 00000000..61a10ddc --- /dev/null +++ b/docs/src/js/namespaces/embedding/functions/register.md @@ -0,0 +1,25 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / register + +# Function: register() + +> **register**(`name`?): (`ctor`) => `any` + +## Parameters + +• **name?**: `string` + +## Returns + +`Function` + +### Parameters + +• **ctor**: `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](../classes/EmbeddingFunction.md)<`any`, `FunctionOptions`>> + +### Returns + +`any` diff --git a/docs/src/js/namespaces/embedding/interfaces/EmbeddingFunctionConfig.md b/docs/src/js/namespaces/embedding/interfaces/EmbeddingFunctionConfig.md new file mode 100644 index 00000000..d011857c --- /dev/null +++ b/docs/src/js/namespaces/embedding/interfaces/EmbeddingFunctionConfig.md @@ -0,0 +1,25 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / EmbeddingFunctionConfig + +# Interface: EmbeddingFunctionConfig + +## Properties + +### function + +> **function**: [`EmbeddingFunction`](../classes/EmbeddingFunction.md)<`any`, `FunctionOptions`> + +*** + +### sourceColumn + +> **sourceColumn**: `string` + +*** + +### vectorColumn? + +> `optional` **vectorColumn**: `string` diff --git a/docs/src/js/namespaces/embedding/type-aliases/OpenAIOptions.md b/docs/src/js/namespaces/embedding/type-aliases/OpenAIOptions.md new file mode 100644 index 00000000..e0a783ef --- /dev/null +++ b/docs/src/js/namespaces/embedding/type-aliases/OpenAIOptions.md @@ -0,0 +1,19 @@ +[**@lancedb/lancedb**](../../../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / OpenAIOptions + +# Type Alias: OpenAIOptions + +> **OpenAIOptions**: `object` + +## Type declaration + +### apiKey + +> **apiKey**: `string` + +### model + +> **model**: `EmbeddingCreateParams`\[`"model"`\] diff --git a/docs/src/js/type-aliases/Data.md b/docs/src/js/type-aliases/Data.md new file mode 100644 index 00000000..1d366e7e --- /dev/null +++ b/docs/src/js/type-aliases/Data.md @@ -0,0 +1,11 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / Data + +# Type Alias: Data + +> **Data**: `Record`<`string`, `unknown`>[] \| `TableLike` + +Data type accepted by NodeJS SDK diff --git a/docs/src/migration.md b/docs/src/migration.md index 252e5d07..b44748da 100644 --- a/docs/src/migration.md +++ b/docs/src/migration.md @@ -80,11 +80,28 @@ we plan to support them soon. For JS/TS users, we offer a brand new SDK [@lancedb/lancedb](https://www.npmjs.com/package/@lancedb/lancedb) +We tried to keep the API as similar as possible to the previous version, but there are a few small changes. Here are the most important ones: + +### Creating Tables + +[CreateTableOptions.writeOptions.writeMode](./javascript/interfaces/WriteOptions.md#writemode) has been replaced with [CreateTableOptions.mode](./js/interfaces/CreateTableOptions.md#mode) + +=== "vectordb (deprecated)" + + ```ts + db.createTable(tableName, data, { writeMode: lancedb.WriteMode.Overwrite }); + ``` + +=== "@lancedb/lancedb" + + ```ts + db.createTable(tableName, data, { mode: "overwrite" }) + ``` + ### Changes to Table APIs Previously `Table.schema` was a property. Now it is an async method. - #### Creating Indices The `Table.createIndex` method is now used for creating both vector indices @@ -92,5 +109,83 @@ and scalar indices. It currently requires a column name to be specified (the column to index). Vector index defaults are now smarter and scale better with the size of the data. -To specify index configuration details you will need to specify which kind of -index you are using. +=== "vectordb (deprecated)" + + ```ts + await tbl.createIndex({ + column: "vector", // default + type: "ivf_pq", + num_partitions: 2, + num_sub_vectors: 2, + }); + ``` + +=== "@lancedb/lancedb" + + ```ts + await table.createIndex("vector", { + config: lancedb.Index.ivfPq({ + numPartitions: 2, + numSubVectors: 2, + }), + }); + ``` + +### Embedding Functions + +The embedding API has been completely reworked, and it now more closely resembles the Python API, including the new [embedding registry](./js/classes/embedding.EmbeddingFunctionRegistry.md) + +=== "vectordb (deprecated)" + + ```ts + + const embeddingFunction = new lancedb.OpenAIEmbeddingFunction('text', API_KEY) + const data = [ + { id: 1, text: 'Black T-Shirt', price: 10 }, + { id: 2, text: 'Leather Jacket', price: 50 } + ] + const table = await db.createTable('vectors', data, embeddingFunction) + ``` + +=== "@lancedb/lancedb" + + ```ts + import * as lancedb from "@lancedb/lancedb"; + import * as arrow from "apache-arrow"; + import { LanceSchema, getRegistry } from "@lancedb/lancedb/embedding"; + + const func = getRegistry().get("openai").create({apiKey: API_KEY}); + + const data = [ + { id: 1, text: 'Black T-Shirt', price: 10 }, + { id: 2, text: 'Leather Jacket', price: 50 } + ] + + const table = await db.createTable('vectors', data, { + embeddingFunction: { + sourceColumn: "text", + function: func, + } + }) + + ``` + +You can also use a schema driven approach, which parallels the Pydantic integration in our Python SDK: + +```ts +const func = getRegistry().get("openai").create({apiKey: API_KEY}); + +const data = [ + { id: 1, text: 'Black T-Shirt', price: 10 }, + { id: 2, text: 'Leather Jacket', price: 50 } +] +const schema = LanceSchema({ + id: new arrow.Int32(), + text: func.sourceField(new arrow.Utf8()), + price: new arrow.Float64(), + vector: func.vectorField() +}) + +const table = await db.createTable('vectors', data, {schema}) + +``` diff --git a/nodejs/examples/basic.ts b/nodejs/examples/basic.ts index f632d047..3d8cdfea 100644 --- a/nodejs/examples/basic.ts +++ b/nodejs/examples/basic.ts @@ -1,7 +1,14 @@ // --8<-- [start:imports] import * as lancedb from "@lancedb/lancedb"; import * as arrow from "apache-arrow"; -import { Field, FixedSizeList, Float16, Int32, Schema } from "apache-arrow"; +import { + Field, + FixedSizeList, + Float16, + Int32, + Schema, + Utf8, +} from "apache-arrow"; // --8<-- [end:imports] @@ -11,15 +18,24 @@ const db = await lancedb.connect(uri); // --8<-- [end:connect] { // --8<-- [start:create_table] + const tbl = await db.createTable( + "myTable", + [ + { vector: [3.1, 4.1], item: "foo", price: 10.0 }, + { vector: [5.9, 26.5], item: "bar", price: 20.0 }, + ], + { mode: "overwrite" }, + ); + // --8<-- [end:create_table] + const data = [ { vector: [3.1, 4.1], item: "foo", price: 10.0 }, { vector: [5.9, 26.5], item: "bar", price: 20.0 }, ]; - const _tbl = await db.createTable("myTable", data); - // --8<-- [end:create_table] + { // --8<-- [start:create_table_exists_ok] - const _tbl = await db.createTable("myTable", data, { + const tbl = await db.createTable("myTable", data, { existsOk: true, }); // --8<-- [end:create_table_exists_ok] @@ -58,16 +74,13 @@ const db = await lancedb.connect(uri); { // --8<-- [start:create_empty_table] + const schema = new arrow.Schema([ - new arrow.Field( - "vector", - new arrow.FixedSizeList( - 2, - new arrow.Field("item", new arrow.Float32(), true), - ), - ), + new arrow.Field("id", new arrow.Int32()), + new arrow.Field("name", new arrow.Utf8()), ]); - const _tbl = await db.createEmptyTable("empty_table", schema); + + const empty_tbl = await db.createEmptyTable("empty_table", schema); // --8<-- [end:create_empty_table] } { diff --git a/nodejs/package-lock.json b/nodejs/package-lock.json index 34a57a45..9d9652d5 100644 --- a/nodejs/package-lock.json +++ b/nodejs/package-lock.json @@ -41,8 +41,8 @@ "shx": "^0.3.4", "tmp": "^0.2.3", "ts-jest": "^29.1.2", - "typedoc": "^0.25.7", - "typedoc-plugin-markdown": "^3.17.1", + "typedoc": "^0.26.4", + "typedoc-plugin-markdown": "^4.2.1", "typescript": "^5.3.3", "typescript-eslint": "^7.1.0" }, @@ -3720,6 +3720,15 @@ "node": ">= 8" } }, + "node_modules/@shikijs/core": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.10.3.tgz", + "integrity": "sha512-D45PMaBaeDHxww+EkcDQtDAtzv00Gcsp72ukBtaLSmqRvh0WgGMq3Al0rl1QQBZfuneO75NXMIzEZGFitThWbg==", + "dev": true, + "dependencies": { + "@types/hast": "^3.0.4" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -4493,7 +4502,8 @@ "node_modules/@types/command-line-args": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.2.3.tgz", - "integrity": "sha512-uv0aG6R0Y8WHZLTamZwtfsDLVRnOa+n+n5rEvFWL5Na5gZ8V2Teab/duDPFzIIIhs9qizDpcavCusCLJZu62Kw==" + "integrity": "sha512-uv0aG6R0Y8WHZLTamZwtfsDLVRnOa+n+n5rEvFWL5Na5gZ8V2Teab/duDPFzIIIhs9qizDpcavCusCLJZu62Kw==", + "peer": true }, "node_modules/@types/command-line-usage": { "version": "5.0.2", @@ -4509,6 +4519,15 @@ "@types/node": "*" } }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -4591,6 +4610,12 @@ "integrity": "sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==", "dev": true }, + "node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", + "dev": true + }, "node_modules/@types/yargs": { "version": "17.0.32", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", @@ -4709,12 +4734,6 @@ "node": ">=8" } }, - "node_modules/ansi-sequence-parser": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz", - "integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==", - "dev": true - }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -5533,6 +5552,18 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -6151,27 +6182,6 @@ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, - "node_modules/handlebars": { - "version": "4.7.8", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", - "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.2", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -7235,12 +7245,6 @@ "node": ">=6" } }, - "node_modules/jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", - "dev": true - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -7287,6 +7291,15 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", "dev": true }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "dependencies": { + "uc.micro": "^2.0.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -7357,18 +7370,29 @@ "tmpl": "1.0.5" } }, - "node_modules/marked": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", - "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", "dev": true, - "bin": { - "marked": "bin/marked.js" + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" }, - "engines": { - "node": ">= 12" + "bin": { + "markdown-it": "bin/markdown-it.mjs" } }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/md5": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", @@ -7380,6 +7404,12 @@ "is-buffer": "~1.1.6" } }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -7469,12 +7499,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true - }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -7872,6 +7896,15 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/pure-rand": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.4.tgz", @@ -8098,15 +8131,13 @@ } }, "node_modules/shiki": { - "version": "0.14.7", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz", - "integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.10.3.tgz", + "integrity": "sha512-eneCLncGuvPdTutJuLyUGS8QNPAVFO5Trvld2wgEq1e002mwctAhJKeMGWtWVXOIEzmlcLRqcgPSorR6AVzOmQ==", "dev": true, "dependencies": { - "ansi-sequence-parser": "^1.1.0", - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" + "@shikijs/core": "1.10.3", + "@types/hast": "^3.0.4" } }, "node_modules/shx": { @@ -8469,36 +8500,37 @@ } }, "node_modules/typedoc": { - "version": "0.25.7", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.7.tgz", - "integrity": "sha512-m6A6JjQRg39p2ZVRIN3NKXgrN8vzlHhOS+r9ymUYtcUP/TIQPvWSq7YgE5ZjASfv5Vd5BW5xrir6Gm2XNNcOow==", + "version": "0.26.4", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.4.tgz", + "integrity": "sha512-FlW6HpvULDKgc3rK04V+nbFyXogPV88hurarDPOjuuB5HAwuAlrCMQ5NeH7Zt68a/ikOKu6Z/0hFXAeC9xPccQ==", "dev": true, "dependencies": { "lunr": "^2.3.9", - "marked": "^4.3.0", - "minimatch": "^9.0.3", - "shiki": "^0.14.7" + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "shiki": "^1.9.1", + "yaml": "^2.4.5" }, "bin": { "typedoc": "bin/typedoc" }, "engines": { - "node": ">= 16" + "node": ">= 18" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x" + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" } }, "node_modules/typedoc-plugin-markdown": { - "version": "3.17.1", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.1.tgz", - "integrity": "sha512-QzdU3fj0Kzw2XSdoL15ExLASt2WPqD7FbLeaqwT70+XjKyTshBnUlQA5nNREO1C2P8Uen0CDjsBLMsCQ+zd0lw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.2.1.tgz", + "integrity": "sha512-7hQt/1WaW/VI4+x3sxwcCGsEylP1E1GvF6OTTELK5sfTEp6AeK+83jkCOgZGp1pI2DiOammMYQMnxxOny9TKsQ==", "dev": true, - "dependencies": { - "handlebars": "^4.7.7" + "engines": { + "node": ">= 18" }, "peerDependencies": { - "typedoc": ">=0.24.0" + "typedoc": "0.26.x" } }, "node_modules/typedoc/node_modules/brace-expansion": { @@ -8511,9 +8543,9 @@ } }, "node_modules/typedoc/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -8785,18 +8817,11 @@ "node": ">=8" } }, - "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", - "dev": true, - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true }, "node_modules/undici-types": { "version": "5.26.5", @@ -8869,18 +8894,6 @@ "node": ">=10.12.0" } }, - "node_modules/vscode-oniguruma": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", - "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", - "dev": true - }, - "node_modules/vscode-textmate": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", - "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", - "dev": true - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -8930,12 +8943,6 @@ "node": ">= 8" } }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", - "dev": true - }, "node_modules/wordwrapjs": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-5.1.0.tgz", @@ -8982,6 +8989,18 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/yaml": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", + "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", + "dev": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", diff --git a/nodejs/package.json b/nodejs/package.json index c289d9d9..52cc60f7 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -50,8 +50,8 @@ "shx": "^0.3.4", "tmp": "^0.2.3", "ts-jest": "^29.1.2", - "typedoc": "^0.25.7", - "typedoc-plugin-markdown": "^3.17.1", + "typedoc": "^0.26.4", + "typedoc-plugin-markdown": "^4.2.1", "typescript": "^5.3.3", "typescript-eslint": "^7.1.0", "@types/axios": "^0.14.0" diff --git a/nodejs/typedoc.json b/nodejs/typedoc.json index 6757e9ab..de09eda8 100644 --- a/nodejs/typedoc.json +++ b/nodejs/typedoc.json @@ -6,5 +6,7 @@ "lancedb/native.d.ts:VectorQuery", "lancedb/native.d.ts:RecordBatchIterator", "lancedb/native.d.ts:Table" - ] + ], + "useHTMLEncodedBrackets": true, + "disableSources": true }