2026-06-12 17:00:01 +02:00
|
|
|
"""Gating rule: may this document be served from / written to the embedding cache?"""
|
2026-06-12 16:48:10 +02:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
|
2026-06-12 17:00:01 +02:00
|
|
|
def is_embedding_cacheable(
|
2026-06-12 16:48:10 +02:00
|
|
|
*,
|
|
|
|
|
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)
|