Download backend/scripts/flush_learning_queue.py from Paritosh-Sovereign/Friday-Subconscious: direct link, hf CLI and curl.
- Browser
- Download file 2.1 kB
-
https://huggingface.co/spaces/Paritosh-Sovereign/Friday-Subconscious/resolve/main/backend/scripts/flush_learning_queue.py
- Command line
-
hf download hf://spaces/Paritosh-Sovereign/Friday-Subconscious/backend/scripts/flush_learning_queue.py
-
curl -L -o flush_learning_queue.py https://huggingface.co/spaces/Paritosh-Sovereign/Friday-Subconscious/resolve/main/backend/scripts/flush_learning_queue.py
2.1 kB
| """ | |
| Project Friday — Master Learning Queue Flush | |
| Bridges existing ConversationMemory patterns into the LearningTarget queue for high-velocity maturation. | |
| """ | |
| import sys | |
| import os | |
| from pathlib import Path | |
| import logging | |
| # Add backend to path | |
| sys.path.append(os.path.join(os.getcwd(), "backend")) | |
| from app.core import database | |
| from app.models.entities import ConversationMemory | |
| from app.services import holocron | |
| logging.basicConfig(level=logging.INFO, format="%(asctime)s | FLUSH | %(message)s") | |
| logger = logging.getLogger("friday.flush") | |
| def flush_memory_to_queue(): | |
| """Converts 310,000+ memory patterns into formal learning targets.""" | |
| logger.info("Initializing Master Queue Sync...") | |
| with database.SessionLocal() as db: | |
| # 1. Fetch distinct topics from memory that aren't already targets | |
| logger.info("Scanning for unqueued mandates in memory store...") | |
| # In this context, 'entities' holds the unique reference ID like MANAGEMENT_MASTER_X | |
| # We'll use the memory ID ranges or categories | |
| # Map categories | |
| for category, target_type in [("ManagementSkill", "management"), ("PersonalityExample", "personality")]: | |
| logger.info(f"Processing category: {category} -> {target_type}") | |
| # Use chunks to avoid memory issues | |
| batch_size = 5000 | |
| offset = 0 | |
| while True: | |
| mem_items = db.query(ConversationMemory.entities)\ | |
| .filter_by(topic=category)\ | |
| .offset(offset).limit(batch_size).all() | |
| if not mem_items: break | |
| topics = [m.entities for m in mem_items] | |
| holocron.add_learning_targets(topics, category=target_type) | |
| offset += batch_size | |
| logger.info(f"Synchronized {offset} patterns for {target_type}...") | |
| logger.info("✓ Master Learning Queue Flush Complete.") | |
| if __name__ == "__main__": | |
| flush_memory_to_queue() | |