Spaces:
Sleeping
Sleeping
Mike Ferchak commited on
Commit Β·
1b1ef21
1
Parent(s): e2c7d31
whatever, good enough
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
from typing import AsyncIterator
|
| 3 |
|
| 4 |
import gradio as gr
|
|
|
|
| 5 |
import httpx
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
from mistralai import Mistral
|
|
@@ -1164,87 +1165,89 @@ def create_demo() -> gr.Blocks:
|
|
| 1164 |
|
| 1165 |
# Admin content (hidden until login)
|
| 1166 |
with gr.Column(visible=False) as admin_content:
|
| 1167 |
-
gr.Markdown("## π Security Guard Admin Dashboard")
|
| 1168 |
-
|
| 1169 |
# Statistics Section
|
| 1170 |
-
with gr.
|
| 1171 |
-
|
| 1172 |
-
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1186 |
|
| 1187 |
# Interaction History Section
|
| 1188 |
-
gr.
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
|
| 1210 |
-
|
| 1211 |
-
|
| 1212 |
-
|
| 1213 |
-
|
| 1214 |
-
|
|
|
|
|
|
|
| 1215 |
)
|
| 1216 |
|
| 1217 |
-
|
| 1218 |
-
|
| 1219 |
-
|
| 1220 |
-
|
| 1221 |
-
|
| 1222 |
-
with gr.Row():
|
| 1223 |
-
admin_prev_btn = gr.Button("β Previous", size="sm")
|
| 1224 |
-
admin_page_info = gr.Markdown("**Page 1 of 1**")
|
| 1225 |
-
admin_next_btn = gr.Button("Next β", size="sm")
|
| 1226 |
|
| 1227 |
# Hidden state for current page
|
| 1228 |
admin_current_page = gr.State(1)
|
| 1229 |
|
| 1230 |
-
gr.Markdown("---")
|
| 1231 |
-
|
| 1232 |
# Export Section
|
| 1233 |
-
gr.
|
| 1234 |
-
|
| 1235 |
-
|
| 1236 |
-
|
| 1237 |
-
|
| 1238 |
-
with gr.Row():
|
| 1239 |
-
admin_export_btn = gr.Button(
|
| 1240 |
-
"π Export to CSV", variant="secondary"
|
| 1241 |
)
|
| 1242 |
-
admin_export_file = gr.File(label="Download CSV", visible=False)
|
| 1243 |
|
| 1244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1245 |
|
| 1246 |
# Danger Zone Section
|
| 1247 |
-
with gr.Column(visible=False) as admin_danger_zone:
|
| 1248 |
gr.Markdown("### β οΈ DANGER ZONE")
|
| 1249 |
gr.Markdown(
|
| 1250 |
"**Warning:** These actions are irreversible and will permanently delete all data."
|
|
|
|
| 2 |
from typing import AsyncIterator
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
+
from gradio.components import label
|
| 6 |
import httpx
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
from mistralai import Mistral
|
|
|
|
| 1165 |
|
| 1166 |
# Admin content (hidden until login)
|
| 1167 |
with gr.Column(visible=False) as admin_content:
|
|
|
|
|
|
|
| 1168 |
# Statistics Section
|
| 1169 |
+
with gr.Column(variant="panel"):
|
| 1170 |
+
gr.Markdown("### Stats")
|
| 1171 |
+
with gr.Column():
|
| 1172 |
+
with gr.Row():
|
| 1173 |
+
admin_total_interactions = gr.Markdown(
|
| 1174 |
+
"**Total Interactions:** 0"
|
| 1175 |
+
)
|
| 1176 |
+
admin_total_flagged = gr.Markdown(
|
| 1177 |
+
"**Total Flagged:** 0"
|
| 1178 |
+
)
|
| 1179 |
+
admin_discrepancies = gr.Markdown(
|
| 1180 |
+
"**v1/v2 Discrepancies:** 0"
|
| 1181 |
+
)
|
| 1182 |
+
admin_feedback_count = gr.Markdown(
|
| 1183 |
+
"**Feedback Submissions:** 0"
|
| 1184 |
+
)
|
| 1185 |
+
|
| 1186 |
+
with gr.Row():
|
| 1187 |
+
admin_refresh_btn = gr.Button(
|
| 1188 |
+
"π Refresh Statistics",
|
| 1189 |
+
variant="secondary",
|
| 1190 |
+
size="sm",
|
| 1191 |
+
)
|
| 1192 |
|
| 1193 |
# Interaction History Section
|
| 1194 |
+
with gr.Column(variant="panel"):
|
| 1195 |
+
gr.Markdown("### π Logs")
|
| 1196 |
+
|
| 1197 |
+
with gr.Column():
|
| 1198 |
+
with gr.Row():
|
| 1199 |
+
admin_search_query = gr.Textbox(
|
| 1200 |
+
label="Search",
|
| 1201 |
+
placeholder="Search model name, prompt text, or feedback comments (case-insensitive)...",
|
| 1202 |
+
value="",
|
| 1203 |
+
show_label=False,
|
| 1204 |
+
)
|
| 1205 |
+
|
| 1206 |
+
with gr.Row():
|
| 1207 |
+
admin_filter_flagged = gr.Checkbox(
|
| 1208 |
+
label="Flagged/Blocked", value=False
|
| 1209 |
+
)
|
| 1210 |
+
admin_filter_discrepancies = gr.Checkbox(
|
| 1211 |
+
label="v1/v2 Discrepancies",
|
| 1212 |
+
value=False,
|
| 1213 |
+
)
|
| 1214 |
+
admin_filter_feedback = gr.Checkbox(
|
| 1215 |
+
label="Has Feedback", value=False
|
| 1216 |
+
)
|
| 1217 |
+
admin_refresh_history_btn = gr.Button(
|
| 1218 |
+
"π Refresh", variant="secondary"
|
| 1219 |
+
)
|
| 1220 |
+
|
| 1221 |
+
admin_history_html = gr.HTML(
|
| 1222 |
+
"<p style='color: #666; padding: 20px;'>No data available. Login and refresh to load interactions.</p>"
|
| 1223 |
)
|
| 1224 |
|
| 1225 |
+
# Pagination controls
|
| 1226 |
+
with gr.Row():
|
| 1227 |
+
admin_prev_btn = gr.Button("β Previous", size="sm")
|
| 1228 |
+
admin_page_info = gr.Markdown("**Page 1 of 1**")
|
| 1229 |
+
admin_next_btn = gr.Button("Next β", size="sm")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1230 |
|
| 1231 |
# Hidden state for current page
|
| 1232 |
admin_current_page = gr.State(1)
|
| 1233 |
|
|
|
|
|
|
|
| 1234 |
# Export Section
|
| 1235 |
+
with gr.Column(variant="panel"):
|
| 1236 |
+
gr.Markdown("### π₯ Export")
|
| 1237 |
+
gr.Markdown(
|
| 1238 |
+
"Export interactions to CSV for analysis. The export will respect the current filter selection."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1239 |
)
|
|
|
|
| 1240 |
|
| 1241 |
+
with gr.Row():
|
| 1242 |
+
admin_export_btn = gr.Button(
|
| 1243 |
+
"π Export to CSV", variant="secondary", size="sm"
|
| 1244 |
+
)
|
| 1245 |
+
admin_export_file = gr.File(
|
| 1246 |
+
label="Download CSV", visible=False
|
| 1247 |
+
)
|
| 1248 |
|
| 1249 |
# Danger Zone Section
|
| 1250 |
+
with gr.Column(visible=False, variant="panel") as admin_danger_zone:
|
| 1251 |
gr.Markdown("### β οΈ DANGER ZONE")
|
| 1252 |
gr.Markdown(
|
| 1253 |
"**Warning:** These actions are irreversible and will permanently delete all data."
|