Mike Ferchak commited on
Commit
1b1ef21
Β·
1 Parent(s): e2c7d31

whatever, good enough

Browse files
Files changed (1) hide show
  1. app.py +70 -67
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.Row():
1171
- admin_refresh_btn = gr.Button(
1172
- "πŸ”„ Refresh Statistics", variant="primary"
1173
- )
1174
-
1175
- with gr.Row(equal_height=True):
1176
- admin_total_interactions = gr.Markdown(
1177
- "### Total Interactions: 0"
1178
- )
1179
- admin_total_flagged = gr.Markdown("### Total Flagged: 0")
1180
- admin_discrepancies = gr.Markdown("### v1/v2 Discrepancies: 0")
1181
- admin_feedback_count = gr.Markdown(
1182
- "### Feedback Submissions: 0"
1183
- )
1184
-
1185
- gr.Markdown("---")
 
 
 
 
 
 
 
1186
 
1187
  # Interaction History Section
1188
- gr.Markdown("### πŸ“‹ Interaction History")
1189
-
1190
- # Search box
1191
- admin_search_query = gr.Textbox(
1192
- label="Search",
1193
- placeholder="Search model name, prompt text, or feedback comments (case-insensitive)...",
1194
- value="",
1195
- )
1196
-
1197
- gr.Markdown(
1198
- "**Filter by (additive):** Select multiple filters to combine them"
1199
- )
1200
-
1201
- with gr.Row():
1202
- admin_filter_flagged = gr.Checkbox(
1203
- label="Flagged/Blocked", value=False
1204
- )
1205
- admin_filter_discrepancies = gr.Checkbox(
1206
- label="v1/v2 Discrepancies",
1207
- value=False,
1208
- info="Models disagree",
1209
- )
1210
- admin_filter_feedback = gr.Checkbox(
1211
- label="Has Feedback", value=False
1212
- )
1213
- admin_refresh_history_btn = gr.Button(
1214
- "πŸ”„ Refresh", variant="secondary"
 
 
1215
  )
1216
 
1217
- admin_history_html = gr.HTML(
1218
- "<p style='color: #666; padding: 20px;'>No data available. Login and refresh to load interactions.</p>"
1219
- )
1220
-
1221
- # Pagination controls
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.Markdown("### πŸ“₯ Export Data")
1234
- gr.Markdown(
1235
- "Export interactions to CSV for analysis. The export will respect the current filter selection."
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
- gr.Markdown("---")
 
 
 
 
 
 
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."