SurfSense/surfsense_backend/app/indexing_pipeline/cache/eligibility.py

21 lines
612 B
Python

"""Gating rule: may this document be served from / written to the index cache?"""
from __future__ import annotations
def is_index_cacheable(
*,
cache_enabled: bool,
embedding_model: str | None,
embedding_dim: int | None,
) -> bool:
"""Cache only when a concrete embedding model and dimension are configured.
Without a model there is nothing to key against, and without a dimension the
blob's integrity guard cannot run -- both bypass the cache.
"""
if not cache_enabled:
return False
if not embedding_model:
return False
return bool(embedding_dim)