fabricatio_lancedb.rust

Classes

SearchedDocument

Represents a document that has been searched and retrieved from the vector store.

StoreDocument

VectorStoreService

A service for managing vector stores using LanceDB.

VectorStoreTable

Package Contents

class fabricatio_lancedb.rust.SearchedDocument

Represents a document that has been searched and retrieved from the vector store.

This structure contains the core information of a searched document including its unique identifier, content, timestamp of creation/modification, and any associated metadata stored as JSON string.

property id: str

Unique identifier for the document, typically generated as a UUID string.

property content: str

The textual content of the document that was searched and matched.

property timestamp: int

Timestamp indicating when the document was created or last updated.

property metadata: str | None

Optional metadata associated with the document, stored as a JSON string.

This can include additional contextual information about the document.

access_metadata() dict

Access the metadata of the document.

Returns a Python dictionary representation of the document’s metadata. If no metadata exists, returns an empty dictionary.

class fabricatio_lancedb.rust.StoreDocument
property content: str
property vector: list[float]
property metadata: str | None
static with_metadata(content: str, vector: Sequence[float], metadata: dict | None) StoreDocument

Create a new Document instance with metadata dict.

class fabricatio_lancedb.rust.VectorStoreService

A service for managing vector stores using LanceDB.

This service provides methods for connecting to a LanceDB instance, creating tables, opening existing tables, and creating or opening tables. It acts as a high-level interface for vector store operations.

static connect(uri: str) Awaitable[Self]

Connect to a lancedb instance.

create_table(table_name: str, ndim: int) Awaitable[VectorStoreTable]

Create a table.

open_table(table_name: str) Awaitable[VectorStoreTable]

Open a table.

create_or_open_table(table_name: str, ndim: int) Awaitable[VectorStoreTable]

Create or open a table.

class fabricatio_lancedb.rust.VectorStoreTable
add_documents(documents: list[StoreDocument], rebuild_index: bool = True) Awaitable[list[str]]

Adds multiple documents to the vector store.

Parameters:
  • documents – A list of StoreDocument objects to be added to the store.

  • rebuild_index – If True (default), rebuild the vector index after adding. Set to False for bulk inserts.

Returns:

An awaitable that resolves to a list of document IDs.

rebuild_index() Awaitable[None]

Rebuilds the vector index on the table.

Useful after bulk inserts with rebuild_index=False. No-op if the table has fewer than 256 rows (minimum for PQ training).

search_document(embedding: Sequence[float], limit: int) Awaitable[list[SearchedDocument]]

Searches for documents similar to the given embedding vector.

Parameters:
  • embedding – A vector representing the query embedding for similarity search.

  • limit – The maximum number of similar documents to return.

Returns:

An awaitable that resolves to a list of SearchedDocument objects.