Spaces:
Runtime error
Runtime error
File size: 1,954 Bytes
58ab44f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | """
packages/memory/__init__.py
Memory pipeline public API.
Exports:
Embedder β sentence-transformers batch embed, 384-dim
ZillizStore β async upsert/search via AsyncMilvusClient
RaptorTree β RAPTOR tree build + query (Groq summariser, no OpenAI)
MemoryWorker β Redis mem_buffer flush-to-Zilliz background loop
Pre-registered gut-feel bugs (other files that could break this one):
W1 [HIGH] worker.py flush fires while raptor.py build_tree() running on same
user_id β partial tree written to Zilliz mid-build β corrupt nodes.
Fix: asyncio.Lock per user_id before tree build.
W2 [HIGH] embedder.py loads model at import time β HF Space cold start adds
~8s. If main.py lifespan timeout is tight, Space may return 503
before Brain is ready. Fix: lazy-load model inside Embedder.__init__
only when first encode() call arrives.
W3 [MED] Zilliz free-tier has 1M vector cap per collection. If mem_buffer
flush writes leaf + summary nodes without dedup, cap hit fast.
Fix: upsert (not insert) keyed on chunk_id hash.
W4 [MED] RAPTOR summariser calls llm_router β pool key exhausted mid-build
β AllKeysExhaustedError raised inside tree build β partial tree
never cleaned up. Fix: catch in raptor.py, return partial tree.
W5 [LOW] sentence-transformers model download on first run (~90MB). HF Space
build cache doesn't persist between deploys unless /data mount used.
Fix: add all-MiniLM-L6-v2 to requirements.txt (triggers cache warm
during build, not at runtime).
"""
from .embedder import Embedder
from .tier2_zilliz import ZillizStore
from .raptor import RaptorTree
from .worker import MemoryWorker
__all__ = ["Embedder", "ZillizStore", "RaptorTree", "MemoryWorker"]
|