fabricatio-lancedb
LanceDB vector store backend for Fabricatio RAG. Provides async Rust-backed table operations — creation, document insertion, vector similarity search, and index rebuilding — plus Python-side RAG capability mixins and document models.
Architecture
The package has two layers:
| Layer | Language | Key Types | Purpose |
|---|---|---|---|
| Rust (PyO3) | Rust | VectorStoreService, VectorStoreTable, StoreDocument, SearchedDocument |
High-performance LanceDB table ops with async execution |
| Python | Python | LancedbRAG, LancedbDocumentModel, LancedbConfig |
RAG capability, document models, configuration |
The Rust layer manages LanceDB connections and tables. The Python layer
implements the fabricatio-rag RAG interface on top of those primitives:
batching embeddings, inserting documents, and searching by vector.
Installation
pip install fabricatio[lancedb]
# or
uv pip install fabricatio[lancedb]
For all Fabricatio extras:
pip install fabricatio[full]
Configuration
All options below are read through the fabricatio configuration chain (see the
Configuration Guide at ../../docs/source/configuration.rst). Set them under the
[ext.lancedb] table in fabricatio.toml, equivalently under
[tool.fabricatio.ext.lancedb] in pyproject.toml, or via
FABRICATIO_EXT__LANCEDB__<FIELD_UPPER> environment variables.
# fabricatio.toml
[ext.lancedb]
database_uri = "./lance.db"
default_table_name = "default"
| Option | Type | Default | Description |
|---|---|---|---|
database_uri |
str |
"./lance.db" |
LanceDB connection URI (local path or S3 s3://bucket/path) |
default_table_name |
str |
"default" |
Table name used when none is specified |
Access at runtime: from fabricatio_lancedb.config import lancedb_config.
Usage
Low-level Rust API
Direct table operations with async Rust execution:
import asyncio
from fabricatio_lancedb.rust import VectorStoreService, VectorStoreTable, StoreDocument
async def main():
# Connect to LanceDB
service = await VectorStoreService.connect("./lance.db")
# Create a table for 1536-dim embeddings (OpenAI text-embedding-3-small)
table = await service.create_table("my_table", ndim=1536)
# Add documents
docs = [
StoreDocument(
content="LanceDB is a fast, open-source vector database.",
vector=[0.1] * 1536,
),
StoreDocument.with_metadata(
content="Fabricatio is an LLM application framework.",
vector=[0.2] * 1536,
metadata={"source": "docs", "version": "1.0"},
),
]
ids = await table.add_documents(docs)
print(f"Inserted: {ids}")
# Search by embedding
results = await table.search_document(embedding=[0.15] * 1536, limit=5)
for r in results:
print(f"{r.id}: {r.content[:60]}...")
print(f" metadata: {r.access_metadata()}")
# Rebuild the index after bulk inserts with rebuild_index=False
await table.rebuild_index()
asyncio.run(main())
RAG capability (high-level)
Integrate with Fabricatio's RAG system using the LancedbRAG mixin:
from fabricatio_lancedb.capabilities.lancedb import LancedbRAG, LancedbAddRAGConfig, LancedbFetchRAGConfig
from fabricatio_lancedb.models.lancedb import LancedbDocumentModel
class MyDoc(LancedbDocumentModel):
"""Custom document with additional fields."""
title: str = ""
class MyRAGRole(SomeBaseRole, LancedbRAG[MyDoc, LancedbAddRAGConfig, LancedbFetchRAGConfig[MyDoc]]):
pass
async def run():
role = MyRAGRole(name="my-rag-role")
# Add a document — handles embedding batching internally
await role.add_document(
MyDoc(content="Semantic search with LanceDB and Fabricatio.", title="Intro"),
config=LancedbAddRAGConfig(table_name="docs", embedding_batch_size=20),
)
# Fetch relevant documents
results = await role.afetch_document(
"how does semantic search work",
config=LancedbFetchRAGConfig(document_model=MyDoc, limit=10),
)
for doc in results:
print(f"[{doc.title}] {doc.content}")
Cached service helper
Reuse connections across calls:
from fabricatio_lancedb.inited_service import get_service
service = await get_service("s3://my-bucket/lancedb")
table = await service.open_table("production_docs")
API Reference
Rust layer (fabricatio_lancedb.rust)
VectorStoreService
| Method | Signature | Returns | Description |
|---|---|---|---|
connect |
(uri: str) -> Awaitable[Self] |
VectorStoreService |
Static — connect to a LanceDB instance |
create_table |
(table_name: str, ndim: int) -> Awaitable[VectorStoreTable] |
VectorStoreTable |
Create a new table with the given vector dimension |
open_table |
(table_name: str) -> Awaitable[VectorStoreTable] |
VectorStoreTable |
Open an existing table |
create_or_open_table |
(table_name: str, ndim: int) -> Awaitable[VectorStoreTable] |
VectorStoreTable |
Create if absent, otherwise open |
VectorStoreTable
| Method | Signature | Returns | Description |
|---|---|---|---|
add_documents |
(documents: list[StoreDocument], rebuild_index: bool = True) -> Awaitable[list[str]] |
Document IDs | Insert documents; set rebuild_index=False for bulk inserts |
search_document |
(embedding: list[float], limit: int, dedup_threshold: float | None = None) -> Awaitable[list[SearchedDocument]] |
Search results | Nearest-neighbor vector search; with dedup_threshold, near-duplicates (cosine similarity ≥ threshold vs. an already-kept result) are dropped and replaced by deeper candidates |
rebuild_index |
() -> Awaitable[None] |
None | Rebuild the vector index (no-op if <256 rows) |
StoreDocument
| Field | Type | Description |
|---|---|---|
content |
str |
Document text content |
vector |
list[float] |
Dense embedding vector |
metadata |
str | None |
Optional JSON-serialized metadata |
Static constructor StoreDocument.with_metadata(content, vector, metadata: dict) serializes
the metadata dict to JSON.
SearchedDocument
| Property | Type | Description |
|---|---|---|
id |
str |
UUID document identifier |
content |
str |
Matched document text |
timestamp |
int |
Microsecond-precision timestamp |
metadata |
str | None |
Raw JSON metadata string |
Method access_metadata() -> dict parses the JSON metadata into a Python dict.
Python layer
LancedbRAG
Extends RAG from fabricatio-rag with LanceDB storage.
| Method | Description |
|---|---|
add_document(data, config) |
Vectorize and insert one or more documents |
afetch_document(query, config) |
Vectorize a query string and return matching documents |
rebuild_index(table_name?) |
Rebuild the vector index on a table |
LancedbAddRAGConfig
Dataclass config for add_document:
| Field | Default | Description |
|---|---|---|
table_name |
lancedb_config.default_table_name |
Target table |
embedding_batch_size |
10 |
Documents per embedding batch |
embedding_parallel_size |
10 |
Max concurrent embedding calls |
rebuild_index |
False |
Rebuild index after insertion |
LancedbFetchRAGConfig
Dataclass config for afetch_document:
| Field | Default | Description |
|---|---|---|
table_name |
lancedb_config.default_table_name |
Source table |
document_model |
None (required) |
Document model class for deserialization |
limit |
15 |
Max results returned |
dedup_cos_threshold |
0.95 |
Cosine similarity at which a candidate is treated as a duplicate of an already-selected result; None disables deduplication |
LancedbDocumentModel
Extends StoredDocumentModel and SearchedDocumentModel. Fields: content (str), metadata (dict | None).
| Method | Description |
|---|---|
prepare_insertion(vector) -> StoreDocument |
Build a Rust StoreDocument ready for insertion |
from_raw(raw: SearchedDocument) -> Self |
Deserialize a Rust SearchedDocument |
with_text_chunk(chunk: str) -> Self |
Create from a plain text chunk |
Schema
Each LanceDB table uses this Arrow schema:
| Column | Type | Nullable | Description |
|---|---|---|---|
item |
Utf8 |
no | Primary key (UUID v7) |
timestamp |
Time64(us) |
no | Insertion timestamp |
vector |
FixedSizeList(Float32, ndim) |
no | Embedding vector |
content |
Utf8 |
no | Document text |
metadata |
Utf8 |
yes | JSON-serialized metadata |
Dependencies
fabricatio-core— core interfaces and configurationfabricatio-rag— base RAG abstractions (RAG, document models)more-itertools— chunked iteration for batch processingasync-lru— async LRU caching
Rust dependencies (via PyO3): lancedb, arrow, pyo3, tokio.
License
This project is licensed under the MIT License — see LICENSE.
Metadata
Release files for fabricatio-lancedb 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 686.0 MB
Release files / fabricatio_lancedb-0.3.5-cp314-cp314-win_amd64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 58.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
df6e2d8191f463b6b87c74a12a28fcf1d70b6cf2dc18b3e15c82f651b19db584
|
|
BLAKE2b-256 checksum How to use checksums |
b9ab07de952553abea6c9118e4ab2d6097bb6849d4b673b28e942e47ac9eb53e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp314-cp314-manylinux_2_38_x86_64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp314-cp314-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 62.1 MB |
| Tags | CPython 3.14 Linux glibc 2.38+ x86-64 |
|
SHA-256 checksum How to use checksums |
3d6f0164dffc3995be895161d122d60aa8002f89fd78250da89d605194294343
|
|
BLAKE2b-256 checksum How to use checksums |
f9dffca9077daf5462909bb9131127a5a2d0a954507ba927deb27e46a6b298ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp314-cp314-manylinux_2_38_aarch64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp314-cp314-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 54.2 MB |
| Tags | CPython 3.14 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
2a2ff005b49c539a2a1256a3e5bb2a36f49afb25612d42694f97f8c14abb77a5
|
|
BLAKE2b-256 checksum How to use checksums |
92be2111b40c137fe7589d9e8af24f13ae3a5178885a220b54af67149ced150f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 53.9 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
548b1666d3723995a2454b25f0b4719c4119950ea2355455b1d961d89087be2e
|
|
BLAKE2b-256 checksum How to use checksums |
55e61b4d1f9f863a99c2a17bd684ca4a981b01e885a9ac3995b241d550dd25af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp313-cp313-win_amd64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 58.4 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f64159e589fe0e7061ff3c5f0e289f6a7e9eddcad725e6b51103bab7e2e0c555
|
|
BLAKE2b-256 checksum How to use checksums |
e4955df1d4f59d44a02a6da06b9a7ffe1ab5c926e01c9910cb60da1a03d891ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp313-cp313-manylinux_2_38_x86_64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp313-cp313-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 62.1 MB |
| Tags | CPython 3.13 Linux glibc 2.38+ x86-64 |
|
SHA-256 checksum How to use checksums |
fff81b9369a85ae09a51cd1f7dbd25b07b0c2c281dddbab5cef9fabee5806414
|
|
BLAKE2b-256 checksum How to use checksums |
e5fe12d3833d23a96312939f8916aacf45d56888256343cd0f7ad8190f0786a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp313-cp313-manylinux_2_38_aarch64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp313-cp313-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 54.2 MB |
| Tags | CPython 3.13 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
d482e180928eaa647ba6b56c41b2efd7a38b5cad3e857643f216f06b7dcfca0f
|
|
BLAKE2b-256 checksum How to use checksums |
18a5777d40575ce8cc2861e6cb7f12ae163d533ecf0dd4bac72a552b62b1bd92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 53.9 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
91dcaaf0e6b1c8dba50791a0796db52314bb00d539919b7df27d4715e9d27433
|
|
BLAKE2b-256 checksum How to use checksums |
34507e275a3017c8aa39ebb36c33e6ef4138bd2985cdfbdd8a4c2acbf24b8ae1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp312-cp312-win_amd64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 58.4 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9463d438e53bfca2b4a29ea998b47ee829acffee54b78ca7d92fc4d6407566eb
|
|
BLAKE2b-256 checksum How to use checksums |
aac49b06678647af60d032485bfa8334c58c5be45240d447bfaeb0502043584a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp312-cp312-manylinux_2_38_x86_64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp312-cp312-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 62.1 MB |
| Tags | CPython 3.12 Linux glibc 2.38+ x86-64 |
|
SHA-256 checksum How to use checksums |
51245b74678d99ee4208d6fdd0f05388e3738f5e8bf616064e0173c9605d9ebb
|
|
BLAKE2b-256 checksum How to use checksums |
8cc666a9bb52a6339f3efc9149bb04e377545172e45b9b61ca8a915a6d6048cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp312-cp312-manylinux_2_38_aarch64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp312-cp312-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 54.2 MB |
| Tags | CPython 3.12 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
d099f5616552551bd236b2f99e4c7e8db8bf007660a8aa62c640788b6de9769b
|
|
BLAKE2b-256 checksum How to use checksums |
2d3db104f21d78288fd32fde0cbe3d8ce19d416f42a993caf095e399ba6ca474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fabricatio_lancedb-0.3.5-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | fabricatio_lancedb-0.3.5-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 53.9 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b81d06f5e60f956c0362788b743b2ffa5813a08064f5592a9196bba6f729d18c
|
|
BLAKE2b-256 checksum How to use checksums |
78027bc45bee20b0c904ffca57e7e360af66807ce3aceef87db0da4829950510
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|