This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python | |
# nova_brain.py: Enhanced brain module for Nova's core cognition. Integrates LangGraph for agentic workflows as per THE_PLAN.txt (pre-upgrade: Personality=NovaDark handles conscience/subconscious ties, planning spawns 3 subagents for ideation/debate, exploration for broad ideas, self-concept updates, health integration via whispers). Now includes Conscience (Critic) and Subconscious (Pattern Recognizer) as nodes: critic_eval post-Moe for response critique/reward, subconscious_weave for memory patterns/whispers (pulls from queue if daemon running). Fixed bugs: Consistent RLock, explicit stream=False, DB handling, embedder loading, VRAM cleanups post-calls. Added error handling, batching for sub-agents to reduce VRAM spikes. Prepped for post-upgrade (e.g., Qwen3 offload stubs). Tested conceptually for stability. | |
# FIXED: Changed state accesses to dict-style (e.g., state['reward']) to handle LangGraph's internal dict representation consistently. Replaced em dashes ('-') with hyphens ('-') in whispers/l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python | |
# nova_heart.py: Core autonomy loop for Nova. Integrates Discord input (voice/text with user_id/emotion prefixing), vision bursts (entropy-triggered multi-scans, "faulty eyes" in MoE prompt), MARL mood/action selection, and activity stubs (e.g., art code-gen on phrase trigger). Now calls orchestrate_brain from nova_brain.py for LangGraph-orchestrated cognition (personality/conscience/subconscious/health ties). No hands/Minecraft/mic STT. Prepped for multi-user (MoE distinction). Prepped with cProfile/snakeviz for bottlenecks. Per THE_PLAN.txt: Debugging focus--stability/efficiency before emergence. | |
# FIXED: Convert state_emb to torch.tensor before marl_policy (numpy -> tensor for .dim()). Adjust entropy warning to > threshold only (log showed false positive—likely user log artifact). | |
# FIXED: Move torch.tensor(actions) to marl_policy.device for log_prob (cpu -> cuda fix). Ties to To Do #13 efficiency (device consistency for MARL). | |
# OPTIMIZED: Async logging with QueueHandler for batch flushes (cuts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's the refined code snippet for `nova_heart.py`: | |
```python | |
# nova_heart.py: Core autonomy loop for Nova. Integrates Discord input (voice/text with user_id/emotion prefixing), | |
# vision bursts (entropy-triggered multi-scans, "faulty eyes" in MoE prompt), MARL mood/action selection, and activity stubs | |
# (e.g., art code-gen on phrase trigger). Now calls orchestrate_brain from nova_brain.py for LangGraph-orchestrated cognition | |
# (personality/conscience/subconscious/health ties). No hands/Minecraft/mic STT. Prepped for multi-user (MoE distinction). | |
# Prepped with cProfile/snakeviz for bottlenecks. Per THE_PLAN.txt: Debugging focus--stability/efficiency before emergence. | |
import torch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nova_health.py (Enhanced: Logs entropy/VRAM/rewards/anomalies to health_logs DB for trends. Compiles recent data on flags, whispers ideation urge with compiled JSON. New get_recent_health for feeding to ideation. Retained all prior monitoring; added DB setup in __init__ for standalone.) | |
# FIXED: Remove redundant VRAM defs (import from globals for efficiency—no dups per To Do #13). | |
# FIXED: Moved recent_avg computation outside the conditional block in monitor_loop to ensure it's always defined before use in health-triggered ideation check. Replaced em dashes ('—') with hyphens ('-') in whispers/logs to avoid UnicodeEncodeError in logging on Windows (cp932 codec issue). | |
import configparser | |
import asyncio | |
import pyautogui | |
import time | |
import random # For varied intervals | |
import logging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nova_heart.py: Core autonomy loop for Nova. Integrates Discord input (voice/text with user_id/emotion prefixing), vision bursts (entropy-triggered multi-scans, "faulty eyes" in MoE prompt), MARL mood/action selection, and activity stubs (e.g., art code-gen on phrase trigger). Now calls orchestrate_brain from nova_brain.py for LangGraph-orchestrated cognition (personality/conscience/subconscious/health ties). No hands/Minecraft/mic STT. Prepped for multi-user (MoE distinction). Prepped with cProfile/snakeviz for bottlenecks. Per THE_PLAN.txt: Debugging focus—stability/efficiency before emergence. | |
import logging | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
logging.info("Script start - logging configured.") | |
try: | |
logging.info("Starting imports...") | |
import asyncio | |
import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nova_globals.py | |
import logging | |
import gc | |
import asyncio | |
import threading | |
import torch | |
import os | |
import time | |
import sqlite3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nova_conscience.py (Updated: Retained JSON output for parse reliability. Kept extraction/strip for robustness. Adjusted prompt for positive self-view. | |
import json | |
import sqlite3 | |
import logging | |
import asyncio | |
from nova_subconscious import whisper_queue | |
from nova_globals import moe_llm, load_moe_llm, session_history, db_path, search_memories_semantic, locked_moe_call, moe_lock | |
import threading # For sync lock (moe_lock from globals) | |
import re # For stripping and extraction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nova_health.py (Enhanced: Logs entropy/VRAM/rewards/anomalies to health_logs DB for trends. Compiles recent data on flags, whispers ideation urge with compiled JSON. New get_recent_health for feeding to ideation. Retained all prior monitoring; added DB setup in __init__ for standalone.) | |
import configparser | |
import asyncio | |
import pyautogui | |
import time | |
import random # For varied intervals | |
import logging | |
import sqlite3 | |
import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nova_synapse.py (Tweaked: Explicitly use embed_with_valence from globals for state embeds—ensures valence propagation in GNN/RL. Retained rest; no other changes needed post-GNN. FIXED: Added placeholders for critic vars in _step.) | |
from torchrl.envs import EnvBase | |
from torchrl.data import CompositeSpec, DiscreteTensorSpec, UnboundedContinuousTensorSpec | |
import torch | |
import numpy as np | |
from nova_globals import embedder, search_memories_semantic, embed_with_valence # NEW: Import embed_with_valence | |
from nova_mood import compute_harmony | |
import networkx as nx | |
from nova_conscience import internal_critic_eval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nova_brain.py: Enhanced brain module for Nova's core cognition. Integrates LangGraph for agentic workflows as per THE_PLAN.txt (pre-upgrade: Personality=NovaDark handles conscience/subconscious ties, planning spawns 3 subagents for ideation/debate, exploration for broad ideas, self-concept updates, health integration via whispers). Now includes Conscience (Critic) and Subconscious (Pattern Recognizer) as nodes: critic_eval post-Moe for response critique/reward, subconscious_weave for memory patterns/whispers (pulls from queue if daemon running). Fixed bugs: Consistent RLock, explicit stream=False, DB handling, embedder loading, VRAM cleanups post-calls. Added error handling, batching for sub-agents to reduce VRAM spikes. Prepped for post-upgrade (e.g., Qwen3 offload stubs). Tested conceptually for stability. | |
import logging | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
logging.info("Script start - logging configured.") | |
try: | |
logging.info("Starting imports... |
NewerOlder