mirror of
https://github.com/infinition/Bjorn.git
synced 2026-03-11 07:01:59 +00:00
Add RLUtils class for managing RL/AI dashboard endpoints
- Implemented methods for fetching AI stats, training history, and recent experiences. - Added functionality to set operation mode (MANUAL, AUTO, AI) with appropriate handling. - Included helper methods for querying the database and sending JSON responses. - Integrated model metadata extraction for visualization purposes.
This commit is contained in:
@@ -33,16 +33,11 @@ class DBUtils:
|
||||
def _db_table_info(self, table: str):
|
||||
"""Get table info (primary key and columns)."""
|
||||
table = self._db_safe_ident(table)
|
||||
cols = [r["name"] for r in self.shared_data.db.query(f"PRAGMA table_info({table});")]
|
||||
if not cols:
|
||||
rows = self.shared_data.db.query(f"PRAGMA table_info({table});")
|
||||
if not rows:
|
||||
raise ValueError("Table not found")
|
||||
|
||||
pk = None
|
||||
for r in self.shared_data.db.query(f"PRAGMA table_info({table});"):
|
||||
if int(r["pk"] or 0) == 1:
|
||||
pk = r["name"]
|
||||
break
|
||||
|
||||
cols = [r["name"] for r in rows]
|
||||
pk = next((r["name"] for r in rows if int(r["pk"] or 0) == 1), None)
|
||||
if not pk:
|
||||
pk = "id" if "id" in cols else cols[0]
|
||||
return pk, cols
|
||||
|
||||
Reference in New Issue
Block a user