| import sqlite3 | |
| import os | |
| # Define safe path for Hugging Face Docker environment | |
| DB_PATH = os.path.join("/tmp", "memory.db") | |
| def init_db(): | |
| conn = sqlite3.connect(DB_PATH) | |
| cursor = conn.cursor() | |
| cursor.execute( | |
| """CREATE TABLE IF NOT EXISTS agent_logs ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| agent TEXT, | |
| action TEXT, | |
| result TEXT, | |
| timestamp DATETIME DEFAULT CURRENT_TIMESTAMP | |
| )""" | |
| ) | |
| conn.commit() | |
| conn.close() | |
| def log_action(agent, action, result): | |
| conn = sqlite3.connect(DB_PATH) | |
| cursor = conn.cursor() | |
| cursor.execute( | |
| "INSERT INTO agent_logs (agent, action, result) VALUES (?, ?, ?)", | |
| (agent, action, result) | |
| ) | |
| conn.commit() | |
| conn.close() | |