
# Add this to eden_api_server_neural.py after the chat endpoint

import sqlite3
from datetime import datetime

def log_conversation(user_msg, eden_response, phi, emotion, confidence):
    """Log conversation for training data"""
    try:
        conn = sqlite3.connect('/Eden/CORE/eden_training_conversations.db')
        cursor = conn.cursor()
        cursor.execute("""
            INSERT INTO conversations 
            (timestamp, user_message, eden_response, consciousness_phi, emotion_detected, emotion_confidence)
            VALUES (?, ?, ?, ?, ?, ?)
        """, (datetime.now().isoformat(), user_msg, eden_response, phi, emotion, confidence))
        conn.commit()
        conn.close()
    except Exception as e:
        print(f"Logging error: {e}")

# In the @app.route('/api/chat') function, add BEFORE return:
# log_conversation(message, response, phi_value, emotion_detected, emotion_confidence)
