Skip to content

Commit 1aa2723

Browse files
committed
fix(cache): guard semantic detector initialization
1 parent 539c5cc commit 1aa2723

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

headroom/cache/dynamic_detector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,14 +770,16 @@ def detect(
770770
# Encode all sentences
771771
if not sentences:
772772
return [], None
773+
if self._model is None or self._exemplar_embeddings is None:
774+
return [], self._load_error or "semantic detector is not initialized"
773775

774776
try:
775777
import numpy as np
776778
except ImportError:
777779
return [], "numpy not installed. Install with: pip install numpy"
778780

779781
sentence_texts = [s[0] for s in sentences]
780-
sentence_embeddings = self._model.encode( # type: ignore[union-attr]
782+
sentence_embeddings = self._model.encode(
781783
sentence_texts,
782784
convert_to_numpy=True,
783785
)

0 commit comments

Comments
 (0)