Skip to content

Vector store

gutenberg_kg.vector_store

vector_store.py — locate a KG's sqlite-vec store.

GutenbergKG orchestrates other KGs' stores — DocKG under .dockg/ and DiaryKG under .diarykg/ — and registers or reads each one's vector store. The store is a single vectors.sqlite file. A lancedb/ directory left by a pre-migration build is not a store: LanceDB support was removed fleet-wide with kgmodule-utils and doc-kg 0.29.0, so such a store is rebuilt, not read.

:seealso: kg_rag.primitives.KGEntry.vectors_path.

resolve_vectors_path(store_dir)

Return the sqlite-vec store in a KG store directory, if it exists.

Parameters:

Name Type Description Default
store_dir Path

The .dockg / .diarykg directory holding the store.

required

Returns:

Type Description
Path | None

<store_dir>/vectors.sqlite, or None when it is not built.

Source code in src/gutenberg_kg/vector_store.py
19
20
21
22
23
24
25
26
def resolve_vectors_path(store_dir: Path) -> Path | None:
    """Return the sqlite-vec store in a KG store directory, if it exists.

    :param store_dir: The ``.dockg`` / ``.diarykg`` directory holding the store.
    :return: ``<store_dir>/vectors.sqlite``, or ``None`` when it is not built.
    """
    vectors = store_dir / "vectors.sqlite"
    return vectors if vectors.exists() else None