MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _load_cached

Method _load_cached

skills/embedding/scripts/embed.py:366–379  ·  view source on GitHub ↗
(self, text: str)

Source from the content-addressed store, hash-verified

364 def _normalize_text(self, text: str) -> str:
365 normalized = re.sub(r"\s+", " ", str(text or "")).strip()
366 return normalized[:8000]
367
368 def _cache_key(self, text: str) -> str:
369 payload = f"{self.descriptor}:{text}"
370 return hashlib.sha256(payload.encode("utf-8")).hexdigest()
371
372 def _cache_path(self, text: str) -> Path:
373 return self.cache_dir / f"{self._cache_key(text)}.json"
374
375 def _load_cached(self, text: str) -> Optional[List[float]]:
376 cache_path = self._cache_path(text)
377 if not cache_path.exists():
378 return None
379
380 try:
381 data = json.loads(cache_path.read_text(encoding="utf-8"))
382 except (json.JSONDecodeError, OSError):

Callers 2

embed_textMethod · 0.95
embed_batchMethod · 0.95

Calls 2

_cache_pathMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected