Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -846,6 +846,17 @@ def cleanup_old_messages(days: int = 30) -> str:
|
|
| 846 |
except Exception as e:
|
| 847 |
return f"❌ Failed to clean old messages: {str(e)}"
|
| 848 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 849 |
|
| 850 |
# Define custom CSS for the Gradio interface
|
| 851 |
custom_css = """
|
|
|
|
| 846 |
except Exception as e:
|
| 847 |
return f"❌ Failed to clean old messages: {str(e)}"
|
| 848 |
|
| 849 |
+
def get_topics_list() -> List[str]:
|
| 850 |
+
"""Retrieve a list of unique topics from the database."""
|
| 851 |
+
try:
|
| 852 |
+
with sqlite3.connect(DATABASE_FILE) as conn:
|
| 853 |
+
cursor = conn.execute('SELECT DISTINCT topic FROM messages ORDER BY topic')
|
| 854 |
+
topics = [row[0] for row in cursor.fetchall()]
|
| 855 |
+
return ["All Topics"] + topics
|
| 856 |
+
except sqlite3.Error as e:
|
| 857 |
+
print(f"❌ Error retrieving topics: {str(e)}")
|
| 858 |
+
return ["All Topics"]
|
| 859 |
+
|
| 860 |
|
| 861 |
# Define custom CSS for the Gradio interface
|
| 862 |
custom_css = """
|