Skip to content

API Reference parrot.stores.lancedb_models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.stores.lancedb_models

View source

Validated configuration, manifest, schema and identity for the LanceDB backend.

Pure module: no SDK import, no I/O. Everything here is consumed by lancedb.py (TASK-3062+) and re-derived independently by tests.

Class CollectionManifest

Versioned identity persisted in the Arrow schema metadata.

Fields:

Field Type Default Description
schema_version int SCHEMA_VERSION
collection_uuid str
dimension int
metric_type str
embedding_fingerprint str
metadata_fields dict[str, str]

Method CollectionManifest.check_compatible

Raise an actionable, non-destructive error on reopen mismatch.

On reopen, unspecified settings come FROM the manifest (the caller is expected to have derived config/embedding_fingerprint_value accordingly before calling this). This method only rejects an explicit mismatch; it never migrates or overwrites persisted data.

check_compatible(config: 'LanceDBConfig', embedding_fingerprint_value: str) -> None

Parameter Type Default Description
config 'LanceDBConfig'
embedding_fingerprint_value str

Class LanceDBConfig

Backend-owned settings, validated once before any SDK operation.

Fields:

Field Type Default Description
uri str
collection_name str 'my_collection'
dimension int 768
metric_type Literal['COSINE'] 'COSINE'
index_type Literal['FLAT'] 'FLAT'
embedding_id str | None None
metadata_fields dict[str, Literal['str', 'bool', 'int', 'float']]
read_consistency_interval_seconds float 0.0
batch_size int 128

Class LanceDBHybridHit

Backend-owned hybrid result. Deliberately has no distance alias.

Fields:

Field Type Default Description
id str
content str
metadata dict[str, Any]
score float
score_kind Literal['rrf'] 'rrf'
higher_is_better Literal[True] True

Attribute RESERVED_METADATA_KEY

Attribute SCHEMA_VERSION

Attribute STANDARD_BOOL_FIELDS

Attribute STANDARD_STRING_FIELDS

Function build_arrow_schema

Explicit Arrow schema carrying the manifest in schema metadata.

Imports pyarrow lazily so this module stays importable (and unit testable) without the optional lancedb/pyarrow extra installed at the call site — pyarrow itself is a core dependency (packages/ai-parrot/pyproject.toml:157), but keeping the import local avoids surprising import-time side effects for a pure-model module.

build_arrow_schema(config: LanceDBConfig, manifest: CollectionManifest)

Parameter Type Default Description
config LanceDBConfig
manifest CollectionManifest

Function embedding_fingerprint

Stable identity for an embedding configuration, excluding credentials.

Contextual-embedding settings are part of the identity fingerprint (spec §2), so every key that is not credential-shaped is included.

embedding_fingerprint(settings: dict[str, Any]) -> str

Parameter Type Default Description
settings dict[str, Any]

Returns: str

Function namespaced_id

lancedb:<collection_uuid>:<percent-encoded record_id>.

namespaced_id(collection_uuid: str, record_id: str) -> str

Parameter Type Default Description
collection_uuid str
record_id str

Returns: str

Function record_id_for

Fallback identity: sha256 of ORIGINAL text plus canonical original metadata.

Must be computed on the caller's original document/metadata, BEFORE any contextual augmentation is applied (spec §2 "Data Models").

record_id_for(text: str, metadata: dict[str, Any]) -> str

Parameter Type Default Description
text str
metadata dict[str, Any]

Returns: str

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally