Spaces:
Runtime error
Runtime error
dauksza123
commited on
Update StarReliabilityApp_Refined.py
Browse files
StarReliabilityApp_Refined.py
CHANGED
@@ -7,6 +7,8 @@ import speech_recognition as sr # For local STT (if desired)
|
|
7 |
|
8 |
class StarMaintAI:
|
9 |
def __init__(self, db_path):
|
|
|
|
|
10 |
self.connection = sqlite3.connect(db_path)
|
11 |
self.short_term_memory = []
|
12 |
self.medium_term_memory = []
|
@@ -31,6 +33,38 @@ class StarMaintAI:
|
|
31 |
|
32 |
self.load_long_term_memory()
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
def load_long_term_memory(self):
|
35 |
"""
|
36 |
Load persistent memory from the 'long_term_memory' table.
|
|
|
7 |
|
8 |
class StarMaintAI:
|
9 |
def __init__(self, db_path):
|
10 |
+
self.db_path = db_path
|
11 |
+
self.ensure_database_exists()
|
12 |
self.connection = sqlite3.connect(db_path)
|
13 |
self.short_term_memory = []
|
14 |
self.medium_term_memory = []
|
|
|
33 |
|
34 |
self.load_long_term_memory()
|
35 |
|
36 |
+
def ensure_database_exists(self):
|
37 |
+
"""
|
38 |
+
Ensure the database file exists and create required tables if not.
|
39 |
+
"""
|
40 |
+
if not os.path.exists(self.db_path):
|
41 |
+
print(f"Database not found at {self.db_path}. Initializing new database.")
|
42 |
+
connection = sqlite3.connect(self.db_path)
|
43 |
+
cursor = connection.cursor()
|
44 |
+
|
45 |
+
# Create necessary tables
|
46 |
+
cursor.execute("""
|
47 |
+
CREATE TABLE IF NOT EXISTS long_term_memory (
|
48 |
+
key TEXT PRIMARY KEY,
|
49 |
+
value TEXT
|
50 |
+
)
|
51 |
+
""")
|
52 |
+
cursor.execute("""
|
53 |
+
CREATE TABLE IF NOT EXISTS prompts (
|
54 |
+
title TEXT PRIMARY KEY,
|
55 |
+
description TEXT
|
56 |
+
)
|
57 |
+
""")
|
58 |
+
cursor.execute("""
|
59 |
+
CREATE TABLE IF NOT EXISTS functions (
|
60 |
+
function_name TEXT PRIMARY KEY,
|
61 |
+
description TEXT
|
62 |
+
)
|
63 |
+
""")
|
64 |
+
|
65 |
+
connection.commit()
|
66 |
+
connection.close()
|
67 |
+
|
68 |
def load_long_term_memory(self):
|
69 |
"""
|
70 |
Load persistent memory from the 'long_term_memory' table.
|