Rust-backed Client Migration Guide
In an effort to ensure all clients have the same set of capabilities we havemigrated the Python and Node clients onto a common Rust base library. In Python,both the synchronous and asynchronous clients are based on this implementation.In Node, the new client is available as@lancedb/lancedb
, which replacesthe existingvectordb
package.
This guide describes the differences between the two Node APIs and will hopefully assist usersthat would like to migrate to the new API.
TypeScript/JavaScript
For JS/TS users, we offer a brand new SDK@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 has been replaced withCreateTableOptions.mode
Changes to Table APIs
PreviouslyTable.schema
was a property. Now it is an async method.
Creating Indices
TheTable.createIndex
method is now used for creating both vector indicesand scalar indices. It currently requires a column name to be specified (thecolumn to index). Vector index defaults are now smarter and scale better withthe size of the data.
Embedding Functions
The embedding API has been completely reworked, and it now more closely resembles the Python API, including the newembedding registry:
import*aslancedbfrom"@lancedb/lancedb";import*asarrowfrom"apache-arrow";import{LanceSchema,getRegistry}from"@lancedb/lancedb/embedding";constfunc=getRegistry().get("openai").create({apiKey:API_KEY});constdata=[{id:1,text:'Black T-Shirt',price:10},{id:2,text:'Leather Jacket',price:50}]consttable=awaitdb.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:
constfunc=getRegistry().get("openai").create({apiKey:API_KEY});constdata=[{id:1,text:'Black T-Shirt',price:10},{id:2,text:'Leather Jacket',price:50}]constschema=LanceSchema({id:newarrow.Int32(),text:func.sourceField(newarrow.Utf8()),price:newarrow.Float64(),vector:func.vectorField()})consttable=awaitdb.createTable('vectors',data,{schema})