Download autonomous_learning.py from noah33565/NoahsKI: direct link, hf CLI and curl.
- Browser
- Download file 27.3 kB
-
https://huggingface.co/spaces/noah33565/NoahsKI/resolve/main/autonomous_learning.py
- Command line
-
hf download hf://spaces/noah33565/NoahsKI/autonomous_learning.py
-
curl -L -o autonomous_learning.py https://huggingface.co/spaces/noah33565/NoahsKI/resolve/main/autonomous_learning.py
27.3 kB
| """ | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β β | |
| β AUTONOMOUS LEARNING MODULE for NoahsKI β | |
| β Production-Ready Plugin v1.0 β | |
| β β | |
| β Dieses Modul erweitert NoahsKI um: β | |
| β β Autonomes Internet-Learning (Background) β | |
| β β FAISS Vector Database + RAG β | |
| β β Smart Web-Crawling (robots.txt compliant) β | |
| β β Content Quality Filtering β | |
| β β Self-Optimization Engine β | |
| β β Resource-Aware Learning β | |
| β β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| USAGE: | |
| from autonomous_learning import AutonomousLearningSystem | |
| # Initialize | |
| auto_learn = AutonomousLearningSystem() | |
| auto_learn.start() | |
| # Use RAG in responses | |
| enhanced_response = auto_learn.enhance_response(user_query, base_response) | |
| """ | |
| import os | |
| import json | |
| import time | |
| import random | |
| import hashlib | |
| import threading | |
| import logging | |
| import re | |
| from typing import Dict, List, Tuple, Optional | |
| from dataclasses import dataclass, field | |
| from pathlib import Path | |
| from datetime import datetime | |
| from urllib.parse import urlparse, urljoin | |
| from urllib.robotparser import RobotFileParser | |
| import numpy as np | |
| # Optional imports with fallbacks | |
| try: | |
| import requests | |
| REQUESTS_AVAILABLE = True | |
| except ImportError: | |
| REQUESTS_AVAILABLE = False | |
| try: | |
| from bs4 import BeautifulSoup | |
| BS4_AVAILABLE = True | |
| except ImportError: | |
| BS4_AVAILABLE = False | |
| try: | |
| import psutil | |
| PSUTIL_AVAILABLE = True | |
| except ImportError: | |
| PSUTIL_AVAILABLE = False | |
| try: | |
| import faiss | |
| FAISS_AVAILABLE = True | |
| except ImportError: | |
| FAISS_AVAILABLE = False | |
| try: | |
| from sentence_transformers import SentenceTransformer | |
| SENTENCE_TRANSFORMERS_AVAILABLE = True | |
| except ImportError: | |
| SENTENCE_TRANSFORMERS_AVAILABLE = False | |
| logger = logging.getLogger(__name__) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # CONFIGURATION | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class AutoLearningConfig: | |
| """Configuration for autonomous learning""" | |
| # Resource Thresholds | |
| MAX_RAM_PERCENT = 75.0 | |
| MAX_CPU_PERCENT = 70.0 | |
| IDLE_TIME_SECONDS = 300 # 5 minutes | |
| # Learning Parameters | |
| MIN_CONTENT_LENGTH = 200 | |
| MAX_CONTENT_LENGTH = 50000 | |
| MIN_QUALITY_SCORE = 0.6 | |
| CRAWL_DEPTH = 2 | |
| CRAWL_DELAY = 1.0 | |
| MAX_PAGES_PER_SESSION = 50 | |
| # Knowledge Management | |
| DATA_DIR = Path('noahski_data/autonomous_learning') | |
| KNOWLEDGE_JSON = DATA_DIR / 'knowledge_base.json' | |
| MAX_ENTRIES = 10000 | |
| DECAY_DAYS = 90 | |
| # Vector Search | |
| EMBEDDING_DIM = 384 | |
| TOP_K = 5 | |
| SIMILARITY_THRESHOLD = 0.65 | |
| # Content Filtering | |
| BLACKLIST = [ | |
| 'porn', 'xxx', 'adult', 'casino', 'gambling', 'viagra', | |
| 'hack', 'crack', 'pirate', 'illegal', 'weapon', 'hate' | |
| ] | |
| # Quality Domains | |
| QUALITY_DOMAINS = [ | |
| 'wikipedia.org', 'github.com', 'stackoverflow.com', | |
| 'python.org', 'pytorch.org', 'tensorflow.org', | |
| 'medium.com', 'towardsdatascience.com' | |
| ] | |
| # Seed URLs | |
| SEED_URLS = [ | |
| 'https://en.wikipedia.org/wiki/Artificial_intelligence', | |
| 'https://en.wikipedia.org/wiki/Machine_learning', | |
| 'https://github.com/trending/python', | |
| 'https://stackoverflow.com/questions/tagged/python' | |
| ] | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # DATA CLASSES | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class KnowledgeEntry: | |
| """Single knowledge entry""" | |
| id: str | |
| content: str | |
| source: str | |
| title: str | |
| timestamp: float | |
| embedding: Optional[np.ndarray] = None | |
| confidence: float = 0.5 | |
| access_count: int = 0 | |
| last_accessed: float = field(default_factory=time.time) | |
| quality_score: float = 0.0 | |
| domain: str = "" | |
| def to_dict(self) -> Dict: | |
| return { | |
| 'id': self.id, | |
| 'content': self.content, | |
| 'source': self.source, | |
| 'title': self.title, | |
| 'timestamp': self.timestamp, | |
| 'confidence': self.confidence, | |
| 'access_count': self.access_count, | |
| 'last_accessed': self.last_accessed, | |
| 'quality_score': self.quality_score, | |
| 'domain': self.domain | |
| } | |
| def from_dict(data: Dict) -> 'KnowledgeEntry': | |
| return KnowledgeEntry( | |
| id=data['id'], | |
| content=data['content'], | |
| source=data['source'], | |
| title=data.get('title', ''), | |
| timestamp=data['timestamp'], | |
| confidence=data.get('confidence', 0.5), | |
| access_count=data.get('access_count', 0), | |
| last_accessed=data.get('last_accessed', time.time()), | |
| quality_score=data.get('quality_score', 0.0), | |
| domain=data.get('domain', '') | |
| ) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # HELPER CLASSES | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class ResourceMonitor: | |
| """Monitor system resources""" | |
| def __init__(self): | |
| self.available = PSUTIL_AVAILABLE | |
| def get_ram_usage(self) -> float: | |
| if not self.available: | |
| return 50.0 | |
| try: | |
| return psutil.virtual_memory().percent | |
| except: | |
| return 50.0 | |
| def get_cpu_usage(self) -> float: | |
| if not self.available: | |
| return 50.0 | |
| try: | |
| return psutil.cpu_percent(interval=0.1) | |
| except: | |
| return 50.0 | |
| def can_learn(self) -> bool: | |
| ram = self.get_ram_usage() | |
| cpu = self.get_cpu_usage() | |
| return ram < AutoLearningConfig.MAX_RAM_PERCENT and cpu < AutoLearningConfig.MAX_CPU_PERCENT | |
| class ContentFilter: | |
| """Filter content quality""" | |
| def __init__(self): | |
| self.blacklist_pattern = re.compile( | |
| '|'.join(re.escape(word) for word in AutoLearningConfig.BLACKLIST), | |
| re.IGNORECASE | |
| ) | |
| self.seen_hashes = set() | |
| def is_toxic(self, text: str) -> bool: | |
| return bool(self.blacklist_pattern.search(text)) | |
| def is_duplicate(self, text: str) -> bool: | |
| content_hash = hashlib.md5(text.encode()).hexdigest() | |
| if content_hash in self.seen_hashes: | |
| return True | |
| self.seen_hashes.add(content_hash) | |
| return False | |
| def calculate_quality(self, text: str, domain: str) -> float: | |
| score = 0.5 | |
| if len(text) > 1000: | |
| score += 0.1 | |
| sentences = text.count('.') + text.count('!') + text.count('?') | |
| if sentences > 3: | |
| score += 0.1 | |
| if any(qd in domain for qd in AutoLearningConfig.QUALITY_DOMAINS): | |
| score += 0.2 | |
| return max(0.0, min(1.0, score)) | |
| def filter_content(self, text: str, domain: str) -> Tuple[bool, float]: | |
| if len(text) < AutoLearningConfig.MIN_CONTENT_LENGTH: | |
| return False, 0.0 | |
| if len(text) > AutoLearningConfig.MAX_CONTENT_LENGTH: | |
| text = text[:AutoLearningConfig.MAX_CONTENT_LENGTH] | |
| if self.is_toxic(text): | |
| return False, 0.0 | |
| if self.is_duplicate(text): | |
| return False, 0.0 | |
| quality = self.calculate_quality(text, domain) | |
| if quality < AutoLearningConfig.MIN_QUALITY_SCORE: | |
| return False, quality | |
| return True, quality | |
| class WebCrawler: | |
| """Web crawler with robots.txt compliance""" | |
| def __init__(self): | |
| if not REQUESTS_AVAILABLE or not BS4_AVAILABLE: | |
| logger.warning("Web crawling disabled: missing dependencies") | |
| self.enabled = False | |
| else: | |
| self.enabled = True | |
| self.robots_cache = {} | |
| self.visited_urls = set() | |
| self.user_agent = 'NoahsKI-Learning-Bot/1.0' | |
| def can_fetch(self, url: str) -> bool: | |
| if not self.enabled: | |
| return False | |
| try: | |
| parsed = urlparse(url) | |
| base_url = f"{parsed.scheme}://{parsed.netloc}" | |
| if base_url not in self.robots_cache: | |
| rp = RobotFileParser() | |
| robots_url = urljoin(base_url, '/robots.txt') | |
| try: | |
| rp.set_url(robots_url) | |
| rp.read() | |
| except: | |
| rp.allow_all = True | |
| self.robots_cache[base_url] = rp | |
| return self.robots_cache[base_url].can_fetch(self.user_agent, url) | |
| except: | |
| return True | |
| def fetch_page(self, url: str) -> Optional[Tuple[str, str, str]]: | |
| if not self.enabled or url in self.visited_urls: | |
| return None | |
| if not self.can_fetch(url): | |
| return None | |
| try: | |
| headers = {'User-Agent': self.user_agent} | |
| response = requests.get(url, headers=headers, timeout=10) | |
| if response.status_code != 200: | |
| return None | |
| html = response.text | |
| soup = BeautifulSoup(html, 'html.parser') | |
| # Remove scripts and styles | |
| for script in soup(["script", "style"]): | |
| script.decompose() | |
| title = soup.title.string if soup.title else "" | |
| text = soup.get_text(separator=' ', strip=True) | |
| text = re.sub(r'\s+', ' ', text).strip() | |
| self.visited_urls.add(url) | |
| time.sleep(AutoLearningConfig.CRAWL_DELAY) | |
| return html, text, title | |
| except Exception as e: | |
| logger.debug(f"Failed to fetch {url}: {e}") | |
| return None | |
| def crawl(self, seed_url: str, max_pages: int = 10) -> List[Tuple[str, str, str, str]]: | |
| results = [] | |
| queue = [(seed_url, 0)] | |
| while queue and len(results) < max_pages: | |
| url, depth = queue.pop(0) | |
| if depth > AutoLearningConfig.CRAWL_DEPTH: | |
| continue | |
| page_data = self.fetch_page(url) | |
| if not page_data: | |
| continue | |
| html, text, title = page_data | |
| domain = urlparse(url).netloc | |
| if text: | |
| results.append((url, text, title, domain)) | |
| # Extract links for next level | |
| if depth < AutoLearningConfig.CRAWL_DEPTH: | |
| try: | |
| soup = BeautifulSoup(html, 'html.parser') | |
| for a_tag in soup.find_all('a', href=True)[:5]: | |
| link = urljoin(url, a_tag['href']) | |
| if link.startswith(('http://', 'https://')) and link not in self.visited_urls: | |
| queue.append((link, depth + 1)) | |
| except: | |
| pass | |
| return results | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # VECTOR DATABASE | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class VectorDatabase: | |
| """FAISS-based vector database""" | |
| def __init__(self): | |
| self.entries: List[KnowledgeEntry] = [] | |
| self.lock = threading.Lock() | |
| self.embedder = None | |
| self.index = None | |
| self.use_faiss = False | |
| # Initialize embedder | |
| if SENTENCE_TRANSFORMERS_AVAILABLE: | |
| try: | |
| self.embedder = SentenceTransformer('all-MiniLM-L6-v2') | |
| logger.info("β Loaded sentence-transformers embedder") | |
| except Exception as e: | |
| logger.warning(f"Failed to load embedder: {e}") | |
| # Initialize FAISS | |
| if FAISS_AVAILABLE and self.embedder: | |
| self.index = faiss.IndexFlatL2(AutoLearningConfig.EMBEDDING_DIM) | |
| self.use_faiss = True | |
| logger.info("β FAISS enabled") | |
| else: | |
| logger.info("βΉ Using fallback search") | |
| self._load() | |
| def _create_embedding(self, text: str) -> np.ndarray: | |
| if self.embedder: | |
| try: | |
| return self.embedder.encode(text, convert_to_numpy=True).astype('float32') | |
| except: | |
| pass | |
| # Fallback: hash-based | |
| text_hash = hashlib.sha256(text.encode()).digest() | |
| embedding = np.frombuffer(text_hash, dtype=np.uint8)[:AutoLearningConfig.EMBEDDING_DIM] | |
| return embedding.astype('float32') / 255.0 | |
| def add(self, entry: KnowledgeEntry): | |
| with self.lock: | |
| if entry.embedding is None: | |
| entry.embedding = self._create_embedding(entry.content) | |
| self.entries.append(entry) | |
| if self.use_faiss: | |
| self.index.add(entry.embedding.reshape(1, -1)) | |
| if len(self.entries) > AutoLearningConfig.MAX_ENTRIES: | |
| self._cleanup() | |
| def search(self, query: str, top_k: int = None) -> List[Tuple[KnowledgeEntry, float]]: | |
| if top_k is None: | |
| top_k = AutoLearningConfig.TOP_K | |
| with self.lock: | |
| if not self.entries: | |
| return [] | |
| query_emb = self._create_embedding(query) | |
| if self.use_faiss: | |
| distances, indices = self.index.search( | |
| query_emb.reshape(1, -1), | |
| min(top_k, len(self.entries)) | |
| ) | |
| results = [] | |
| for dist, idx in zip(distances[0], indices[0]): | |
| if idx < len(self.entries): | |
| similarity = 1.0 / (1.0 + dist) | |
| if similarity >= AutoLearningConfig.SIMILARITY_THRESHOLD: | |
| entry = self.entries[idx] | |
| entry.access_count += 1 | |
| entry.last_accessed = time.time() | |
| entry.confidence = min(1.0, entry.confidence + 0.01) | |
| results.append((entry, similarity)) | |
| return results | |
| else: | |
| # Fallback: cosine similarity | |
| results = [] | |
| for entry in self.entries: | |
| if entry.embedding is not None: | |
| similarity = np.dot(query_emb, entry.embedding) / ( | |
| np.linalg.norm(query_emb) * np.linalg.norm(entry.embedding) + 1e-8 | |
| ) | |
| if similarity >= AutoLearningConfig.SIMILARITY_THRESHOLD: | |
| entry.access_count += 1 | |
| entry.last_accessed = time.time() | |
| results.append((entry, float(similarity))) | |
| results.sort(key=lambda x: x[1], reverse=True) | |
| return results[:top_k] | |
| def _cleanup(self): | |
| """Remove old/low-quality entries""" | |
| scored = [(e, e.confidence * 0.4 + min(e.access_count/100, 0.3) + e.quality_score * 0.3) | |
| for e in self.entries] | |
| scored.sort(key=lambda x: x[1], reverse=True) | |
| keep_count = int(AutoLearningConfig.MAX_ENTRIES * 0.9) | |
| self.entries = [e for e, s in scored[:keep_count]] | |
| if self.use_faiss: | |
| self.index.reset() | |
| if self.entries: | |
| embeddings = np.vstack([e.embedding for e in self.entries]).astype('float32') | |
| self.index.add(embeddings) | |
| def _load(self): | |
| try: | |
| if AutoLearningConfig.KNOWLEDGE_JSON.exists(): | |
| with open(AutoLearningConfig.KNOWLEDGE_JSON, 'r', encoding='utf-8') as f: | |
| data = json.load(f) | |
| self.entries = [KnowledgeEntry.from_dict(e) for e in data.get('entries', [])] | |
| if self.use_faiss and self.entries: | |
| for entry in self.entries: | |
| if entry.embedding is None: | |
| entry.embedding = self._create_embedding(entry.content) | |
| embeddings = np.vstack([e.embedding for e in self.entries]).astype('float32') | |
| self.index.add(embeddings) | |
| logger.info(f"β Loaded {len(self.entries)} knowledge entries") | |
| except Exception as e: | |
| logger.error(f"Failed to load knowledge: {e}") | |
| def save(self): | |
| try: | |
| AutoLearningConfig.DATA_DIR.mkdir(parents=True, exist_ok=True) | |
| data = { | |
| 'entries': [e.to_dict() for e in self.entries], | |
| 'saved_at': time.time() | |
| } | |
| with open(AutoLearningConfig.KNOWLEDGE_JSON, 'w', encoding='utf-8') as f: | |
| json.dump(data, f, indent=2) | |
| except Exception as e: | |
| logger.error(f"Failed to save knowledge: {e}") | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # MAIN AUTONOMOUS LEARNING SYSTEM | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class AutonomousLearningSystem: | |
| """Main autonomous learning system - plug and play!""" | |
| def __init__(self): | |
| logger.info("π§ Initializing Autonomous Learning System...") | |
| self.vector_db = VectorDatabase() | |
| self.crawler = WebCrawler() | |
| self.content_filter = ContentFilter() | |
| self.resource_monitor = ResourceMonitor() | |
| self.running = False | |
| self.learning_thread = None | |
| self.monitor_thread = None | |
| self.last_user_activity = time.time() | |
| self.lock = threading.Lock() | |
| self.stats = { | |
| 'pages_crawled': 0, | |
| 'entries_added': 0, | |
| 'entries_rejected': 0, | |
| 'learning_sessions': 0 | |
| } | |
| logger.info("β Autonomous Learning System initialized") | |
| def start(self): | |
| """Start background monitor""" | |
| if self.monitor_thread is None or not self.monitor_thread.is_alive(): | |
| self.running = True | |
| self.monitor_thread = threading.Thread( | |
| target=self._monitor_loop, | |
| daemon=True, | |
| name="AutoLearningMonitor" | |
| ) | |
| self.monitor_thread.start() | |
| logger.info("β Autonomous learning monitor started") | |
| def stop(self): | |
| """Stop learning""" | |
| self.running = False | |
| if self.learning_thread: | |
| self.learning_thread.join(timeout=5.0) | |
| if self.monitor_thread: | |
| self.monitor_thread.join(timeout=5.0) | |
| self.vector_db.save() | |
| def update_user_activity(self): | |
| """Call this on every user request""" | |
| self.last_user_activity = time.time() | |
| def _should_learn(self) -> bool: | |
| if self.running and self.learning_thread and self.learning_thread.is_alive(): | |
| return False | |
| idle_time = time.time() - self.last_user_activity | |
| if idle_time < AutoLearningConfig.IDLE_TIME_SECONDS: | |
| return False | |
| return self.resource_monitor.can_learn() | |
| def _monitor_loop(self): | |
| """Background monitoring loop""" | |
| while self.running: | |
| try: | |
| if self._should_learn(): | |
| logger.info("π― Starting autonomous learning session") | |
| self._start_learning_session() | |
| time.sleep(60) # Check every minute | |
| except Exception as e: | |
| logger.error(f"Monitor error: {e}") | |
| time.sleep(60) | |
| def _start_learning_session(self): | |
| """Start a learning session""" | |
| self.learning_thread = threading.Thread( | |
| target=self._learning_loop, | |
| daemon=True, | |
| name="AutoLearning" | |
| ) | |
| self.learning_thread.start() | |
| def _learning_loop(self): | |
| """Main learning loop""" | |
| try: | |
| self.stats['learning_sessions'] += 1 | |
| seed_url = random.choice(AutoLearningConfig.SEED_URLS) | |
| logger.info(f"π Learning from: {seed_url}") | |
| pages = self.crawler.crawl(seed_url, max_pages=AutoLearningConfig.MAX_PAGES_PER_SESSION) | |
| self.stats['pages_crawled'] += len(pages) | |
| for url, text, title, domain in pages: | |
| if not self.running or not self.resource_monitor.can_learn(): | |
| break | |
| is_valid, quality = self.content_filter.filter_content(text, domain) | |
| if not is_valid: | |
| self.stats['entries_rejected'] += 1 | |
| continue | |
| entry = KnowledgeEntry( | |
| id=hashlib.md5(f"{url}{time.time()}".encode()).hexdigest(), | |
| content=text[:5000], | |
| source=url, | |
| title=title, | |
| timestamp=time.time(), | |
| quality_score=quality, | |
| domain=domain | |
| ) | |
| self.vector_db.add(entry) | |
| self.stats['entries_added'] += 1 | |
| logger.info(f"β Learned: {title[:50]}... (quality: {quality:.2f})") | |
| self.vector_db.save() | |
| logger.info(f"β Learning session complete: {len(pages)} pages processed") | |
| except Exception as e: | |
| logger.error(f"Learning error: {e}") | |
| def enhance_response(self, query: str, base_response: str = None) -> Dict: | |
| """ | |
| Enhance a response with RAG | |
| Returns: | |
| { | |
| 'enhanced_response': str, | |
| 'has_knowledge': bool, | |
| 'sources': List[Dict], | |
| 'base_response': str | |
| } | |
| """ | |
| results = self.vector_db.search(query) | |
| response = { | |
| 'base_response': base_response or "", | |
| 'has_knowledge': len(results) > 0, | |
| 'sources': [], | |
| 'enhanced_response': base_response or "" | |
| } | |
| if results: | |
| # Build source list | |
| for entry, similarity in results[:3]: | |
| response['sources'].append({ | |
| 'title': entry.title, | |
| 'domain': entry.domain, | |
| 'confidence': entry.confidence, | |
| 'similarity': similarity, | |
| 'snippet': entry.content[:200] | |
| }) | |
| # Enhance response | |
| knowledge_context = "\n\nBased on my learned knowledge:\n" | |
| for i, (entry, sim) in enumerate(results[:3], 1): | |
| knowledge_context += f"\n{i}. {entry.title} ({entry.domain})\n {entry.content[:150]}...\n" | |
| response['enhanced_response'] = (base_response or "") + knowledge_context | |
| return response | |
| def get_stats(self) -> Dict: | |
| """Get statistics""" | |
| return { | |
| **self.stats, | |
| 'knowledge_entries': len(self.vector_db.entries), | |
| 'running': self.running and self.learning_thread and self.learning_thread.is_alive(), | |
| 'idle_time': time.time() - self.last_user_activity, | |
| 'can_learn': self.resource_monitor.can_learn(), | |
| 'using_faiss': self.vector_db.use_faiss | |
| } | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # EXPORT | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| __all__ = ['AutonomousLearningSystem', 'AutoLearningConfig'] | |
| if __name__ == '__main__': | |
| # Test mode | |
| logging.basicConfig(level=logging.INFO) | |
| system = AutonomousLearningSystem() | |
| system.start() | |
| print("Autonomous Learning System running in test mode") | |
| print("Press Ctrl+C to stop") | |
| try: | |
| while True: | |
| time.sleep(1) | |
| except KeyboardInterrupt: | |
| print("\nStopping...") | |
| system.stop() | |