Close local release-quality gaps and reconcile workplan status
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0e332-3365-77c0-8491-084e9ea33ac1
This commit is contained in:
parent
37436bb562
commit
7cd633986e
56 changed files with 462 additions and 237 deletions
|
|
@ -8,7 +8,12 @@ automatically invalidated when entity content changes.
|
|||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
class _CacheEntry(TypedDict):
|
||||
digest: str
|
||||
vector: list[float]
|
||||
|
||||
|
||||
class EmbeddingCache:
|
||||
|
|
@ -24,12 +29,12 @@ class EmbeddingCache:
|
|||
|
||||
def __init__(self, cache_dir: Path):
|
||||
self._path = cache_dir / "embeddings.json"
|
||||
self._data: dict[str, dict] = {}
|
||||
self._data: dict[str, _CacheEntry] = {}
|
||||
self._hits = 0
|
||||
self._misses = 0
|
||||
self._load()
|
||||
|
||||
def get(self, slug: str, content_digest: str) -> Optional[list[float]]:
|
||||
def get(self, slug: str, content_digest: str) -> list[float] | None:
|
||||
"""Return the cached vector if *content_digest* matches, else ``None``."""
|
||||
entry = self._data.get(slug)
|
||||
if entry is not None and entry.get("digest") == content_digest:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue