Skip to main content

fabricatio-lancedb

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Bindings: PyO3 Build Tool: uv + maturin

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 configuration
  • fabricatio-rag — base RAG abstractions (RAG, document models)
  • more-itertools — chunked iteration for batch processing
  • async-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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fabricatio-lancedb 0.4.1
File Actions
fabricatio_lancedb-0.4.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for fabricatio_lancedb-0.4.1-cp314-cp314-win_amd64.whl
fabricatio_lancedb-0.4.1-cp314-cp314-manylinux_2_39_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.39+ ARM64 Details for fabricatio_lancedb-0.4.1-cp314-cp314-manylinux_2_39_aarch64.whl
fabricatio_lancedb-0.4.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for fabricatio_lancedb-0.4.1-cp314-cp314-macosx_11_0_arm64.whl
fabricatio_lancedb-0.4.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for fabricatio_lancedb-0.4.1-cp313-cp313-win_amd64.whl
fabricatio_lancedb-0.4.1-cp313-cp313-manylinux_2_39_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.39+ ARM64 Details for fabricatio_lancedb-0.4.1-cp313-cp313-manylinux_2_39_aarch64.whl
fabricatio_lancedb-0.4.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for fabricatio_lancedb-0.4.1-cp313-cp313-macosx_11_0_arm64.whl
fabricatio_lancedb-0.4.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for fabricatio_lancedb-0.4.1-cp312-cp312-win_amd64.whl
fabricatio_lancedb-0.4.1-cp312-cp312-manylinux_2_39_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ ARM64 Details for fabricatio_lancedb-0.4.1-cp312-cp312-manylinux_2_39_aarch64.whl
fabricatio_lancedb-0.4.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for fabricatio_lancedb-0.4.1-cp312-cp312-macosx_11_0_arm64.whl

Total release size: 591.0 MB

Release files / fabricatio_lancedb-0.4.1-cp314-cp314-win_amd64.whl

Download URL fabricatio_lancedb-0.4.1-cp314-cp314-win_amd64.whl
Size 68.8 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
a98c8992caae5030eee0700d22a3e6a0d6261c98ab48525c9897a6cc9c7d1b64
BLAKE2b-256 checksum
How to use checksums
41a43dbafb1dfec7e30283f170ff1a5bf7cdb9594ecdb0b3f1b0ad703d39e7b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp314-cp314-manylinux_2_39_aarch64.whl

Download URL fabricatio_lancedb-0.4.1-cp314-cp314-manylinux_2_39_aarch64.whl
Size 64.8 MB
Tags CPython 3.14 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
adca85ef484f4a119c6fd2e9e740f9c3bf483cfac9c0678fefbd90dc7fff66d3
BLAKE2b-256 checksum
How to use checksums
a51190c07fed053826aa7752a1ae8eaf62fac9768269c18b604f28cd5911bbe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL fabricatio_lancedb-0.4.1-cp314-cp314-macosx_11_0_arm64.whl
Size 63.4 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fec485d745dff959cca32d4c95cf58449416c688673de186b5cf35bc8c77ecb5
BLAKE2b-256 checksum
How to use checksums
633dc9ea62bba9c8f96710e4cb82c368f189d97de808595ff6fd93d7137c419c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp313-cp313-win_amd64.whl

Download URL fabricatio_lancedb-0.4.1-cp313-cp313-win_amd64.whl
Size 68.8 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
7c95842945e7de0ef5420a89da036b533fd795080efcfc3056017f3fe7c817df
BLAKE2b-256 checksum
How to use checksums
1f7a8757de70fafb270d902203c1c3e2b1c7b1ec607a2619ecad0de15df6e656
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp313-cp313-manylinux_2_39_aarch64.whl

Download URL fabricatio_lancedb-0.4.1-cp313-cp313-manylinux_2_39_aarch64.whl
Size 64.7 MB
Tags CPython 3.13 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
ebe57e4f10ad9673bba35421000ed1887dcf4727ad1f7b0160862eba52102584
BLAKE2b-256 checksum
How to use checksums
5133fbd952bb27139840239e9f32e7af540f648a8de10c375ed2be666628a7ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL fabricatio_lancedb-0.4.1-cp313-cp313-macosx_11_0_arm64.whl
Size 63.4 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
60a8b77671d5aa1ff18ae210a02713f6d154cbb17bff0fd24339bf003e3f0e8e
BLAKE2b-256 checksum
How to use checksums
8be8733941fe8593edae8cfbefc6789d235608e4db80d3ca9081b142f44f22cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp312-cp312-win_amd64.whl

Download URL fabricatio_lancedb-0.4.1-cp312-cp312-win_amd64.whl
Size 68.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
72e529d8df39635baa4aa99cd5c3b65f4a714ce319adadc1ba8e0e9a3fe20eb6
BLAKE2b-256 checksum
How to use checksums
5a7bf875f8d4dbea132f8c022e7cdae95b27bd9f3dc702282255185d5d134403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp312-cp312-manylinux_2_39_aarch64.whl

Download URL fabricatio_lancedb-0.4.1-cp312-cp312-manylinux_2_39_aarch64.whl
Size 64.7 MB
Tags CPython 3.12 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
6e0fe293e53213a5c42fbaf8e0e201cd9a0902bbf2a648cff5b2ee70e2b21f7c
BLAKE2b-256 checksum
How to use checksums
b0a0a9c2283bca57759da1006a52f1a1a8fdeb92e01110412edd7e6ec357c026
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL fabricatio_lancedb-0.4.1-cp312-cp312-macosx_11_0_arm64.whl
Size 63.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
084ae492bb448667c8d179d03e9cced9fd642ef032fbd420428dbf58b9dc49e3
BLAKE2b-256 checksum
How to use checksums
7cf18465fa72877715d98f65ca4e0269d7ef0008f19ede67eaaef4b654ce95c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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}

Security for fabricatio-lancedb 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page