LanceDB
Langchain Vector store for LanceDB. Embedded database with local directory-based storage and approximate nearest neighbor search.
Install
pip install langchain-lancedb
or
uv add langchain-lancedb
API Reference
__init__
def __init__(
self,
embedding_function: Embeddings | None = None,
uri: str | Path = "./.rag_cache/db/lancedb",
table_name: str = "documents",
namespace: str | None = None,
**kwargs,
)
| Parameter | Type | Description |
|---|---|---|
embedding_function |
Embeddings | None |
Embedding function used to embed queries and texts (e.g., FastEmbedEmbeddings). |
uri |
str | Path |
URI for the LanceDB database (local directory path). Default "./.rag_cache/db/lancedb". |
table_name |
str |
Table name for storing documents. Default "documents". |
namespace |
str | None |
Optional namespace prefix for the table (creates {namespace}.{table_name}). |
from_texts
def from_texts(
cls,
texts: list[str],
embedding: Embeddings | None = None,
metadatas: list[dict] | None = None,
ids: list[str] | None = None,
uri: str | Path = "./.rag_cache/db/lancedb",
table_name: str | None = None,
namespace: str | None = None,
**kwargs,
) -> LanceDB
| Parameter | Type | Description |
|---|---|---|
texts |
list[str] |
Texts to index. |
embedding |
Embeddings | None |
Embedding function. |
metadatas |
list[dict] | None |
Optional metadata dicts, one per text. |
ids |
list[str] | None |
Optional document IDs. Auto-generated via SHA-256 if not provided. |
uri |
str | Path |
URI for the LanceDB database. Default "./.rag_cache/db/lancedb". |
table_name |
str | None |
Table name. Default "documents". |
namespace |
str | None |
Optional namespace prefix for the table. |
Returns: LanceDB — a new vector store with the texts indexed.
add_texts
def add_texts(
self,
texts: list[str],
metadatas: list[dict] | None = None,
ids: list[str] | None = None,
**kwargs,
) -> list[str]
| Parameter | Type | Description |
|---|---|---|
texts |
list[str] |
Texts to add. |
metadatas |
list[dict] | None |
Optional metadata dicts, one per text. Defaults to {}. |
ids |
list[str] | None |
Optional document IDs. Auto-generated via SHA-256 if not provided. |
Returns: list[str] — the IDs of the added texts. On first call, automatically creates the LanceDB table with inferred schema.
delete
def delete(
self,
ids: list[str] | None = None,
**kwargs,
) -> bool | None
| Parameter | Type | Description |
|---|---|---|
ids |
list[str] | None |
List of document IDs to remove. |
Returns: bool \| None — True if deletion succeeded, False if no table exists. Raises ValueError if ids is None.
similarity_search
def similarity_search(
self,
query: str,
k: int = 4,
**kwargs,
) -> list[Document]
| Parameter | Type | Description |
|---|---|---|
query |
str |
Query text. |
k |
int |
Number of documents to return. Default 4. |
Returns: list[Document] — documents most similar to the query, ordered by distance (ascending).
similarity_search_with_score
def similarity_search_with_score(
self,
query: str,
k: int = 4,
**kwargs,
) -> list[tuple[Document, float]]
| Parameter | Type | Description |
|---|---|---|
query |
str |
Query text. |
k |
int |
Number of documents to return. Default 4. |
Returns: list[tuple[Document, float]] — tuples of (Document, distance). Lower distance = more similar. Uses LanceDB's built-in ANN search.
Metadata
Release files for langchain-lancedb 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_lancedb-0.1.0.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_lancedb-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / langchain_lancedb-0.1.0.tar.gz
| Download URL | langchain_lancedb-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e180b77506a175385ef1bbdb05ac62d8ca9815b1c8c5c326437acb68940feaef
|
|
BLAKE2b-256 checksum How to use checksums |
63390a88d9185841297ef1b8799ad7853de8fc12033833b53cfce849f73c0d5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.17
|
Release files / langchain_lancedb-0.1.0-py3-none-any.whl
| Download URL | langchain_lancedb-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
938e195f955aa755a32176e770ebc2b94a42dc8ed4bb2dfaa9cb6e9c58b846d6
|
|
BLAKE2b-256 checksum How to use checksums |
6ce3905efbf35a723a21295a4dbc6082bb1b1da7c80106238a7c713df96bc849
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.17
|