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.4.0
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.9 MB
Release files / fabricatio_lancedb-0.4.0-cp314-cp314-win_amd64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 58.5 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f15918600582f597b5292469555a8b37b0da2eb8d24521508859d30a096ee7ec
|
|
BLAKE2b-256 checksum How to use checksums |
92d0dbc9ae974132cf98d551b4a6e57a0c747f45c9a7dd66e4ffafa26aa3b2b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp314-cp314-manylinux_2_38_x86_64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp314-cp314-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 62.3 MB |
| Tags | CPython 3.14 Linux glibc 2.38+ x86-64 |
|
SHA-256 checksum How to use checksums |
35326d5ed8840994b0e23f5123dcb72ed6b33ece3747b4edceff367a99c4502e
|
|
BLAKE2b-256 checksum How to use checksums |
b46635c0d3ced7d6058bd365f27a74fe8718bfb1d893f55f1d6a22a21b3e6cfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp314-cp314-manylinux_2_38_aarch64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp314-cp314-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 54.3 MB |
| Tags | CPython 3.14 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
da510e0730e3a212611abd0650feef41f335a69f514862f8264f4efe64292e5e
|
|
BLAKE2b-256 checksum How to use checksums |
72387cefd8dbafc0ea68ee0a2b3c610b651cc78c46c461ea87deffed62abb13c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | fabricatio_lancedb-0.4.0-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 |
e3253d9dbef6e4e3b03c0f5ca1134b1c417b92f5291e1e66aaeca28822f5d117
|
|
BLAKE2b-256 checksum How to use checksums |
4dbafcf8a98575ed1af0a3058d1167093c54a709d2769f8ec1e1ffe6cf2e44d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp313-cp313-win_amd64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 58.4 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6f37167df5234585f6f515549e98ddb3e2cd58fce47209a3d16c95d3fa302d47
|
|
BLAKE2b-256 checksum How to use checksums |
bb5e48a29a71d12aac5fa3dfa24bcd5dcc31391272c1660de37d130698479ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp313-cp313-manylinux_2_38_x86_64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp313-cp313-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 62.3 MB |
| Tags | CPython 3.13 Linux glibc 2.38+ x86-64 |
|
SHA-256 checksum How to use checksums |
ca30cf240be9b5e1a56a3d6428651982447f167c6bc103406645e8b7e48274f8
|
|
BLAKE2b-256 checksum How to use checksums |
f81fa82b3d5b99e739b61d94f36393f709ff67cbda270064fbf83f92ee39a435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp313-cp313-manylinux_2_38_aarch64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp313-cp313-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 54.3 MB |
| Tags | CPython 3.13 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
7d05da64ed3d84e430c10c35e1f15a841f8d21c95c80089557aac514443e4690
|
|
BLAKE2b-256 checksum How to use checksums |
c59091a1783d725de98c2026f7a4bfd04867f4a03aa6a4f3c0f6cde39f92a2ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | fabricatio_lancedb-0.4.0-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 |
c456e25e3dc60904d1296c5f583a83247d0319c064204bf436ed5b294dcef0e8
|
|
BLAKE2b-256 checksum How to use checksums |
a34ebe937d42897cc60f19977b41bfb75407476208bde6a693edc7886844926e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp312-cp312-win_amd64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 58.5 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f2678c3563861df2f31f53b77848d026cab0caa2c448358f51e130328c93d14e
|
|
BLAKE2b-256 checksum How to use checksums |
dfac95ca7d8471d3b7159b79789d85df4e793995aed4c3f398b82130bdc28189
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp312-cp312-manylinux_2_38_x86_64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp312-cp312-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 62.3 MB |
| Tags | CPython 3.12 Linux glibc 2.38+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ad14b6846be61f94d4cc7772d483a543a8ad56096c26b72296b2c95240c16e4
|
|
BLAKE2b-256 checksum How to use checksums |
c2d9bd27659d8ab65b7c046b120d176025ad5b9bc4678199ee0d81974ec6a60c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp312-cp312-manylinux_2_38_aarch64.whl
| Download URL | fabricatio_lancedb-0.4.0-cp312-cp312-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 54.3 MB |
| Tags | CPython 3.12 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
ec9cfa315c259ecea5b158c4c8ce133e5e61b3b0a32f3981096b695441ac8eb9
|
|
BLAKE2b-256 checksum How to use checksums |
edc10d8e0242f013e30f573a6d67001310b88a646063e6d733df19e361860261
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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.4.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | fabricatio_lancedb-0.4.0-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 |
07388f91320154f739ff92eaa485fbc2a62b1cec069a3555269339d1d6aaa756
|
|
BLAKE2b-256 checksum How to use checksums |
2fa0a2d1be4979107bd4fe64fbf089f6e8dce79dffc551ff8583124753fee890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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}
|