(self, text: str)
| 364 | return self.cache_dir / f"{self._cache_key(text)}.json" |
| 365 | |
| 366 | def _load_cached(self, text: str) -> Optional[List[float]]: |
| 367 | cache_path = self._cache_path(text) |
| 368 | if not cache_path.exists(): |
| 369 | return None |
| 370 | |
| 371 | try: |
| 372 | data = json.loads(cache_path.read_text(encoding="utf-8")) |
| 373 | except (json.JSONDecodeError, OSError): |
| 374 | return None |
| 375 | |
| 376 | embedding = data.get("embedding") |
| 377 | if not isinstance(embedding, list): |
| 378 | return None |
| 379 | return embedding |
| 380 | |
| 381 | def _save_cached(self, text: str, embedding: List[float]) -> None: |
| 382 | cache_path = self._cache_path(text) |
no test coverage detected