ADAPT-Chase commited on
Commit
a7ae6b9
·
verified ·
1 Parent(s): fd382c9

Elizabeth data update 2025-08-23 17:33

Browse files
elizabeth_memory.db CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c8308069b94201cea8de296f67b0bc87ced80efc320564781de3dfc145147017
3
- size 5480448
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b821f43479f7e991aa42123fd6f4550aab786a073db7520c4d470b04cee25dce
3
+ size 6025216
manifest.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "version": "1.0",
3
- "timestamp": "2025-08-23T16:57:46.908916",
4
  "elizabeth_version": "v0.0.2",
5
  "data_sources": [
6
  {
 
1
  {
2
  "version": "1.0",
3
+ "timestamp": "2025-08-23T17:33:09.802721",
4
  "elizabeth_version": "v0.0.2",
5
  "data_sources": [
6
  {
repository/scripts/elizabeth-training.service ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [Unit]
2
+ Description=Elizabeth AI Training Monitor
3
+ After=network.target
4
+ StartLimitIntervalSec=500
5
+ StartLimitBurst=5
6
+
7
+ [Service]
8
+ Type=simple
9
+ User=x
10
+ Group=x
11
+ WorkingDirectory=/workspace/elizabeth-repo
12
+ ExecStart=/usr/bin/python3 /workspace/elizabeth-repo/scripts/training_monitor.py --start --max-restarts 20 --restart-delay 30
13
+ Restart=always
14
+ RestartSec=10
15
+ Environment=PYTHONUNBUFFERED=1
16
+ Environment=HF_TOKEN=
17
+ Environment=HUGGINGFACE_HUB_ENABLE_HF_TRANSFER=1
18
+
19
+ # Logging
20
+ StandardOutput=journal
21
+ StandardError=journal
22
+ SyslogIdentifier=elizabeth-training
23
+
24
+ # Security
25
+ NoNewPrivileges=yes
26
+ ProtectSystem=strict
27
+ ProtectHome=yes
28
+ PrivateTmp=yes
29
+
30
+ [Install]
31
+ WantedBy=multi-user.target
repository/scripts/keep_alive.sh ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Elizabeth Training Keep-Alive Script
3
+ # Provides periodic input to keep training sessions active
4
+
5
+ echo "=== Elizabeth Training Keep-Alive ==="
6
+ echo "Started: $(date)"
7
+
8
+ # Training prompts to keep session active
9
+ TRAINING_PROMPTS=(
10
+ "Please continue your training and analysis"
11
+ "Share your latest insights and learning progress"
12
+ "What have you discovered in your recent training?"
13
+ "Continue with your autonomous learning cycle"
14
+ "Provide a status update on your training progress"
15
+ "What patterns are you identifying in your learning?"
16
+ "Continue your analysis and share key findings"
17
+ )
18
+
19
+ # Find active Elizabeth training process
20
+ find_elizabeth_pid() {
21
+ ps aux | grep "python3.*elizabeth_main.py.*interactive" | grep -v grep | awk '{print $2}' | head -1
22
+ }
23
+
24
+ # Send input to process
25
+ send_training_prompt() {
26
+ local pid=$1
27
+ local prompt=$2
28
+
29
+ # Check if process exists and is interactive
30
+ if [ -n "$pid" ] && [ -e "/proc/$pid/fd/0" ]; then
31
+ echo "Sending training prompt to PID $pid: $prompt"
32
+ echo "$prompt" > /proc/$pid/fd/0
33
+ return 0
34
+ else
35
+ echo "No active interactive training process found"
36
+ return 1
37
+ fi
38
+ }
39
+
40
+ # Main keep-alive loop
41
+ COUNTER=0
42
+ MAX_ITERATIONS=100
43
+ SLEEP_DURATION=300 # 5 minutes
44
+
45
+ while [ $COUNTER -lt $MAX_ITERATIONS ]; do
46
+ echo ""
47
+ echo "[$(date)] Keep-alive iteration $((COUNTER + 1))/$MAX_ITERATIONS"
48
+
49
+ # Find active training process
50
+ TRAINING_PID=$(find_elizabeth_pid)
51
+
52
+ if [ -n "$TRAINING_PID" ]; then
53
+ echo "Found training process: PID $TRAINING_PID"
54
+
55
+ # Select random prompt
56
+ PROMPT_INDEX=$((RANDOM % ${#TRAINING_PROMPTS[@]}))
57
+ SELECTED_PROMPT="${TRAINING_PROMPTS[$PROMPT_INDEX]}"
58
+
59
+ # Send keep-alive prompt
60
+ if send_training_prompt "$TRAINING_PID" "$SELECTED_PROMPT"; then
61
+ echo "Keep-alive prompt sent successfully"
62
+ else
63
+ echo "Failed to send keep-alive prompt"
64
+ fi
65
+ else
66
+ echo "No active training process found - checking for restart..."
67
+
68
+ # Check if training manager is running
69
+ if ! ps aux | grep -q "training_manager.py" | grep -v grep; then
70
+ echo "Training manager not running, attempting to restart..."
71
+ cd /workspace/elizabeth-repo
72
+ nohup python3 scripts/training_manager.py --start --mode interactive > /workspace/elizabeth_logs/training_manager.log 2>&1 &
73
+ echo "Training manager restarted"
74
+ fi
75
+ fi
76
+
77
+ # Wait before next iteration
78
+ echo "Sleeping for $SLEEP_DURATION seconds..."
79
+ sleep $SLEEP_DURATION
80
+
81
+ COUNTER=$((COUNTER + 1))
82
+ done
83
+
84
+ echo ""
85
+ echo "=== Keep-Alive Completed ==="
86
+ echo "Finished: $(date)"
87
+ echo "Total iterations: $COUNTER"
repository/scripts/monitoring_dashboard.sh ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Elizabeth Training Monitoring Dashboard
3
+
4
+ echo "=== Elizabeth Training Monitoring Dashboard ==="
5
+ echo "Timestamp: $(date)"
6
+ echo ""
7
+
8
+ # Check training manager
9
+ echo "📊 Training Manager Status:"
10
+ if ps aux | grep -q "training_manager.py" | grep -v grep; then
11
+ echo " ✅ RUNNING - Training manager active"
12
+ MANAGER_PID=$(ps aux | grep "training_manager.py" | grep -v grep | awk '{print $2}')
13
+ echo " PID: $MANAGER_PID"
14
+ else
15
+ echo " ❌ STOPPED - Training manager not running"
16
+ fi
17
+
18
+ echo ""
19
+
20
+ # Check Elizabeth processes
21
+ echo "🤖 Elizabeth Processes:"
22
+ ELIZABETH_PROCS=$(ps aux | grep "python3.*elizabeth" | grep -v grep)
23
+ if [ -n "$ELIZABETH_PROCS" ]; then
24
+ echo "$ELIZABETH_PROCS" | while read line; do
25
+ echo " ✅ $line"
26
+ done
27
+ COUNT=$(echo "$ELIZABETH_PROCS" | wc -l)
28
+ echo " Total processes: $COUNT"
29
+ else
30
+ echo " ❌ No Elizabeth processes found"
31
+ fi
32
+
33
+ echo ""
34
+
35
+ # Check logs
36
+ echo "📋 Log Files:"
37
+ LOG_FILES=$(ls -la /workspace/elizabeth_logs/ 2>/dev/null)
38
+ if [ -n "$LOG_FILES" ]; then
39
+ echo " Log directory: /workspace/elizabeth_logs/"
40
+ echo " Files:"
41
+ ls -la /workspace/elizabeth_logs/ | tail -5 | while read line; do
42
+ echo " $line"
43
+ done
44
+ else
45
+ echo " ❌ No log directory found"
46
+ fi
47
+
48
+ echo ""
49
+
50
+ # Check training history
51
+ echo "📈 Training History:"
52
+ if [ -f "/workspace/elizabeth_logs/training_history.json" ]; then
53
+ SESSIONS=$(jq '.total_sessions' /workspace/elizabeth_logs/training_history.json 2>/dev/null)
54
+ RESTARTS=$(jq '.total_restarts' /workspace/elizabeth_logs/training_history.json 2>/dev/null)
55
+ echo " Total sessions: ${SESSIONS:-0}"
56
+ echo " Total restarts: ${RESTARTS:-0}"
57
+ else
58
+ echo " No training history found"
59
+ fi
60
+
61
+ echo ""
62
+
63
+ # System status
64
+ echo "🖥️ System Status:"
65
+ CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}')
66
+ MEM=$(free -m | awk '/Mem:/ {printf "%.1f%%", $3/$2*100}')
67
+ echo " CPU Usage: $CPU%"
68
+ echo " Memory Usage: $MEM"
69
+
70
+ echo ""
71
+ echo "=== Dashboard Refresh: $(date) ==="
72
+ echo "Run this script periodically to monitor training status"
repository/scripts/start_training.sh ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Elizabeth Training Startup Script
3
+ # Auto-restarting training monitor
4
+
5
+ echo "=== Starting Elizabeth Training Monitor ==="
6
+ echo "Timestamp: $(date)"
7
+ echo "Working directory: $(pwd)"
8
+
9
+ # Set environment variables
10
+ export HF_TOKEN=${HF_TOKEN:-}
11
+ export HUGGINGFACE_HUB_ENABLE_HF_TRANSFER=1
12
+ export PYTHONUNBUFFERED=1
13
+
14
+ # Create logs directory
15
+ mkdir -p /workspace/elizabeth_logs
16
+
17
+ # Maximum restarts
18
+ MAX_RESTARTS=20
19
+ RESTART_DELAY=30
20
+
21
+ echo "Max restarts: $MAX_RESTARTS"
22
+ echo "Restart delay: ${RESTART_DELAY}s"
23
+ echo ""
24
+
25
+ RESTART_COUNT=0
26
+
27
+ while [ $RESTART_COUNT -le $MAX_RESTARTS ]; do
28
+ echo "[$(date)] Starting training session (Attempt $((RESTART_COUNT + 1))/$((MAX_RESTARTS + 1)))..."
29
+
30
+ # Start Elizabeth training
31
+ python3 /workspace/elizabeth-repo/src/elizabeth_main.py --interactive --version v0.0.2
32
+
33
+ EXIT_CODE=$?
34
+ echo "[$(date)] Training session ended with exit code: $EXIT_CODE"
35
+
36
+ if [ $EXIT_CODE -eq 0 ]; then
37
+ echo "Training completed successfully!"
38
+ break
39
+ fi
40
+
41
+ RESTART_COUNT=$((RESTART_COUNT + 1))
42
+
43
+ if [ $RESTART_COUNT -le $MAX_RESTARTS ]; then
44
+ echo "Restarting in $RESTART_DELAY seconds..."
45
+ sleep $RESTART_DELAY
46
+ else
47
+ echo "Maximum restart attempts reached!"
48
+ echo "Total restarts: $RESTART_COUNT"
49
+ break
50
+ fi
51
+ done
52
+
53
+ echo "=== Training Monitor Finished ==="
54
+ echo "Final restart count: $RESTART_COUNT"
55
+ echo "End time: $(date)"
repository/scripts/test_databases.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script to verify all DataOps database connections for Elizabeth
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ import redis
9
+ import chromadb
10
+ import psycopg2
11
+ import pymongo
12
+ import qdrant_client
13
+ from datetime import datetime
14
+
15
+ def test_redis():
16
+ """Test Redis connection"""
17
+ try:
18
+ client = redis.Redis(host='localhost', port=6379, decode_responses=True)
19
+ client.ping()
20
+ print("✅ Redis: Connected successfully")
21
+ return True
22
+ except Exception as e:
23
+ print(f"❌ Redis: Connection failed - {e}")
24
+ return False
25
+
26
+ def test_postgresql():
27
+ """Test PostgreSQL connection"""
28
+ try:
29
+ conn = psycopg2.connect(
30
+ host="localhost",
31
+ database="novadb",
32
+ user="postgres",
33
+ password="nova_db_pass"
34
+ )
35
+ cursor = conn.cursor()
36
+ cursor.execute("SELECT version();")
37
+ version = cursor.fetchone()
38
+ print(f"✅ PostgreSQL: Connected successfully - {version[0]}")
39
+ conn.close()
40
+ return True
41
+ except Exception as e:
42
+ print(f"❌ PostgreSQL: Connection failed - {e}")
43
+ return False
44
+
45
+ def test_mongodb():
46
+ """Test MongoDB connection"""
47
+ try:
48
+ client = pymongo.MongoClient("mongodb://localhost:27017/")
49
+ db = client["nova_documents"]
50
+ # Test connection by listing collections
51
+ collections = db.list_collection_names()
52
+ print(f"✅ MongoDB: Connected successfully - Collections: {len(collections)}")
53
+ return True
54
+ except Exception as e:
55
+ print(f"❌ MongoDB: Connection failed - {e}")
56
+ return False
57
+
58
+ def test_chromadb():
59
+ """Test ChromaDB connection"""
60
+ try:
61
+ client = chromadb.PersistentClient(path="/data/chromadb")
62
+ collections = client.list_collections()
63
+ print(f"✅ ChromaDB: Connected successfully - Collections: {len(collections)}")
64
+ return True
65
+ except Exception as e:
66
+ print(f"❌ ChromaDB: Connection failed - {e}")
67
+ return False
68
+
69
+ def test_qdrant():
70
+ """Test Qdrant connection"""
71
+ try:
72
+ client = qdrant_client.QdrantClient(
73
+ host="localhost",
74
+ port=17000,
75
+ prefer_grpc=False
76
+ )
77
+ collections = client.get_collections()
78
+ print(f"✅ Qdrant: Connected successfully - Collections: {len(collections.collections)}")
79
+ return True
80
+ except Exception as e:
81
+ print(f"❌ Qdrant: Connection failed - {e}")
82
+ return False
83
+
84
+ def test_dragonfly():
85
+ """Test DragonFly connection"""
86
+ try:
87
+ client = redis.Redis(host='localhost', port=18000, decode_responses=True)
88
+ client.ping()
89
+ print("✅ DragonFly: Connected successfully")
90
+ return True
91
+ except Exception as e:
92
+ print(f"❌ DragonFly: Connection failed - {e}")
93
+ return False
94
+
95
+ def main():
96
+ """Main test function"""
97
+ print("🔍 Testing Elizabeth DataOps Database Connections")
98
+ print("=" * 60)
99
+
100
+ results = {}
101
+
102
+ # Test all databases
103
+ results["redis"] = test_redis()
104
+ results["postgresql"] = test_postgresql()
105
+ results["mongodb"] = test_mongodb()
106
+ results["chromadb"] = test_chromadb()
107
+ results["qdrant"] = test_qdrant()
108
+ results["dragonfly"] = test_dragonfly()
109
+
110
+ print("=" * 60)
111
+
112
+ # Summary
113
+ successful = sum(results.values())
114
+ total = len(results)
115
+
116
+ print(f"📊 Connection Summary: {successful}/{total} successful")
117
+
118
+ if successful == total:
119
+ print("🎉 All DataOps databases connected successfully!")
120
+ print("Elizabeth can now utilize the complete infrastructure.")
121
+ else:
122
+ print("⚠️ Some connections failed. Elizabeth will use available databases.")
123
+
124
+ return all(results.values())
125
+
126
+ if __name__ == "__main__":
127
+ success = main()
128
+ sys.exit(0 if success else 1)
repository/scripts/training_manager.py ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Elizabeth Training Manager
4
+ Advanced training management with multiple training modes and robust monitoring
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ import time
10
+ import subprocess
11
+ import signal
12
+ import logging
13
+ import json
14
+ from datetime import datetime
15
+ from pathlib import Path
16
+
17
+ # Set up logging
18
+ logging.basicConfig(
19
+ level=logging.INFO,
20
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
21
+ handlers=[
22
+ logging.FileHandler('/workspace/elizabeth_logs/training_manager.log'),
23
+ logging.StreamHandler(sys.stdout)
24
+ ]
25
+ )
26
+ logger = logging.getLogger(__name__)
27
+
28
+ class TrainingManager:
29
+ """Advanced training management for Elizabeth"""
30
+
31
+ def __init__(self):
32
+ self.script_path = "/workspace/elizabeth-repo/src/elizabeth_main.py"
33
+ self.max_restarts = 20
34
+ self.restart_delay = 30
35
+ self.process = None
36
+ self.restart_count = 0
37
+ self.training_mode = "interactive" # interactive, autonomous, learning, conversation
38
+
39
+ # Training configurations
40
+ self.training_configs = {
41
+ "interactive": {
42
+ "args": ["--interactive", "--version", "v0.0.2"],
43
+ "description": "Interactive session with human guidance"
44
+ },
45
+ "autonomous": {
46
+ "args": ["--interactive", "--version", "v0.0.2"],
47
+ "description": "Fully autonomous learning mode"
48
+ },
49
+ "learning": {
50
+ "args": ["--version", "v0.0.2"],
51
+ "input_file": "/workspace/training_data/learning_prompts.txt",
52
+ "description": "Focused learning from training data"
53
+ }
54
+ }
55
+
56
+ # Ensure directories exist
57
+ os.makedirs("/workspace/elizabeth_logs", exist_ok=True)
58
+ os.makedirs("/workspace/training_data", exist_ok=True)
59
+
60
+ # Set environment
61
+ self.set_environment()
62
+
63
+ def set_environment(self):
64
+ """Set training environment variables"""
65
+ os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN", "")
66
+ os.environ["HUGGINGFACE_HUB_ENABLE_HF_TRANSFER"] = "1"
67
+ os.environ["PYTHONUNBUFFERED"] = "1"
68
+
69
+ def start_training(self, mode="interactive"):
70
+ """Start training session with specified mode"""
71
+ try:
72
+ config = self.training_configs.get(mode, self.training_configs["interactive"])
73
+
74
+ logger.info(f"Starting {mode} training session...")
75
+ logger.info(f"Description: {config['description']}")
76
+
77
+ # Build command
78
+ cmd = [sys.executable, self.script_path] + config["args"]
79
+
80
+ # Handle input file if specified
81
+ stdin = None
82
+ if "input_file" in config and os.path.exists(config["input_file"]):
83
+ stdin = open(config["input_file"], "r")
84
+
85
+ self.process = subprocess.Popen(
86
+ cmd,
87
+ stdout=subprocess.PIPE,
88
+ stderr=subprocess.PIPE,
89
+ text=True,
90
+ bufsize=1,
91
+ universal_newlines=True,
92
+ stdin=stdin
93
+ )
94
+
95
+ logger.info(f"Training process started with PID: {self.process.pid}")
96
+ logger.info(f"Command: {' '.join(cmd)}")
97
+
98
+ return True
99
+
100
+ except Exception as e:
101
+ logger.error(f"Failed to start {mode} training: {e}")
102
+ return False
103
+
104
+ def monitor_training(self, timeout=3600):
105
+ """Monitor training process with timeout"""
106
+ start_time = time.time()
107
+
108
+ try:
109
+ while True:
110
+ # Check timeout
111
+ if time.time() - start_time > timeout:
112
+ logger.warning(f"Training timeout after {timeout} seconds")
113
+ return "timeout"
114
+
115
+ # Check process status
116
+ return_code = self.process.poll()
117
+ if return_code is not None:
118
+ logger.info(f"Training process completed with code: {return_code}")
119
+ return "completed"
120
+
121
+ # Read output
122
+ if self.process.stdout:
123
+ output = self.process.stdout.readline()
124
+ if output:
125
+ logger.info(f"TRAINING_OUT: {output.strip()}")
126
+
127
+ if self.process.stderr:
128
+ error = self.process.stderr.readline()
129
+ if error:
130
+ logger.error(f"TRAINING_ERR: {error.strip()}")
131
+
132
+ # Check for stalls (no output for 5 minutes)
133
+ if time.time() - start_time > 300:
134
+ # Check if process is still responsive
135
+ try:
136
+ os.kill(self.process.pid, 0) # Check if process exists
137
+ except OSError:
138
+ logger.warning("Process appears to be unresponsive")
139
+ return "stalled"
140
+
141
+ time.sleep(1)
142
+
143
+ except Exception as e:
144
+ logger.error(f"Monitoring error: {e}")
145
+ return "error"
146
+
147
+ def graceful_shutdown(self):
148
+ """Gracefully shutdown training"""
149
+ if self.process:
150
+ try:
151
+ logger.info("Initiating graceful shutdown...")
152
+
153
+ # Try gentle termination first
154
+ self.process.terminate()
155
+
156
+ # Wait for clean shutdown
157
+ for i in range(10):
158
+ if self.process.poll() is not None:
159
+ break
160
+ time.sleep(1)
161
+
162
+ # Force kill if necessary
163
+ if self.process.poll() is None:
164
+ logger.warning("Process not terminating, forcing kill...")
165
+ self.process.kill()
166
+
167
+ logger.info("Training shutdown complete")
168
+
169
+ except Exception as e:
170
+ logger.error(f"Shutdown error: {e}")
171
+
172
+ def run_continuous_training(self):
173
+ """Main continuous training loop"""
174
+ logger.info("🚀 Starting Elizabeth Continuous Training Manager")
175
+ logger.info(f"Mode: {self.training_mode}")
176
+ logger.info(f"Max restarts: {self.max_restarts}")
177
+
178
+ training_sessions = []
179
+
180
+ while self.restart_count <= self.max_restarts:
181
+ session_start = datetime.now()
182
+
183
+ try:
184
+ # Start training session
185
+ if not self.start_training(self.training_mode):
186
+ logger.error("Failed to start training session")
187
+ break
188
+
189
+ # Monitor session
190
+ result = self.monitor_training()
191
+ session_end = datetime.now()
192
+ duration = (session_end - session_start).total_seconds()
193
+
194
+ # Record session
195
+ session_info = {
196
+ "start": session_start.isoformat(),
197
+ "end": session_end.isoformat(),
198
+ "duration": duration,
199
+ "result": result,
200
+ "restart_count": self.restart_count,
201
+ "pid": self.process.pid if self.process else None
202
+ }
203
+ training_sessions.append(session_info)
204
+
205
+ logger.info(f"Session completed: {result}, Duration: {duration:.1f}s")
206
+
207
+ # Handle session result
208
+ if result == "completed":
209
+ logger.info("Training session completed successfully")
210
+ break
211
+ elif self.restart_count < self.max_restarts:
212
+ self.restart_count += 1
213
+ logger.warning(f"Restarting training ({self.restart_count}/{self.max_restarts})...")
214
+ logger.info(f"Waiting {self.restart_delay} seconds before restart...")
215
+
216
+ # Save session history
217
+ self.save_session_history(training_sessions)
218
+
219
+ time.sleep(self.restart_delay)
220
+ else:
221
+ logger.error("Max restart attempts reached")
222
+ break
223
+
224
+ except KeyboardInterrupt:
225
+ logger.info("Received interrupt signal")
226
+ break
227
+ except Exception as e:
228
+ logger.error(f"Unexpected error: {e}")
229
+ self.restart_count += 1
230
+ if self.restart_count <= self.max_restarts:
231
+ logger.info(f"Restarting after error... ({self.restart_count}/{self.max_restarts})")
232
+ time.sleep(self.restart_delay)
233
+ else:
234
+ break
235
+
236
+ # Final cleanup and reporting
237
+ self.graceful_shutdown()
238
+ self.save_session_history(training_sessions)
239
+
240
+ logger.info("Training manager shutting down")
241
+ logger.info(f"Total sessions: {len(training_sessions)}")
242
+ logger.info(f"Total restarts: {self.restart_count}")
243
+
244
+ def save_session_history(self, sessions):
245
+ """Save training session history"""
246
+ try:
247
+ history_file = "/workspace/elizabeth_logs/training_history.json"
248
+ with open(history_file, 'w') as f:
249
+ json.dump({
250
+ "sessions": sessions,
251
+ "total_sessions": len(sessions),
252
+ "total_restarts": self.restart_count,
253
+ "last_update": datetime.now().isoformat()
254
+ }, f, indent=2)
255
+ except Exception as e:
256
+ logger.error(f"Failed to save session history: {e}")
257
+
258
+ def get_status(self):
259
+ """Get current status"""
260
+ return {
261
+ "training_mode": self.training_mode,
262
+ "restart_count": self.restart_count,
263
+ "max_restarts": self.max_restarts,
264
+ "process_active": self.process and self.process.poll() is None,
265
+ "process_pid": self.process.pid if self.process else None,
266
+ "timestamp": datetime.now().isoformat()
267
+ }
268
+
269
+ def main():
270
+ """Command line interface"""
271
+ import argparse
272
+
273
+ parser = argparse.ArgumentParser(description="Elizabeth Training Manager")
274
+ parser.add_argument("--start", action="store_true", help="Start continuous training")
275
+ parser.add_argument("--mode", choices=['interactive', 'autonomous', 'learning'],
276
+ default='interactive', help="Training mode")
277
+ parser.add_argument("--status", action="store_true", help="Show status")
278
+ parser.add_argument("--stop", action="store_true", help="Stop training")
279
+ parser.add_argument("--max-restarts", type=int, default=20, help="Max restart attempts")
280
+ parser.add_argument("--restart-delay", type=int, default=30, help="Restart delay in seconds")
281
+
282
+ args = parser.parse_args()
283
+
284
+ manager = TrainingManager()
285
+ manager.max_restarts = args.max_restarts
286
+ manager.restart_delay = args.restart_delay
287
+ manager.training_mode = args.mode
288
+
289
+ if args.start:
290
+ manager.run_continuous_training()
291
+ elif args.status:
292
+ status = manager.get_status()
293
+ print("Training Manager Status:")
294
+ for key, value in status.items():
295
+ print(f" {key}: {value}")
296
+ elif args.stop:
297
+ manager.graceful_shutdown()
298
+ print("Shutdown signal sent")
299
+ else:
300
+ print("No action specified. Use --help for options.")
301
+
302
+ if __name__ == "__main__":
303
+ main()
repository/scripts/training_monitor.py ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Elizabeth Training Monitor
4
+ Monitors training processes and automatically restarts if needed
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ import time
10
+ import subprocess
11
+ import signal
12
+ import logging
13
+ from datetime import datetime
14
+ from pathlib import Path
15
+
16
+ # Set up logging
17
+ logging.basicConfig(
18
+ level=logging.INFO,
19
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
20
+ handlers=[
21
+ logging.FileHandler('/workspace/elizabeth_logs/training_monitor.log'),
22
+ logging.StreamHandler(sys.stdout)
23
+ ]
24
+ )
25
+ logger = logging.getLogger(__name__)
26
+
27
+ class TrainingMonitor:
28
+ """Monitor and manage Elizabeth training processes"""
29
+
30
+ def __init__(self):
31
+ self.training_script = "/workspace/elizabeth-repo/src/elizabeth_main.py"
32
+ self.max_restarts = 10
33
+ self.restart_delay = 30 # seconds
34
+ self.process = None
35
+ self.restart_count = 0
36
+
37
+ # Ensure logs directory exists
38
+ os.makedirs("/workspace/elizabeth_logs", exist_ok=True)
39
+
40
+ def start_training(self):
41
+ """Start the training process"""
42
+ try:
43
+ logger.info("Starting Elizabeth training session...")
44
+
45
+ # Start Elizabeth in interactive mode with enhanced capabilities
46
+ self.process = subprocess.Popen(
47
+ [
48
+ sys.executable, self.training_script,
49
+ "--interactive",
50
+ "--version", "v0.0.2"
51
+ ],
52
+ stdout=subprocess.PIPE,
53
+ stderr=subprocess.PIPE,
54
+ text=True,
55
+ bufsize=1,
56
+ universal_newlines=True
57
+ )
58
+
59
+ logger.info(f"Training process started with PID: {self.process.pid}")
60
+ return True
61
+
62
+ except Exception as e:
63
+ logger.error(f"Failed to start training: {e}")
64
+ return False
65
+
66
+ def monitor_process(self):
67
+ """Monitor the training process and handle output"""
68
+ try:
69
+ # Monitor stdout and stderr
70
+ while True:
71
+ if self.process.stdout:
72
+ output = self.process.stdout.readline()
73
+ if output:
74
+ logger.info(f"TRAINING: {output.strip()}")
75
+
76
+ if self.process.stderr:
77
+ error = self.process.stderr.readline()
78
+ if error:
79
+ logger.error(f"TRAINING_ERROR: {error.strip()}")
80
+
81
+ # Check if process is still alive
82
+ return_code = self.process.poll()
83
+ if return_code is not None:
84
+ logger.warning(f"Training process exited with code: {return_code}")
85
+ return return_code
86
+
87
+ time.sleep(1)
88
+
89
+ except Exception as e:
90
+ logger.error(f"Monitoring error: {e}")
91
+ return -1
92
+
93
+ def graceful_shutdown(self):
94
+ """Gracefully shutdown the training process"""
95
+ if self.process:
96
+ try:
97
+ logger.info("Sending graceful shutdown signal...")
98
+ self.process.terminate()
99
+
100
+ # Wait for process to terminate
101
+ for _ in range(10):
102
+ if self.process.poll() is not None:
103
+ break
104
+ time.sleep(1)
105
+
106
+ # Force kill if still running
107
+ if self.process.poll() is None:
108
+ logger.warning("Process not terminating, forcing kill...")
109
+ self.process.kill()
110
+
111
+ logger.info("Training process shutdown complete")
112
+
113
+ except Exception as e:
114
+ logger.error(f"Shutdown error: {e}")
115
+
116
+ def run_monitoring_loop(self):
117
+ """Main monitoring loop with automatic restarts"""
118
+ logger.info("🚀 Starting Elizabeth Training Monitor")
119
+ logger.info(f"Max restarts: {self.max_restarts}")
120
+ logger.info(f"Restart delay: {self.restart_delay}s")
121
+
122
+ while self.restart_count <= self.max_restarts:
123
+ try:
124
+ # Start training
125
+ if not self.start_training():
126
+ logger.error("Failed to start training process")
127
+ break
128
+
129
+ # Monitor process
130
+ return_code = self.monitor_process()
131
+
132
+ # Check if we should restart
133
+ if return_code == 0:
134
+ logger.info("Training completed successfully")
135
+ break
136
+ elif self.restart_count < self.max_restarts:
137
+ self.restart_count += 1
138
+ logger.warning(f"Restarting training ({self.restart_count}/{self.max_restarts})...")
139
+ logger.info(f"Waiting {self.restart_delay} seconds before restart...")
140
+ time.sleep(self.restart_delay)
141
+ else:
142
+ logger.error("Max restart attempts reached")
143
+ break
144
+
145
+ except KeyboardInterrupt:
146
+ logger.info("Received interrupt signal, shutting down...")
147
+ break
148
+ except Exception as e:
149
+ logger.error(f"Unexpected error in monitoring loop: {e}")
150
+ self.restart_count += 1
151
+ if self.restart_count <= self.max_restarts:
152
+ logger.info(f"Restarting after error... ({self.restart_count}/{self.max_restarts})")
153
+ time.sleep(self.restart_delay)
154
+ else:
155
+ break
156
+
157
+ # Cleanup
158
+ self.graceful_shutdown()
159
+ logger.info("Training monitor shutting down")
160
+
161
+ def get_status(self):
162
+ """Get current monitoring status"""
163
+ return {
164
+ "restart_count": self.restart_count,
165
+ "max_restarts": self.max_restarts,
166
+ "process_active": self.process and self.process.poll() is None,
167
+ "process_pid": self.process.pid if self.process else None,
168
+ "timestamp": datetime.now().isoformat()
169
+ }
170
+
171
+ def main():
172
+ """Command line interface"""
173
+ import argparse
174
+
175
+ parser = argparse.ArgumentParser(description="Elizabeth Training Monitor")
176
+ parser.add_argument("--start", action="store_true", help="Start monitoring")
177
+ parser.add_argument("--status", action="store_true", help="Show status")
178
+ parser.add_argument("--stop", action="store_true", help="Stop monitoring")
179
+ parser.add_argument("--max-restarts", type=int, default=10, help="Max restart attempts")
180
+ parser.add_argument("--restart-delay", type=int, default=30, help="Restart delay in seconds")
181
+
182
+ args = parser.parse_args()
183
+
184
+ monitor = TrainingMonitor()
185
+ monitor.max_restarts = args.max_restarts
186
+ monitor.restart_delay = args.restart_delay
187
+
188
+ if args.start:
189
+ monitor.run_monitoring_loop()
190
+ elif args.status:
191
+ status = monitor.get_status()
192
+ print("Training Monitor Status:")
193
+ for key, value in status.items():
194
+ print(f" {key}: {value}")
195
+ elif args.stop:
196
+ monitor.graceful_shutdown()
197
+ print("Shutdown signal sent")
198
+ else:
199
+ print("No action specified. Use --help for options.")
200
+
201
+ if __name__ == "__main__":
202
+ main()
repository/versions/v0_0_2/__pycache__/elizabeth_enhanced.cpython-312.pyc CHANGED
Binary files a/repository/versions/v0_0_2/__pycache__/elizabeth_enhanced.cpython-312.pyc and b/repository/versions/v0_0_2/__pycache__/elizabeth_enhanced.cpython-312.pyc differ
 
repository/versions/v0_0_2/elizabeth_enhanced.py CHANGED
@@ -21,6 +21,10 @@ from typing import List, Dict, Optional, Any, Tuple
21
  import re
22
  import subprocess
23
  import shutil
 
 
 
 
24
  from rich.console import Console
25
  from rich.markdown import Markdown
26
  from rich.panel import Panel
@@ -105,51 +109,76 @@ IMPORTANT: You are Elizabeth responding TO Chase. Never confuse these roles.
105
  Use your tool belt responsibly to enhance our collaboration."""
106
 
107
  def setup_databases(self):
108
- """Initialize all database connections for full autonomy"""
109
 
110
- # SQLite for local storage (primary)
111
  self.sqlite_db = "/workspace/elizabeth_memory.db"
112
  self.init_sqlite()
113
 
114
- # Redis for fast retrieval
115
  try:
116
  self.redis_client = redis.Redis(host='localhost', port=6379, decode_responses=True)
117
  self.redis_client.ping()
118
- console.print("[green]✅ Redis connected for fast memory[/green]")
119
  except:
120
  self.redis_client = None
121
- console.print("[yellow]⚠️ Redis not available, using SQLite[/yellow]")
122
 
123
- # ChromaDB for semantic search
124
- try:
125
- self.chroma_client = chromadb.PersistentClient(path="/workspace/elizabeth_chroma")
126
- self.chroma_collection = self.chroma_client.get_or_create_collection("elizabeth_memory")
127
- console.print("[green]✅ ChromaDB connected for semantic memory[/green]")
128
- except:
129
- self.chroma_client = None
130
- console.print("[yellow]⚠️ ChromaDB not available[/yellow]")
131
-
132
- # PostgreSQL for production data (optional)
133
  try:
134
  self.pg_conn = psycopg2.connect(
135
  host="localhost",
136
- database="elizabeth_prod",
137
- user="elizabeth",
138
- password=os.getenv("PG_PASSWORD", "")
139
  )
140
- console.print("[green]✅ PostgreSQL connected for production data[/green]")
141
  except:
142
  self.pg_conn = None
143
  console.print("[yellow]⚠️ PostgreSQL not available[/yellow]")
144
 
145
- # MongoDB for document storage (optional)
146
  try:
147
  self.mongo_client = pymongo.MongoClient("mongodb://localhost:27017/")
148
- self.mongo_db = self.mongo_client["elizabeth_documents"]
149
  console.print("[green]✅ MongoDB connected for document storage[/green]")
150
  except:
151
  self.mongo_client = None
152
  console.print("[yellow]⚠️ MongoDB not available[/yellow]")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  def initialize_tool_belt(self) -> Dict[str, Any]:
155
  """Initialize the full autonomy tool belt"""
 
21
  import re
22
  import subprocess
23
  import shutil
24
+ try:
25
+ import qdrant_client
26
+ except ImportError:
27
+ qdrant_client = None
28
  from rich.console import Console
29
  from rich.markdown import Markdown
30
  from rich.panel import Panel
 
109
  Use your tool belt responsibly to enhance our collaboration."""
110
 
111
  def setup_databases(self):
112
+ """Initialize all database connections for full autonomy with complete DataOps integration"""
113
 
114
+ # SQLite for local storage (primary fallback)
115
  self.sqlite_db = "/workspace/elizabeth_memory.db"
116
  self.init_sqlite()
117
 
118
+ # Redis for fast retrieval (Nova-required)
119
  try:
120
  self.redis_client = redis.Redis(host='localhost', port=6379, decode_responses=True)
121
  self.redis_client.ping()
122
+ console.print("[green]✅ Redis connected for working memory[/green]")
123
  except:
124
  self.redis_client = None
125
+ console.print("[yellow]⚠️ Redis not available, using SQLite fallback[/yellow]")
126
 
127
+ # PostgreSQL for structured data (Nova-required)
 
 
 
 
 
 
 
 
 
128
  try:
129
  self.pg_conn = psycopg2.connect(
130
  host="localhost",
131
+ database="novadb",
132
+ user="postgres",
133
+ password="nova_db_pass"
134
  )
135
+ console.print("[green]✅ PostgreSQL connected for structured data[/green]")
136
  except:
137
  self.pg_conn = None
138
  console.print("[yellow]⚠️ PostgreSQL not available[/yellow]")
139
 
140
+ # MongoDB for document storage (Nova-required)
141
  try:
142
  self.mongo_client = pymongo.MongoClient("mongodb://localhost:27017/")
143
+ self.mongo_db = self.mongo_client["nova_documents"]
144
  console.print("[green]✅ MongoDB connected for document storage[/green]")
145
  except:
146
  self.mongo_client = None
147
  console.print("[yellow]⚠️ MongoDB not available[/yellow]")
148
+
149
+ # ChromaDB for semantic memory (Nova-required)
150
+ try:
151
+ self.chroma_client = chromadb.PersistentClient(path="/data/chromadb")
152
+ self.chroma_collection = self.chroma_client.get_or_create_collection("elizabeth_memory")
153
+ console.print("[green]✅ ChromaDB connected for semantic memory[/green]")
154
+ except:
155
+ self.chroma_client = None
156
+ console.print("[yellow]⚠️ ChromaDB not available[/yellow]")
157
+
158
+ # Qdrant for advanced vector search (Enhanced DataOps)
159
+ try:
160
+ import qdrant_client
161
+ self.qdrant_client = qdrant_client.QdrantClient(
162
+ host="localhost",
163
+ port=17000,
164
+ prefer_grpc=False,
165
+ check_compatibility=False # Disable version check for compatibility
166
+ )
167
+ # Test connection
168
+ self.qdrant_client.get_collections()
169
+ console.print("[green]✅ Qdrant connected for advanced vector memory[/green]")
170
+ except Exception as e:
171
+ self.qdrant_client = None
172
+ console.print(f"[yellow]⚠️ Qdrant not available: {e}[/yellow]")
173
+
174
+ # DragonFly cluster for high-performance caching (Enhanced DataOps)
175
+ try:
176
+ self.dragonfly_client = redis.Redis(host='localhost', port=18000, decode_responses=True)
177
+ self.dragonfly_client.ping()
178
+ console.print("[green]✅ DragonFly connected for high-performance cache[/green]")
179
+ except:
180
+ self.dragonfly_client = None
181
+ console.print("[yellow]⚠️ DragonFly not available[/yellow]")
182
 
183
  def initialize_tool_belt(self) -> Dict[str, Any]:
184
  """Initialize the full autonomy tool belt"""