File size: 1,731 Bytes
7c8b011 | 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 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import asyncio
import json
import os
from mnemocore.core.engine import HAIMEngine
from mnemocore.core.config import get_config
from mnemocore.core.container import build_container
from mnemocore.core.tier_manager import TierManager
async def sync_qdrant():
config = get_config()
container = build_container(config)
# Initialize TierManager with Qdrant
tier_manager = TierManager(config=config, qdrant_store=container.qdrant_store)
engine = HAIMEngine(
config=config,
tier_manager=tier_manager,
working_memory=container.working_memory,
episodic_store=container.episodic_store,
semantic_store=container.semantic_store
)
await engine.initialize()
print(f"Engine initialized. Memories in HOT: {len(engine.tier_manager.hot)}")
# Force sync from memory.jsonl if HOT is empty
if len(engine.tier_manager.hot) == 0:
print("HOT is empty, reloading from legacy log...")
await engine._load_legacy_if_needed()
print(f"Memories after reload: {len(engine.tier_manager.hot)}")
# Consolidation will move them to WARM (Qdrant)
# But we can also just call _save_to_warm manually for all nodes
print("Syncing nodes to Qdrant...")
count = 0
for node_id, node in list(engine.tier_manager.hot.items()):
await engine.tier_manager._save_to_warm(node)
count += 1
if count % 100 == 0:
print(f"Synced {count} nodes...")
print(f"Total synced: {count}")
await engine.close()
if __name__ == "__main__":
import sys
sys.path.append(os.path.join(os.getcwd(), "src"))
asyncio.run(sync_qdrant())
|