Update dashboard/logs.py
Browse files- dashboard/logs.py +22 -11
dashboard/logs.py
CHANGED
|
@@ -1,18 +1,29 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import streamlit as st
|
| 4 |
import pandas as pd
|
|
|
|
| 5 |
import os
|
| 6 |
-
import sqlite3
|
| 7 |
|
| 8 |
-
|
| 9 |
-
DB_PATH = os.path.join("/tmp", "memory.db")
|
| 10 |
|
| 11 |
def show_logs():
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
conn = sqlite3.connect(DB_PATH)
|
| 14 |
-
df = pd.read_sql("SELECT * FROM
|
| 15 |
conn.close()
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sqlite3
|
|
|
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
+
import streamlit as st
|
| 4 |
import os
|
|
|
|
| 5 |
|
| 6 |
+
DB_PATH = os.path.join("/mnt/data", "memory.db")
|
|
|
|
| 7 |
|
| 8 |
def show_logs():
|
| 9 |
+
# Ensure DB exists
|
| 10 |
+
if not os.path.exists(DB_PATH):
|
| 11 |
+
st.info("No logs yet — run your first pipeline!")
|
| 12 |
+
return
|
| 13 |
+
|
| 14 |
conn = sqlite3.connect(DB_PATH)
|
| 15 |
+
df = pd.read_sql("SELECT * FROM memory_logs ORDER BY id DESC", conn)
|
| 16 |
conn.close()
|
| 17 |
+
|
| 18 |
+
if df.empty:
|
| 19 |
+
st.info("No logs yet — run your first pipeline!")
|
| 20 |
+
else:
|
| 21 |
+
st.dataframe(df, use_container_width=True)
|
| 22 |
+
# Offer download
|
| 23 |
+
csv = df.to_csv(index=False).encode("utf-8")
|
| 24 |
+
st.download_button(
|
| 25 |
+
label="📥 Download Logs CSV",
|
| 26 |
+
data=csv,
|
| 27 |
+
file_name="agent_memory_logs.csv",
|
| 28 |
+
mime="text/csv"
|
| 29 |
+
)
|