diff --git a/llm_team_ui.py b/llm_team_ui.py index bc1605f..bb4c3f7 100644 --- a/llm_team_ui.py +++ b/llm_team_ui.py @@ -151,7 +151,7 @@ def _check_high_alert_expiry(): # IPs that never get rate-limited (your LAN, localhost) ALLOWLIST_IPS = {"127.0.0.1", "::1", "192.168.1.1"} # Demo mode state — toggled by admin at runtime -_demo_mode = {"active": False, "started_by": None, "showcase": False} +_demo_mode = {"active": True, "started_by": "profit", "showcase": True} # Routes that demo users CAN trigger (read-like POSTs — enrichment, self-analysis, team runs) DEMO_ALLOWED_POSTS = { @@ -196,13 +196,13 @@ def is_demo(): # ─── THEME SYSTEM ──────────────────────────────────────────── # Shared CSS + JS for theme switching across all pages THEME_CSS = """ -body.theme-light, body.theme-reddit { +body.theme-light, body.theme-coral { --bg: #f5f3ef; --surface: rgba(255,254,251,0.92); --surface2: rgba(250,248,244,0.85); --border: #ddd8cf; --text: #1a1d23; --text2: #6b6560; --accent: #4f46e5; --accent2: #6366f1; --green: #16a34a; --orange: #d97706; --red: #dc2626; --blue: #2563eb; --glow: rgba(79,70,229,0.04); } -body.theme-reddit { +body.theme-coral { --bg: #dae0e6; --surface: #ffffff; --surface2: #f6f7f8; --border: #edeff1; --text: #1a1a1b; --text2: #7c7c7c; --accent: #ff4500; --accent2: #ff5414; --green: #46d160; --orange: #ff4500; --red: #ff585b; --blue: #7193ff; @@ -214,155 +214,155 @@ body.theme-modern { --green: #22c55e; --orange: #f59e0b; --red: #ef4444; --blue: #3b82f6; --glow: rgba(59,130,246,0.06); } -body.theme-light .scanlines, body.theme-light .vignette, body.theme-reddit .scanlines, body.theme-reddit .vignette { display: none; } -body.theme-light canvas#bg-grid, body.theme-reddit canvas#bg-grid { display: none; } -body.theme-light .panel, body.theme-light .login-box, body.theme-reddit .panel, body.theme-reddit .login-box { backdrop-filter: none; box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 0 0 1px var(--border); } -body.theme-light .panel::before, body.theme-reddit .panel::before { background: linear-gradient(90deg, transparent, rgba(79,70,229,0.12), transparent); } -body.theme-light .mode-tab, body.theme-reddit .mode-tab { background: var(--bg); } -body.theme-light .mode-tab.active, body.theme-reddit .mode-tab.active { background: rgba(79,70,229,0.06); box-shadow: 0 1px 3px rgba(79,70,229,0.1); } -body.theme-light .mode-tab.crazy, body.theme-reddit .mode-tab.crazy { background: linear-gradient(135deg, rgba(245,240,255,0.9), rgba(235,225,255,0.9)); border-color: rgba(168,85,247,0.2); } -body.theme-light .mode-tab.crazy.active, body.theme-reddit .mode-tab.crazy.active { background: linear-gradient(135deg, rgba(235,225,255,1), rgba(225,210,255,1)); border-color: #a855f7; color: #7c3aed; } -body.theme-light .model-card, body.theme-reddit .model-card { background: var(--bg); } -body.theme-light .model-card.selected, body.theme-reddit .model-card.selected { background: rgba(79,70,229,0.04); } -body.theme-light .model-card.selected .check, body.theme-reddit .model-card.selected .check { background: var(--accent); border-color: var(--accent); color: #fff; } -body.theme-light .prov-badge.ollama, body.theme-reddit .prov-badge.ollama { background: rgba(22,163,74,0.06); color: var(--green); border-color: rgba(22,163,74,0.15); } -body.theme-light .output-card, body.theme-reddit .output-card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); } -body.theme-light .output-card .card-body, body.theme-reddit .output-card .card-body { background: var(--surface); } -body.theme-light textarea, body.theme-reddit textarea { background: var(--surface) !important; color: var(--text) !important; } -body.theme-light input, body.theme-light select, body.theme-reddit input, body.theme-reddit select { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; } -body.theme-light select option, body.theme-reddit select option { background: var(--surface); color: var(--text); } -body.theme-light .config-row select, body.theme-reddit .config-row select { background: #fff !important; color: #1a1d23 !important; } -body.theme-light .config-row select option, body.theme-reddit .config-row select option { background: #fff; color: #1a1d23; } -body.theme-light .threat-card, body.theme-reddit .threat-card { background: var(--surface); } -body.theme-light .threat-card.critical, body.theme-reddit .threat-card.critical { background: rgba(220,38,38,0.03); } -body.theme-light .threat-card.high, body.theme-reddit .threat-card.high { background: rgba(217,119,6,0.03); } -body.theme-light .enrich-panel, body.theme-reddit .enrich-panel { background: rgba(79,70,229,0.03); border-color: rgba(79,70,229,0.15); } -body.theme-light .enrich-title, body.theme-reddit .enrich-title { color: var(--accent); } -body.theme-light .threat-summary .ts-box, body.theme-reddit .threat-summary .ts-box { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.04); } -body.theme-light .field input, body.theme-reddit .field input { background: var(--surface); } -body.theme-light .login-box .btn, body.theme-reddit .login-box .btn { color: #fff; } -body.theme-light .btn, body.theme-reddit .btn { background: var(--bg); color: var(--text); border-color: var(--border); } -body.theme-light .btn:hover, body.theme-reddit .btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,70,229,0.04); } -body.theme-light .btn-g, body.theme-light .btn-green, body.theme-reddit .btn-g, body.theme-reddit .btn-green { color: var(--green); border-color: rgba(22,163,74,0.3); background: rgba(22,163,74,0.04); } -body.theme-light .btn-g:hover, body.theme-light .btn-green:hover, body.theme-reddit .btn-g:hover, body.theme-reddit .btn-green:hover { background: rgba(22,163,74,0.08); border-color: var(--green); } -body.theme-light .btn-r, body.theme-light .btn-red, body.theme-reddit .btn-r, body.theme-reddit .btn-red { color: var(--red); border-color: rgba(220,38,38,0.3); background: rgba(220,38,38,0.04); } -body.theme-light .btn-r:hover, body.theme-light .btn-red:hover, body.theme-reddit .btn-r:hover, body.theme-reddit .btn-red:hover { background: rgba(220,38,38,0.08); border-color: var(--red); } -body.theme-light .btn-primary, body.theme-reddit .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; } -body.theme-light .btn-primary:hover, body.theme-reddit .btn-primary:hover { background: var(--accent2); } -body.theme-light .stat-box, body.theme-reddit .stat-box { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.04); } -body.theme-light .tab, body.theme-reddit .tab { background: var(--surface); } -body.theme-light .tab.active, body.theme-reddit .tab.active { background: rgba(79,70,229,0.06); } -body.theme-light code, body.theme-light pre, body.theme-reddit code, body.theme-reddit pre { background: rgba(0,0,0,0.03); } -body.theme-light .back, body.theme-reddit .back { background: var(--surface); } -body.theme-light .back:hover, body.theme-reddit .back:hover { border-color: var(--accent); color: var(--accent); } -body.theme-light .log-line:nth-child(even), body.theme-reddit .log-line:nth-child(even) { background: rgba(0,0,0,0.02); } -body.theme-light ::-webkit-scrollbar, body.theme-reddit ::-webkit-scrollbar { width: 8px; height: 8px; } -body.theme-light ::-webkit-scrollbar-thumb, body.theme-reddit ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } -body.theme-light ::-webkit-scrollbar-thumb:hover, body.theme-reddit ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.22); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } -body.theme-light ::-webkit-scrollbar-track, body.theme-reddit ::-webkit-scrollbar-track { background: transparent; } -body.theme-light .log-line, body.theme-reddit .log-line { color: #374151; } -body.theme-light #log-view, body.theme-reddit #log-view { background: var(--surface); border-color: var(--border); } -body.theme-light .controls, body.theme-reddit .controls { background: var(--surface); } -body.theme-light .controls select, body.theme-light .controls input, body.theme-reddit .controls select, body.theme-reddit .controls input { background: var(--surface) !important; } -body.theme-light .tag-err, body.theme-reddit .tag-err { background: rgba(220,38,38,0.06); color: var(--red); border-color: rgba(220,38,38,0.2); } -body.theme-light .tag-ok, body.theme-reddit .tag-ok { background: rgba(22,163,74,0.06); color: var(--green); border-color: rgba(22,163,74,0.2); } -body.theme-light .tag-time, body.theme-reddit .tag-time { background: rgba(79,70,229,0.06); color: var(--accent); border-color: rgba(79,70,229,0.2); } -body.theme-light .tag-mode, body.theme-reddit .tag-mode { background: rgba(217,119,6,0.06); color: var(--orange); border-color: rgba(217,119,6,0.2); } -body.theme-light .threat-summary .ts-box, body.theme-reddit .threat-summary .ts-box { background: #fff; border-color: var(--border); } -body.theme-light .ban-btn, body.theme-reddit .ban-btn { background: var(--surface); } -body.theme-light .ban-btn.ban, body.theme-reddit .ban-btn.ban { color: var(--red); border-color: rgba(220,38,38,0.3); } -body.theme-light .ban-btn.ban:hover, body.theme-reddit .ban-btn.ban:hover { background: rgba(220,38,38,0.05); } -body.theme-light .enrich-field .label, body.theme-reddit .enrich-field .label { color: #6b7280; } -body.theme-light .enrich-field .value, body.theme-reddit .enrich-field .value { color: #1a1d23; } -body.theme-light .provider-card, body.theme-light .prov-section, body.theme-reddit .provider-card, body.theme-reddit .prov-section { background: var(--surface); border-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.04); } -body.theme-light .toggle-switch input:checked + .toggle-slider, body.theme-reddit .toggle-switch input:checked + .toggle-slider { background: var(--accent); } -body.theme-light .run-card, body.theme-light .history-card, body.theme-reddit .run-card, body.theme-reddit .history-card { background: var(--surface); border-color: var(--border); } -body.theme-light .wrap, body.theme-reddit .wrap { background: transparent; } -body.theme-light header, body.theme-reddit header { border-color: var(--border); } -body.theme-light .tabs .tab.err, body.theme-reddit .tabs .tab.err { color: var(--red); border-color: rgba(220,38,38,0.2); } -body.theme-light .tabs .tab.err.active, body.theme-reddit .tabs .tab.err.active { background: rgba(220,38,38,0.04); } -body.theme-light .progress-panel, body.theme-reddit .progress-panel { background: rgba(255,255,255,0.97); border-color: var(--accent); box-shadow: 0 2px 12px rgba(79,70,229,0.08); } -body.theme-light .progress-panel.done, body.theme-reddit .progress-panel.done { border-color: var(--green); box-shadow: 0 2px 12px rgba(22,163,74,0.08); } -body.theme-light .progress-header .prog-mode, body.theme-reddit .progress-header .prog-mode { color: var(--accent); } -body.theme-light .progress-header .prog-time, body.theme-reddit .progress-header .prog-time { color: var(--text2); } -body.theme-light .progress-track, body.theme-reddit .progress-track { background: rgba(0,0,0,0.04); border-color: rgba(79,70,229,0.15); } -body.theme-light .progress-fill, body.theme-reddit .progress-fill { background: linear-gradient(90deg, var(--accent), #818cf8, var(--blue)); box-shadow: none; } -body.theme-light .progress-step, body.theme-reddit .progress-step { background: rgba(79,70,229,0.1); } -body.theme-light .progress-step.done, body.theme-reddit .progress-step.done { background: linear-gradient(90deg, var(--accent), var(--green)); } -body.theme-light .progress-step.active, body.theme-reddit .progress-step.active { background: var(--accent); box-shadow: 0 0 4px rgba(79,70,229,0.3); } -body.theme-light .progress-detail, body.theme-reddit .progress-detail { color: var(--text2); } -body.theme-light .progress-detail .prog-stats, body.theme-reddit .progress-detail .prog-stats { color: var(--accent); } -body.theme-light .output-card, body.theme-reddit .output-card { background: var(--surface); border-color: var(--border); backdrop-filter: none; } -body.theme-light .output-card .card-header, body.theme-reddit .output-card .card-header { border-color: var(--border); color: var(--text); } -body.theme-light .output-card .card-header .role-tag, body.theme-reddit .output-card .card-header .role-tag { background: rgba(0,0,0,0.03); color: var(--text2); border-color: var(--border); } -body.theme-light .output-card .card-body, body.theme-reddit .output-card .card-body { color: var(--text); background: #fff; } -body.theme-light .synthesis-card, body.theme-reddit .synthesis-card { border-color: var(--accent); } -body.theme-light .synthesis-card .card-header, body.theme-reddit .synthesis-card .card-header { background: rgba(79,70,229,0.04); } -body.theme-light .crazy-card, body.theme-reddit .crazy-card { border-color: #8b5cf6; } -body.theme-light .crazy-card .card-header, body.theme-reddit .crazy-card .card-header { background: rgba(139,92,246,0.04); } -body.theme-light .error-card .card-header, body.theme-reddit .error-card .card-header { background: rgba(220,38,38,0.04); } -body.theme-light .status-bar, body.theme-reddit .status-bar { background: var(--surface); border-color: var(--border); color: var(--text2); } -body.theme-light .card-act, body.theme-reddit .card-act { background: var(--surface); } -body.theme-light .card-act:hover, body.theme-reddit .card-act:hover { border-color: var(--accent); color: var(--accent); } -body.theme-light .demo-btn, body.theme-light [onclick*="toggleDemo"], body.theme-light [onclick*="setDemo"], body.theme-reddit .demo-btn, body.theme-reddit [onclick*="toggleDemo"], body.theme-reddit [onclick*="setDemo"] { background: var(--bg) !important; color: var(--text) !important; border: 2px solid var(--border) !important; } -body.theme-light .demo-btn:hover, body.theme-light [onclick*="toggleDemo"]:hover, body.theme-light [onclick*="setDemo"]:hover, body.theme-reddit .demo-btn:hover, body.theme-reddit [onclick*="toggleDemo"]:hover, body.theme-reddit [onclick*="setDemo"]:hover { border-color: var(--accent) !important; } -body.theme-light .remove-btn, body.theme-light button[onclick*="remove"], body.theme-light button[onclick*="Remove"], body.theme-light button[onclick*="delete"], body.theme-reddit .remove-btn, body.theme-reddit button[onclick*="remove"], body.theme-reddit button[onclick*="Remove"], body.theme-reddit button[onclick*="delete"] { background: rgba(220,38,38,0.06) !important; color: var(--red) !important; border-color: rgba(220,38,38,0.25) !important; } -body.theme-light .toggle-switch .toggle-slider, body.theme-reddit .toggle-switch .toggle-slider { background: #ccc8c0; } -body.theme-light .toggle-switch input:checked + .toggle-slider, body.theme-reddit .toggle-switch input:checked + .toggle-slider { background: var(--accent); } -body.theme-light .add-btn, body.theme-light button[onclick*="add"], body.theme-light button[onclick*="Add"], body.theme-reddit .add-btn, body.theme-reddit button[onclick*="add"], body.theme-reddit button[onclick*="Add"] { background: rgba(79,70,229,0.06) !important; color: var(--accent) !important; border-color: rgba(79,70,229,0.25) !important; } -body.theme-light .ip-row, body.theme-light .allowlist-row, body.theme-light .model-row, body.theme-reddit .ip-row, body.theme-reddit .allowlist-row, body.theme-reddit .model-row { background: var(--surface); border-color: var(--border); } -body.theme-light .prov-section, body.theme-light .section-card, body.theme-light [class*="section"], body.theme-light .tab-content > div > div, body.theme-reddit .prov-section, body.theme-reddit .section-card, body.theme-reddit [class*="section"], body.theme-reddit .tab-content > div > div { border-color: var(--border); } -body.theme-reddit { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; } -body.theme-reddit .panel, body.theme-reddit .output-card, body.theme-reddit .threat-card, body.theme-reddit .stat-box, body.theme-reddit .provider-card, body.theme-reddit .prov-section, body.theme-reddit .run-card, body.theme-reddit .history-card, body.theme-reddit .threat-summary .ts-box, body.theme-reddit .enrich-panel { border-radius: 8px; border-width: 1px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); } -body.theme-reddit .tab, body.theme-reddit .back, body.theme-reddit .ban-btn, body.theme-reddit .btn, body.theme-reddit .card-act, body.theme-reddit .theme-toggle, body.theme-reddit input, body.theme-reddit select, body.theme-reddit textarea { border-radius: 20px; } -body.theme-reddit .tag, body.theme-reddit .prov-badge { border-radius: 12px; } -body.theme-reddit .mode-tab, body.theme-reddit .model-card { border-radius: 8px; } -body.theme-reddit .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); } -body.theme-reddit .tab:hover { background: rgba(255,69,0,0.06); } -body.theme-reddit .mode-tab.active { background: rgba(255,69,0,0.08); border-color: var(--accent); color: var(--accent); box-shadow: none; } -body.theme-reddit .mode-tab.crazy, body.theme-reddit .mode-tab.crazy.active { background: rgba(255,69,0,0.06); border-color: rgba(255,69,0,0.2); color: var(--accent); } -body.theme-reddit .model-card.selected { border-color: var(--accent); background: rgba(255,69,0,0.04); } -body.theme-reddit .model-card.selected .check { background: var(--accent); border-color: var(--accent); } -body.theme-reddit .btn-primary, body.theme-reddit .login-box .btn { background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 20px; } -body.theme-reddit .btn-g, body.theme-reddit .btn-green { color: var(--green); border-color: rgba(70,209,96,0.3); background: rgba(70,209,96,0.06); } -body.theme-reddit .btn-r, body.theme-reddit .btn-red { color: var(--red); border-color: rgba(255,88,91,0.3); background: rgba(255,88,91,0.06); } -body.theme-reddit .output-card .card-header { border-radius: 8px 8px 0 0; border-bottom-width: 1px; } -body.theme-reddit .output-card .card-body { border-radius: 0 0 8px 8px; } -body.theme-reddit .synthesis-card { border-color: var(--accent); } -body.theme-reddit .synthesis-card .card-header { background: rgba(255,69,0,0.04); } -body.theme-reddit .progress-panel { border-radius: 8px; border-color: var(--accent); box-shadow: 0 2px 8px rgba(255,69,0,0.08); } -body.theme-reddit .progress-fill { background: linear-gradient(90deg, #ff4500, #ff8b60); } -body.theme-reddit .progress-step.done { background: linear-gradient(90deg, #ff4500, var(--green)); } -body.theme-reddit .progress-step.active { background: var(--accent); } -body.theme-reddit .progress-header .prog-mode { color: var(--accent); } -body.theme-reddit .enrich-panel { background: rgba(255,69,0,0.02); border-color: rgba(255,69,0,0.12); } -body.theme-reddit .enrich-title { color: var(--accent); } -body.theme-reddit .tabs .tab.err.active { background: var(--red); color: #fff; border-color: var(--red); } -body.theme-reddit .tag-time, body.theme-reddit .tag-mode { background: rgba(255,69,0,0.06); color: var(--accent); border-color: rgba(255,69,0,0.15); } -body.theme-reddit .tag-err { background: rgba(255,88,91,0.08); color: var(--red); border-color: rgba(255,88,91,0.2); } -body.theme-reddit .tag-ok { background: rgba(70,209,96,0.08); color: var(--green); border-color: rgba(70,209,96,0.2); } -body.theme-reddit .prov-badge.ollama { background: rgba(70,209,96,0.08); color: var(--green); border-color: rgba(70,209,96,0.2); } -body.theme-reddit header { border-bottom-width: 1px; } -body.theme-reddit ::-webkit-scrollbar-thumb { background: rgba(255,69,0,0.15); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } -body.theme-reddit ::-webkit-scrollbar-thumb:hover { background: rgba(255,69,0,0.3); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } -body.theme-light .new-prompt-btn, body.theme-reddit .new-prompt-btn { color: #fff; } -body.theme-light .composer-close, body.theme-reddit .composer-close { background: var(--surface); } -body.theme-reddit .new-prompt-btn { border-radius: 20px; } -body.theme-reddit .composer-close { border-radius: 20px; } +body.theme-light .scanlines, body.theme-light .vignette, body.theme-coral .scanlines, body.theme-coral .vignette { display: none; } +body.theme-light canvas#bg-grid, body.theme-coral canvas#bg-grid { display: none; } +body.theme-light .panel, body.theme-light .login-box, body.theme-coral .panel, body.theme-coral .login-box { backdrop-filter: none; box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 0 0 1px var(--border); } +body.theme-light .panel::before, body.theme-coral .panel::before { background: linear-gradient(90deg, transparent, rgba(79,70,229,0.12), transparent); } +body.theme-light .mode-tab, body.theme-coral .mode-tab { background: var(--bg); } +body.theme-light .mode-tab.active, body.theme-coral .mode-tab.active { background: rgba(79,70,229,0.06); box-shadow: 0 1px 3px rgba(79,70,229,0.1); } +body.theme-light .mode-tab.crazy, body.theme-coral .mode-tab.crazy { background: linear-gradient(135deg, rgba(245,240,255,0.9), rgba(235,225,255,0.9)); border-color: rgba(168,85,247,0.2); } +body.theme-light .mode-tab.crazy.active, body.theme-coral .mode-tab.crazy.active { background: linear-gradient(135deg, rgba(235,225,255,1), rgba(225,210,255,1)); border-color: #a855f7; color: #7c3aed; } +body.theme-light .model-card, body.theme-coral .model-card { background: var(--bg); } +body.theme-light .model-card.selected, body.theme-coral .model-card.selected { background: rgba(79,70,229,0.04); } +body.theme-light .model-card.selected .check, body.theme-coral .model-card.selected .check { background: var(--accent); border-color: var(--accent); color: #fff; } +body.theme-light .prov-badge.ollama, body.theme-coral .prov-badge.ollama { background: rgba(22,163,74,0.06); color: var(--green); border-color: rgba(22,163,74,0.15); } +body.theme-light .output-card, body.theme-coral .output-card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); } +body.theme-light .output-card .card-body, body.theme-coral .output-card .card-body { background: var(--surface); } +body.theme-light textarea, body.theme-coral textarea { background: var(--surface) !important; color: var(--text) !important; } +body.theme-light input, body.theme-light select, body.theme-coral input, body.theme-coral select { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; } +body.theme-light select option, body.theme-coral select option { background: var(--surface); color: var(--text); } +body.theme-light .config-row select, body.theme-coral .config-row select { background: #fff !important; color: #1a1d23 !important; } +body.theme-light .config-row select option, body.theme-coral .config-row select option { background: #fff; color: #1a1d23; } +body.theme-light .threat-card, body.theme-coral .threat-card { background: var(--surface); } +body.theme-light .threat-card.critical, body.theme-coral .threat-card.critical { background: rgba(220,38,38,0.03); } +body.theme-light .threat-card.high, body.theme-coral .threat-card.high { background: rgba(217,119,6,0.03); } +body.theme-light .enrich-panel, body.theme-coral .enrich-panel { background: rgba(79,70,229,0.03); border-color: rgba(79,70,229,0.15); } +body.theme-light .enrich-title, body.theme-coral .enrich-title { color: var(--accent); } +body.theme-light .threat-summary .ts-box, body.theme-coral .threat-summary .ts-box { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.04); } +body.theme-light .field input, body.theme-coral .field input { background: var(--surface); } +body.theme-light .login-box .btn, body.theme-coral .login-box .btn { color: #fff; } +body.theme-light .btn, body.theme-coral .btn { background: var(--bg); color: var(--text); border-color: var(--border); } +body.theme-light .btn:hover, body.theme-coral .btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,70,229,0.04); } +body.theme-light .btn-g, body.theme-light .btn-green, body.theme-coral .btn-g, body.theme-coral .btn-green { color: var(--green); border-color: rgba(22,163,74,0.3); background: rgba(22,163,74,0.04); } +body.theme-light .btn-g:hover, body.theme-light .btn-green:hover, body.theme-coral .btn-g:hover, body.theme-coral .btn-green:hover { background: rgba(22,163,74,0.08); border-color: var(--green); } +body.theme-light .btn-r, body.theme-light .btn-red, body.theme-coral .btn-r, body.theme-coral .btn-red { color: var(--red); border-color: rgba(220,38,38,0.3); background: rgba(220,38,38,0.04); } +body.theme-light .btn-r:hover, body.theme-light .btn-red:hover, body.theme-coral .btn-r:hover, body.theme-coral .btn-red:hover { background: rgba(220,38,38,0.08); border-color: var(--red); } +body.theme-light .btn-primary, body.theme-coral .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; } +body.theme-light .btn-primary:hover, body.theme-coral .btn-primary:hover { background: var(--accent2); } +body.theme-light .stat-box, body.theme-coral .stat-box { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.04); } +body.theme-light .tab, body.theme-coral .tab { background: var(--surface); } +body.theme-light .tab.active, body.theme-coral .tab.active { background: rgba(79,70,229,0.06); } +body.theme-light code, body.theme-light pre, body.theme-coral code, body.theme-coral pre { background: rgba(0,0,0,0.03); } +body.theme-light .back, body.theme-coral .back { background: var(--surface); } +body.theme-light .back:hover, body.theme-coral .back:hover { border-color: var(--accent); color: var(--accent); } +body.theme-light .log-line:nth-child(even), body.theme-coral .log-line:nth-child(even) { background: rgba(0,0,0,0.02); } +body.theme-light ::-webkit-scrollbar, body.theme-coral ::-webkit-scrollbar { width: 8px; height: 8px; } +body.theme-light ::-webkit-scrollbar-thumb, body.theme-coral ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } +body.theme-light ::-webkit-scrollbar-thumb:hover, body.theme-coral ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.22); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } +body.theme-light ::-webkit-scrollbar-track, body.theme-coral ::-webkit-scrollbar-track { background: transparent; } +body.theme-light .log-line, body.theme-coral .log-line { color: #374151; } +body.theme-light #log-view, body.theme-coral #log-view { background: var(--surface); border-color: var(--border); } +body.theme-light .controls, body.theme-coral .controls { background: var(--surface); } +body.theme-light .controls select, body.theme-light .controls input, body.theme-coral .controls select, body.theme-coral .controls input { background: var(--surface) !important; } +body.theme-light .tag-err, body.theme-coral .tag-err { background: rgba(220,38,38,0.06); color: var(--red); border-color: rgba(220,38,38,0.2); } +body.theme-light .tag-ok, body.theme-coral .tag-ok { background: rgba(22,163,74,0.06); color: var(--green); border-color: rgba(22,163,74,0.2); } +body.theme-light .tag-time, body.theme-coral .tag-time { background: rgba(79,70,229,0.06); color: var(--accent); border-color: rgba(79,70,229,0.2); } +body.theme-light .tag-mode, body.theme-coral .tag-mode { background: rgba(217,119,6,0.06); color: var(--orange); border-color: rgba(217,119,6,0.2); } +body.theme-light .threat-summary .ts-box, body.theme-coral .threat-summary .ts-box { background: #fff; border-color: var(--border); } +body.theme-light .ban-btn, body.theme-coral .ban-btn { background: var(--surface); } +body.theme-light .ban-btn.ban, body.theme-coral .ban-btn.ban { color: var(--red); border-color: rgba(220,38,38,0.3); } +body.theme-light .ban-btn.ban:hover, body.theme-coral .ban-btn.ban:hover { background: rgba(220,38,38,0.05); } +body.theme-light .enrich-field .label, body.theme-coral .enrich-field .label { color: #6b7280; } +body.theme-light .enrich-field .value, body.theme-coral .enrich-field .value { color: #1a1d23; } +body.theme-light .provider-card, body.theme-light .prov-section, body.theme-coral .provider-card, body.theme-coral .prov-section { background: var(--surface); border-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.04); } +body.theme-light .toggle-switch input:checked + .toggle-slider, body.theme-coral .toggle-switch input:checked + .toggle-slider { background: var(--accent); } +body.theme-light .run-card, body.theme-light .history-card, body.theme-coral .run-card, body.theme-coral .history-card { background: var(--surface); border-color: var(--border); } +body.theme-light .wrap, body.theme-coral .wrap { background: transparent; } +body.theme-light header, body.theme-coral header { border-color: var(--border); } +body.theme-light .tabs .tab.err, body.theme-coral .tabs .tab.err { color: var(--red); border-color: rgba(220,38,38,0.2); } +body.theme-light .tabs .tab.err.active, body.theme-coral .tabs .tab.err.active { background: rgba(220,38,38,0.04); } +body.theme-light .progress-panel, body.theme-coral .progress-panel { background: rgba(255,255,255,0.97); border-color: var(--accent); box-shadow: 0 2px 12px rgba(79,70,229,0.08); } +body.theme-light .progress-panel.done, body.theme-coral .progress-panel.done { border-color: var(--green); box-shadow: 0 2px 12px rgba(22,163,74,0.08); } +body.theme-light .progress-header .prog-mode, body.theme-coral .progress-header .prog-mode { color: var(--accent); } +body.theme-light .progress-header .prog-time, body.theme-coral .progress-header .prog-time { color: var(--text2); } +body.theme-light .progress-track, body.theme-coral .progress-track { background: rgba(0,0,0,0.04); border-color: rgba(79,70,229,0.15); } +body.theme-light .progress-fill, body.theme-coral .progress-fill { background: linear-gradient(90deg, var(--accent), #818cf8, var(--blue)); box-shadow: none; } +body.theme-light .progress-step, body.theme-coral .progress-step { background: rgba(79,70,229,0.1); } +body.theme-light .progress-step.done, body.theme-coral .progress-step.done { background: linear-gradient(90deg, var(--accent), var(--green)); } +body.theme-light .progress-step.active, body.theme-coral .progress-step.active { background: var(--accent); box-shadow: 0 0 4px rgba(79,70,229,0.3); } +body.theme-light .progress-detail, body.theme-coral .progress-detail { color: var(--text2); } +body.theme-light .progress-detail .prog-stats, body.theme-coral .progress-detail .prog-stats { color: var(--accent); } +body.theme-light .output-card, body.theme-coral .output-card { background: var(--surface); border-color: var(--border); backdrop-filter: none; } +body.theme-light .output-card .card-header, body.theme-coral .output-card .card-header { border-color: var(--border); color: var(--text); } +body.theme-light .output-card .card-header .role-tag, body.theme-coral .output-card .card-header .role-tag { background: rgba(0,0,0,0.03); color: var(--text2); border-color: var(--border); } +body.theme-light .output-card .card-body, body.theme-coral .output-card .card-body { color: var(--text); background: #fff; } +body.theme-light .synthesis-card, body.theme-coral .synthesis-card { border-color: var(--accent); } +body.theme-light .synthesis-card .card-header, body.theme-coral .synthesis-card .card-header { background: rgba(79,70,229,0.04); } +body.theme-light .crazy-card, body.theme-coral .crazy-card { border-color: #8b5cf6; } +body.theme-light .crazy-card .card-header, body.theme-coral .crazy-card .card-header { background: rgba(139,92,246,0.04); } +body.theme-light .error-card .card-header, body.theme-coral .error-card .card-header { background: rgba(220,38,38,0.04); } +body.theme-light .status-bar, body.theme-coral .status-bar { background: var(--surface); border-color: var(--border); color: var(--text2); } +body.theme-light .card-act, body.theme-coral .card-act { background: var(--surface); } +body.theme-light .card-act:hover, body.theme-coral .card-act:hover { border-color: var(--accent); color: var(--accent); } +body.theme-light .demo-btn, body.theme-light [onclick*="toggleDemo"], body.theme-light [onclick*="setDemo"], body.theme-coral .demo-btn, body.theme-coral [onclick*="toggleDemo"], body.theme-coral [onclick*="setDemo"] { background: var(--bg) !important; color: var(--text) !important; border: 2px solid var(--border) !important; } +body.theme-light .demo-btn:hover, body.theme-light [onclick*="toggleDemo"]:hover, body.theme-light [onclick*="setDemo"]:hover, body.theme-coral .demo-btn:hover, body.theme-coral [onclick*="toggleDemo"]:hover, body.theme-coral [onclick*="setDemo"]:hover { border-color: var(--accent) !important; } +body.theme-light .remove-btn, body.theme-light button[onclick*="remove"], body.theme-light button[onclick*="Remove"], body.theme-light button[onclick*="delete"], body.theme-coral .remove-btn, body.theme-coral button[onclick*="remove"], body.theme-coral button[onclick*="Remove"], body.theme-coral button[onclick*="delete"] { background: rgba(220,38,38,0.06) !important; color: var(--red) !important; border-color: rgba(220,38,38,0.25) !important; } +body.theme-light .toggle-switch .toggle-slider, body.theme-coral .toggle-switch .toggle-slider { background: #ccc8c0; } +body.theme-light .toggle-switch input:checked + .toggle-slider, body.theme-coral .toggle-switch input:checked + .toggle-slider { background: var(--accent); } +body.theme-light .add-btn, body.theme-light button[onclick*="add"], body.theme-light button[onclick*="Add"], body.theme-coral .add-btn, body.theme-coral button[onclick*="add"], body.theme-coral button[onclick*="Add"] { background: rgba(79,70,229,0.06) !important; color: var(--accent) !important; border-color: rgba(79,70,229,0.25) !important; } +body.theme-light .ip-row, body.theme-light .allowlist-row, body.theme-light .model-row, body.theme-coral .ip-row, body.theme-coral .allowlist-row, body.theme-coral .model-row { background: var(--surface); border-color: var(--border); } +body.theme-light .prov-section, body.theme-light .section-card, body.theme-light [class*="section"], body.theme-light .tab-content > div > div, body.theme-coral .prov-section, body.theme-coral .section-card, body.theme-coral [class*="section"], body.theme-coral .tab-content > div > div { border-color: var(--border); } +body.theme-coral { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; } +body.theme-coral .panel, body.theme-coral .output-card, body.theme-coral .threat-card, body.theme-coral .stat-box, body.theme-coral .provider-card, body.theme-coral .prov-section, body.theme-coral .run-card, body.theme-coral .history-card, body.theme-coral .threat-summary .ts-box, body.theme-coral .enrich-panel { border-radius: 8px; border-width: 1px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); } +body.theme-coral .tab, body.theme-coral .back, body.theme-coral .ban-btn, body.theme-coral .btn, body.theme-coral .card-act, body.theme-coral .theme-toggle, body.theme-coral input, body.theme-coral select, body.theme-coral textarea { border-radius: 20px; } +body.theme-coral .tag, body.theme-coral .prov-badge { border-radius: 12px; } +body.theme-coral .mode-tab, body.theme-coral .model-card { border-radius: 8px; } +body.theme-coral .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); } +body.theme-coral .tab:hover { background: rgba(255,69,0,0.06); } +body.theme-coral .mode-tab.active { background: rgba(255,69,0,0.08); border-color: var(--accent); color: var(--accent); box-shadow: none; } +body.theme-coral .mode-tab.crazy, body.theme-coral .mode-tab.crazy.active { background: rgba(255,69,0,0.06); border-color: rgba(255,69,0,0.2); color: var(--accent); } +body.theme-coral .model-card.selected { border-color: var(--accent); background: rgba(255,69,0,0.04); } +body.theme-coral .model-card.selected .check { background: var(--accent); border-color: var(--accent); } +body.theme-coral .btn-primary, body.theme-coral .login-box .btn { background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 20px; } +body.theme-coral .btn-g, body.theme-coral .btn-green { color: var(--green); border-color: rgba(70,209,96,0.3); background: rgba(70,209,96,0.06); } +body.theme-coral .btn-r, body.theme-coral .btn-red { color: var(--red); border-color: rgba(255,88,91,0.3); background: rgba(255,88,91,0.06); } +body.theme-coral .output-card .card-header { border-radius: 8px 8px 0 0; border-bottom-width: 1px; } +body.theme-coral .output-card .card-body { border-radius: 0 0 8px 8px; } +body.theme-coral .synthesis-card { border-color: var(--accent); } +body.theme-coral .synthesis-card .card-header { background: rgba(255,69,0,0.04); } +body.theme-coral .progress-panel { border-radius: 8px; border-color: var(--accent); box-shadow: 0 2px 8px rgba(255,69,0,0.08); } +body.theme-coral .progress-fill { background: linear-gradient(90deg, #ff4500, #ff8b60); } +body.theme-coral .progress-step.done { background: linear-gradient(90deg, #ff4500, var(--green)); } +body.theme-coral .progress-step.active { background: var(--accent); } +body.theme-coral .progress-header .prog-mode { color: var(--accent); } +body.theme-coral .enrich-panel { background: rgba(255,69,0,0.02); border-color: rgba(255,69,0,0.12); } +body.theme-coral .enrich-title { color: var(--accent); } +body.theme-coral .tabs .tab.err.active { background: var(--red); color: #fff; border-color: var(--red); } +body.theme-coral .tag-time, body.theme-coral .tag-mode { background: rgba(255,69,0,0.06); color: var(--accent); border-color: rgba(255,69,0,0.15); } +body.theme-coral .tag-err { background: rgba(255,88,91,0.08); color: var(--red); border-color: rgba(255,88,91,0.2); } +body.theme-coral .tag-ok { background: rgba(70,209,96,0.08); color: var(--green); border-color: rgba(70,209,96,0.2); } +body.theme-coral .prov-badge.ollama { background: rgba(70,209,96,0.08); color: var(--green); border-color: rgba(70,209,96,0.2); } +body.theme-coral header { border-bottom-width: 1px; } +body.theme-coral ::-webkit-scrollbar-thumb { background: rgba(255,69,0,0.15); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } +body.theme-coral ::-webkit-scrollbar-thumb:hover { background: rgba(255,69,0,0.3); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; } +body.theme-light .new-prompt-btn, body.theme-coral .new-prompt-btn { color: #fff; } +body.theme-light .composer-close, body.theme-coral .composer-close { background: var(--surface); } +body.theme-coral .new-prompt-btn { border-radius: 20px; } +body.theme-coral .composer-close { border-radius: 20px; } body.theme-modern .new-prompt-btn { border-radius: 8px; color: #fff; } body.theme-modern .composer-close { border-radius: 8px; border-width: 1px; backdrop-filter: blur(12px); background: var(--surface); } -body.theme-light .repipe-overlay, body.theme-reddit .repipe-overlay { background: rgba(0,0,0,0.3); } -body.theme-light .repipe-modal, body.theme-reddit .repipe-modal { background: var(--surface); border-color: var(--border); } -body.theme-light .repipe-text, body.theme-reddit .repipe-text { background: var(--bg); border-color: var(--border); color: var(--text); } -body.theme-light .repipe-btn, body.theme-reddit .repipe-btn { background: var(--bg); } -body.theme-light .repipe-btn.primary, body.theme-reddit .repipe-btn.primary { background: var(--accent); color: #fff; } -body.theme-light .repipe-mode, body.theme-reddit .repipe-mode { background: var(--bg); } -body.theme-light .repipe-mode.sel, body.theme-reddit .repipe-mode.sel { background: rgba(79,70,229,0.06); } -body.theme-reddit .repipe-modal { border-radius: 8px; } -body.theme-reddit .repipe-text { border-radius: 8px; } -body.theme-reddit .repipe-btn, body.theme-reddit .repipe-mode { border-radius: 20px; } -body.theme-reddit .repipe-mode.sel { background: rgba(255,69,0,0.06); color: var(--accent); border-color: var(--accent); } -body.theme-reddit .repipe-btn.primary { background: var(--accent); color: #fff; } +body.theme-light .repipe-overlay, body.theme-coral .repipe-overlay { background: rgba(0,0,0,0.3); } +body.theme-light .repipe-modal, body.theme-coral .repipe-modal { background: var(--surface); border-color: var(--border); } +body.theme-light .repipe-text, body.theme-coral .repipe-text { background: var(--bg); border-color: var(--border); color: var(--text); } +body.theme-light .repipe-btn, body.theme-coral .repipe-btn { background: var(--bg); } +body.theme-light .repipe-btn.primary, body.theme-coral .repipe-btn.primary { background: var(--accent); color: #fff; } +body.theme-light .repipe-mode, body.theme-coral .repipe-mode { background: var(--bg); } +body.theme-light .repipe-mode.sel, body.theme-coral .repipe-mode.sel { background: rgba(79,70,229,0.06); } +body.theme-coral .repipe-modal { border-radius: 8px; } +body.theme-coral .repipe-text { border-radius: 8px; } +body.theme-coral .repipe-btn, body.theme-coral .repipe-mode { border-radius: 20px; } +body.theme-coral .repipe-mode.sel { background: rgba(255,69,0,0.06); color: var(--accent); border-color: var(--accent); } +body.theme-coral .repipe-btn.primary { background: var(--accent); color: #fff; } body.theme-modern .repipe-overlay { background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); } body.theme-modern .repipe-modal { background: var(--surface); backdrop-filter: blur(24px); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.5); } body.theme-modern .repipe-text { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; } @@ -444,16 +444,16 @@ body.theme-modern ::-webkit-scrollbar-track { background: transparent; } THEME_JS = """ """ @@ -589,20 +598,22 @@ def security_headers(response): response.headers["Cross-Origin-Opener-Policy"] = "same-origin" response.headers["Content-Security-Policy"] = "default-src 'self'; script-src 'self' 'unsafe-inline' https://esm.sh; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self' https://esm.sh" response.headers["Permissions-Policy"] = "camera=(), microphone=(), geolocation=()" - # Theme injection + # Theme injection — applies to ALL HTML pages if response.content_type and "text/html" in response.content_type and response.status_code == 200: try: html = response.get_data(as_text=True) - if "" in html and "theme-light" not in html: - apply_script = '' - html = html.replace("", THEME_CSS + "\n", 1) - html = html.replace("", THEME_JS + "\n", 1) - # Toggle button - inject into header + if "" in html and "THEME_INJECTED" not in html: + apply_script = '' + # Inject CSS (inside style tags) + JS into head + html = html.replace("", "\n" + THEME_JS + "\n", 1) + # Inject toggle button into any header/nav found if '' in html: html = html.replace('', ' ' + THEME_TOGGLE_BTN + '\n', 1) - # Body script for early apply + elif '' in html: + html = html.replace('', ' ' + THEME_TOGGLE_BTN + '\n', 1) + # Early apply — runs before body renders to prevent flash if "" in html: html = html.replace("", "" + apply_script, 1) else: @@ -1881,6 +1892,78 @@ DB_DSN = "dbname=knowledge_base user=kbuser password=IPbLBA0EQI8u4TeM2YZrbm1OAy5 def get_db(): return psycopg2.connect(DB_DSN) +# ─── RESPONSE CACHE ────────────────────────────────────────── +# Caches the best-known response for each unique prompt+mode+models combo. +# Returns cached responses instantly on exact match. Updates when a better score arrives. +# Keeps full version history for training data export. + +def _cache_key(prompt, mode, models): + """Generate a deterministic cache key from prompt + mode + sorted model list.""" + # Normalize: lowercase prompt, sorted models, strip whitespace + normalized = f"{prompt.strip().lower()}|{mode}|{','.join(sorted(set(models)))}" + return hashlib.sha256(normalized.encode()).hexdigest()[:32] + + +def cache_lookup(prompt, mode, models): + """Check if we have a cached response for this exact request. + Returns: (cache_hit_dict, cache_key) or (None, cache_key) + """ + key = _cache_key(prompt, mode, models) + try: + with get_db() as conn: + with conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur: + cur.execute( + "UPDATE response_cache SET hit_count = hit_count + 1 WHERE cache_key = %s RETURNING *", + (key,) + ) + row = cur.fetchone() + conn.commit() + if row and row.get("responses"): + return dict(row), key + except Exception as e: + print(f"[CACHE] lookup error: {e}") + return None, key + + +def cache_store(cache_key, prompt, mode, models, run_id, score, responses): + """Store or update cache. Only replaces if new score is better (or no existing entry).""" + try: + with get_db() as conn: + with conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur: + # Check existing + cur.execute("SELECT best_score FROM response_cache WHERE cache_key = %s", (cache_key,)) + existing = cur.fetchone() + + # Always record in history + cur.execute( + "INSERT INTO response_cache_history (cache_key, run_id, score, responses, models_used) VALUES (%s,%s,%s,%s,%s)", + (cache_key, run_id, score, json.dumps(responses), list(set(models))) + ) + + if existing is None: + # New entry + cur.execute( + """INSERT INTO response_cache (cache_key, prompt, mode, models_used, best_run_id, best_score, responses) + VALUES (%s,%s,%s,%s,%s,%s,%s)""", + (cache_key, prompt, mode, list(set(models)), run_id, score, json.dumps(responses)) + ) + print(f"[CACHE] NEW key={cache_key[:12]} mode={mode} score={score} run={run_id}") + elif score is not None and (existing["best_score"] is None or score > existing["best_score"]): + # Better score — update cache + cur.execute( + """UPDATE response_cache SET best_run_id=%s, best_score=%s, responses=%s, updated_at=NOW() + WHERE cache_key=%s""", + (run_id, score, json.dumps(responses), cache_key) + ) + print(f"[CACHE] UPGRADED key={cache_key[:12]} score {existing['best_score']}->{score} run={run_id}") + else: + print(f"[CACHE] KEPT key={cache_key[:12]} existing={existing['best_score']} new={score}") + + conn.commit() + except Exception as e: + print(f"[CACHE] store error: {e}") + + def save_run(mode, prompt, config_data, responses): models = list({r.get("model", "") for r in responses if r.get("model")}) run_id = None @@ -1896,10 +1979,30 @@ def save_run(mode, prompt, config_data, responses): except Exception as e: print(f"[DB] save_run error: {e}") if run_id and responses: - threading.Thread(target=_auto_score_run, args=(run_id, mode, prompt, responses), daemon=True).start() + # Auto-score, then update cache with the score + cache_key = _cache_key(prompt, mode, models) + threading.Thread(target=_auto_score_and_cache, args=(run_id, mode, prompt, responses, models, cache_key), daemon=True).start() return run_id +def _auto_score_and_cache(run_id, mode, prompt, responses, models, cache_key): + """Score the run, then update the cache if this score is the best.""" + _auto_score_run(run_id, mode, prompt, responses) + # Fetch the score that was just written + score = None + try: + with get_db() as conn: + with conn.cursor() as cur: + cur.execute("SELECT quality_score FROM team_runs WHERE id = %s", (run_id,)) + row = cur.fetchone() + if row: + score = row[0] + except Exception: + pass + # Update cache + cache_store(cache_key, prompt, mode, models, run_id, score, responses) + + # ─── AUTO-SCORING ENGINE ───────────────────────────────────── _SCORE_MODEL = "qwen2.5:latest" @@ -1988,6 +2091,7 @@ HTML = r""" header .badge .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: middle; box-shadow: 0 0 8px var(--green); animation: pulse-dot 2s ease-in-out infinite; } @keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } } .grid { display: grid; grid-template-columns: 420px 1fr; gap: 18px; align-items: start; } + .grid > .panel:last-child { position: sticky; top: 20px; } .panel { background: var(--surface); border: 2px solid var(--border); border-radius: 2px; padding: 20px; backdrop-filter: blur(16px); position: relative; } .panel::before { content: ''; position: absolute; top: -1px; left: 16px; right: 16px; height: 1px; background: linear-gradient(90deg, transparent, rgba(226,181,90,0.15), transparent); } .panel h2 { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: var(--text2); margin-bottom: 14px; font-weight: 600; } @@ -2048,12 +2152,58 @@ HTML = r""" .run-btn:active { transform: translateY(0); } .run-btn:disabled { opacity: 0.3; cursor: not-allowed; filter: none; transform: none; box-shadow: none; } .run-btn { margin-bottom: 8px; } - .output-area { display: flex; flex-direction: column; gap: 10px; padding-bottom: 40px; } - .output-card { background: rgba(0,0,0,0.25); border: 2px solid var(--border); border-radius: 2px; overflow: hidden; backdrop-filter: blur(8px); } + .output-area { display: flex; flex-direction: column; gap: 4px; padding-bottom: 20px; max-height: calc(100vh - 160px); overflow-y: auto; scroll-behavior: smooth; } + .output-card { background: rgba(0,0,0,0.25); border: 2px solid var(--border); border-radius: 2px; overflow: hidden; backdrop-filter: blur(8px); flex-shrink: 0; animation: card-arrive 0.4s ease-out both; } + @keyframes card-arrive { from { opacity:0; transform: translateY(16px) scale(0.98); } to { opacity:1; transform: translateY(0) scale(1); } } + .output-card .card-body { position: relative; } + /* Rendered markdown — polished editorial typography */ + .card-body.md-rendered { white-space: normal !important; font-size: 13px; line-height: 1.7; padding: 16px 22px; font-family: 'Inter', -apple-system, sans-serif; color: var(--text); letter-spacing: -0.01em; } + .card-body.md-rendered * { white-space: normal; } + .card-body.md-rendered pre, .card-body.md-rendered pre * { white-space: pre-wrap !important; } + .card-body.md-rendered > *:first-child { margin-top: 0; } + .card-body.md-rendered > *:last-child { margin-bottom: 0; } + .card-body.md-rendered h1 { font-size: 15px; font-weight: 700; margin: 18px 0 6px; color: var(--accent); letter-spacing: 0; } + .card-body.md-rendered h2 { font-size: 13px; font-weight: 700; margin: 16px 0 4px; color: var(--text); letter-spacing: 0.02em; text-transform: uppercase; font-size: 11px; } + .card-body.md-rendered h3 { font-size: 13px; font-weight: 700; margin: 12px 0 3px; color: var(--text); } + .card-body.md-rendered h4, .card-body.md-rendered h5, .card-body.md-rendered h6 { font-size: 12px; font-weight: 600; margin: 10px 0 3px; color: var(--text2); } + .card-body.md-rendered p { margin: 4px 0; } + .card-body.md-rendered ul, .card-body.md-rendered ol { margin: 2px 0; padding-left: 22px; } + .card-body.md-rendered ol { list-style: none; counter-reset: li; padding-left: 0; } + .card-body.md-rendered ol > li { counter-increment: li; padding-left: 24px; position: relative; } + .card-body.md-rendered ol > li::before { content: counter(li); position: absolute; left: 0; width: 18px; text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--accent); top: 1px; } + .card-body.md-rendered ul { list-style: none; padding-left: 0; } + .card-body.md-rendered ul > li { padding-left: 16px; position: relative; } + .card-body.md-rendered ul > li::before { content: ''; position: absolute; left: 3px; top: 8px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: 0.6; } + .card-body.md-rendered li { margin: 1px 0; line-height: 1.5; } + .card-body.md-rendered li > p { margin: 0; display: inline; } + .card-body.md-rendered li > ul, .card-body.md-rendered li > ol { margin: 1px 0; } + .card-body.md-rendered li > ul > li::before { width: 3px; height: 3px; top: 8px; background: var(--text2); opacity: 0.4; } + .card-body.md-rendered strong { color: #fff; font-weight: 600; } + .card-body.md-rendered em { color: var(--text2); font-style: italic; } + .card-body.md-rendered code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 3px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: #c084fc; } + .card-body.md-rendered pre { background: rgba(0,0,0,0.35); border: 1px solid var(--border); border-radius: 4px; padding: 10px 14px; margin: 10px 0; overflow-x: auto; } + .card-body.md-rendered pre code { background: none; padding: 0; color: var(--text); font-size: 12px; line-height: 1.5; } + .card-body.md-rendered blockquote { border-left: 3px solid var(--accent); margin: 10px 0; padding: 6px 14px; color: var(--text2); background: rgba(226,181,90,0.02); border-radius: 0 4px 4px 0; font-style: italic; } + .card-body.md-rendered table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 12px; } + .card-body.md-rendered th { background: rgba(0,0,0,0.25); padding: 6px 12px; text-align: left; border: 1px solid var(--border); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); } + .card-body.md-rendered td { padding: 5px 12px; border: 1px solid var(--border); } + .card-body.md-rendered tr:nth-child(even) td { background: rgba(0,0,0,0.08); } + .card-body.md-rendered hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; } + .card-body.md-rendered a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(226,181,90,0.2); } + .card-body.md-rendered a:hover { border-bottom-color: var(--accent); } + .card-hero-wrap { position: relative; overflow: hidden; background: rgba(0,0,0,0.15); } + .card-hero-loading { padding: 6px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text2); } + .card-hero-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 8px; background: linear-gradient(transparent, rgba(0,0,0,0.7)); font-size: 8px; color: var(--text2); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.5px; opacity: 0; transition: opacity 0.2s; } + .card-hero-wrap:hover .card-hero-label { opacity: 1; } + .output-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; } + .phase-label { animation: phase-enter 0.5s ease-out both; } + @keyframes phase-enter { from { opacity:0; transform: translateX(-20px); } to { opacity:0.8; transform: translateX(0); } } + .output-card.synthesis-card { animation: card-arrive 0.4s ease-out both, synth-glow 2s ease-in-out 0.5s; } + @keyframes synth-glow { 0%{box-shadow:0 0 0 rgba(226,181,90,0)} 50%{box-shadow:0 0 30px rgba(226,181,90,0.15),0 0 60px rgba(226,181,90,0.05)} 100%{box-shadow:0 0 0 rgba(226,181,90,0)} } .output-card .card-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 2px solid var(--border); font-size: 12px; font-weight: 600; font-family: 'JetBrains Mono', monospace; } .output-card .card-header .dot { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; } .output-card .card-header .role-tag { margin-left: auto; font-size: 9px; font-weight: 600; color: var(--text2); background: rgba(0,0,0,0.4); padding: 2px 8px; border-radius: 1px; border: 1px solid var(--border); text-transform: uppercase; letter-spacing: 1px; font-family: 'JetBrains Mono', monospace; } - .output-card .card-body { padding: 14px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; max-height: 500px; overflow-y: auto; } + .output-card .card-body { padding: 14px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; } .synthesis-card { border-color: var(--accent); } .synthesis-card .card-header { background: var(--glow); } .synthesis-card::before { content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 1px; background: var(--accent); opacity: 0.3; } @@ -2067,24 +2217,34 @@ HTML = r""" .status-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(0,0,0,0.3); border: 2px solid var(--border); border-radius: 2px; font-size: 11px; color: var(--text2); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 0.5px; } .spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } - .progress-panel { background: rgba(8,9,12,0.97); border: 2px solid #d946ef; border-radius: 2px; padding: 12px 14px; position: sticky; top: 0; z-index: 50; backdrop-filter: blur(20px); margin-bottom: 10px; transition: opacity 2s, box-shadow 0.3s; box-shadow: 0 4px 24px rgba(217,70,239,0.15), 0 0 40px rgba(0,0,0,0.5); } - .progress-panel.done { border-color: #4ade80; box-shadow: 0 2px 16px rgba(74,222,128,0.15); } - .progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; } + /* Progress panel — fixed above output, not inside scroll */ + .progress-panel { background: rgba(8,9,12,0.97); border: 1px solid #d946ef; border-radius: 2px; padding: 4px 14px; position: fixed; top: 50px; left: 50%; transform: translateX(-50%); width: calc(100% - 20px); max-width: 800px; z-index: 200; backdrop-filter: blur(20px); box-shadow: 0 2px 12px rgba(217,70,239,0.1); max-height: 28px; overflow: hidden; transition: max-height 0.35s ease, padding 0.35s ease, box-shadow 0.3s, border-color 0.3s, opacity 2s; cursor: pointer; } + .progress-panel:hover, .progress-panel.expanded { max-height: 300px; padding: 12px 14px; box-shadow: 0 4px 24px rgba(217,70,239,0.15), 0 0 40px rgba(0,0,0,0.5); } + .progress-panel.done { border-color: #4ade80; box-shadow: 0 2px 8px rgba(74,222,128,0.1); } + .progress-panel.done:hover { box-shadow: 0 2px 16px rgba(74,222,128,0.15); } + /* Collapsed: only show header + track in a thin bar */ + .progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; } + .progress-panel:hover .progress-header, .progress-panel.expanded .progress-header { margin-bottom: 8px; } .progress-header .prog-mode { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #d946ef; font-weight: 700; } .progress-header .prog-time { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #f0abfc; letter-spacing: 0.5px; } - .progress-track { height: 8px; background: rgba(0,0,0,0.5); border: 1px solid rgba(217,70,239,0.3); border-radius: 2px; overflow: hidden; margin-bottom: 6px; } + .progress-track { height: 4px; background: rgba(0,0,0,0.5); border: 1px solid rgba(217,70,239,0.3); border-radius: 2px; overflow: hidden; margin-bottom: 0; transition: height 0.3s, margin-bottom 0.3s; } + .progress-panel:hover .progress-track, .progress-panel.expanded .progress-track { height: 8px; margin-bottom: 6px; } .progress-fill { height: 100%; background: linear-gradient(90deg, #d946ef, #a855f7, #22d3ee); transition: width 0.4s ease; box-shadow: 0 0 14px rgba(217,70,239,0.4); position: relative; } .progress-fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 60%, rgba(255,255,255,0.2)); animation: progress-shimmer 2s ease-in-out infinite; } @keyframes progress-shimmer { 0%,100% { transform: translateX(-100%); } 50% { transform: translateX(100%); } } - .progress-steps { display: flex; gap: 4px; margin-bottom: 6px; } + /* Steps, detail, metrics — hidden when collapsed */ + .progress-steps { display: flex; gap: 4px; margin-bottom: 6px; opacity: 0; max-height: 0; overflow: hidden; transition: opacity 0.3s, max-height 0.3s; } + .progress-panel:hover .progress-steps, .progress-panel.expanded .progress-steps { opacity: 1; max-height: 20px; } .progress-step { flex: 1; height: 4px; background: rgba(217,70,239,0.15); border-radius: 1px; transition: background 0.3s; } .progress-step.done { background: linear-gradient(90deg, #d946ef, #4ade80); } .progress-step.active { background: #d946ef; animation: step-pulse 1s ease-in-out infinite; box-shadow: 0 0 6px rgba(217,70,239,0.4); } @keyframes step-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } } - .progress-detail { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #e0b0ff; display: flex; justify-content: space-between; } + .progress-detail { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #e0b0ff; display: flex; justify-content: space-between; opacity: 0; max-height: 0; overflow: hidden; transition: opacity 0.3s, max-height 0.3s; } + .progress-panel:hover .progress-detail, .progress-panel.expanded .progress-detail { opacity: 1; max-height: 30px; } .progress-detail .prog-substep { max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .progress-detail .prog-stats { color: #c084fc; opacity: 0.7; } - .prog-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(217,70,239,0.15); } + .prog-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(217,70,239,0.15); opacity: 0; max-height: 0; overflow: hidden; transition: opacity 0.3s 0.1s, max-height 0.3s 0.1s; } + .progress-panel:hover .prog-metrics, .progress-panel.expanded .prog-metrics { opacity: 1; max-height: 120px; } .prog-metric { text-align: center; padding: 4px 2px; } .prog-metric .mv { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: #f0abfc; line-height: 1; } .prog-metric .ml { font-family: 'JetBrains Mono', monospace; font-size: 7px; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(217,70,239,0.5); margin-top: 3px; } @@ -2095,14 +2255,25 @@ HTML = r""" .phase-label::before { content: ''; flex: 0 0 12px; height: 2px; background: #4ade80; opacity: 0.6; } .phase-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(74,222,128,0.3), transparent); } .sample-prompts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; } - .sample-chip { background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 2px; padding: 6px 12px; font-size: 11px; color: var(--text2); cursor: pointer; transition: all 0.15s; line-height: 1.4; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } - .sample-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--glow); } + .sample-chip { background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 2px; padding: 6px 12px; font-size: 11px; color: var(--text2); cursor: pointer; transition: all 0.35s ease; line-height: 1.4; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; } + .sample-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--glow); transform: translateY(-1px); } .sample-chip .chip-level { font-size: 8px; font-weight: 700; text-transform: uppercase; margin-right: 6px; opacity: 0.5; font-family: 'JetBrains Mono', monospace; letter-spacing: 1px; } + /* Chip animations */ + .sample-chip-enter { animation: chip-enter 0.4s ease-out both; } + @keyframes chip-enter { from { opacity:0; transform: translateY(10px) scale(0.92); filter: blur(4px); } to { opacity:1; transform: translateY(0) scale(1); filter: blur(0); } } + .chip-exit { animation: chip-exit 0.3s ease-in both; pointer-events: none; } + @keyframes chip-exit { from { opacity:1; transform: translateY(0) scale(1); } to { opacity:0; transform: translateY(-12px) scale(0.9); filter: blur(3px); } } + .chip-swap { animation: chip-swap 0.45s ease-out both; } + @keyframes chip-swap { 0% { opacity:0; transform: translateX(20px) scale(0.9); filter: blur(6px); } 40% { opacity:0.5; filter: blur(2px); } 100% { opacity:1; transform: translateX(0) scale(1); filter: blur(0); } } + .sample-chip .chip-shuffle { display: inline-block; font-size: 9px; opacity: 0; margin-left: 4px; transition: opacity 0.2s; color: var(--accent); vertical-align: middle; } + .sample-chip:hover .chip-shuffle { opacity: 0.6; } .empty-state { text-align: center; padding: 120px 20px; color: var(--text2); } .empty-state .icon { font-size: 28px; margin-bottom: 16px; opacity: 0.15; letter-spacing: 8px; } .empty-state p { font-size: 12px; line-height: 1.6; max-width: 280px; margin: 0 auto; font-family: 'JetBrains Mono', monospace; } .empty-state p strong { color: var(--accent); font-weight: 600; } - .output-area { min-height: 400px; } + .output-area::-webkit-scrollbar { width: 5px; } + .output-area::-webkit-scrollbar-thumb { background: rgba(226,181,90,0.15); border-radius: 4px; } + .output-area::-webkit-scrollbar-thumb:hover { background: rgba(226,181,90,0.3); } .mode-desc { background: rgba(0,0,0,0.25); border-left: 2px solid var(--accent); border-radius: 0; padding: 10px 14px; font-size: 11px; color: var(--text2); margin-bottom: 14px; line-height: 1.5; font-family: 'JetBrains Mono', monospace; } .left-scroll { max-height: calc(100vh - 72px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; } ::-webkit-scrollbar { width: 6px; height: 6px; } @@ -2124,13 +2295,25 @@ HTML = r""" .composer-close { display: none; position: fixed; top: 16px; right: 20px; z-index: 110; background: none; border: 2px solid var(--border); border-radius: 2px; color: var(--text2); font-size: 18px; width: 32px; height: 32px; cursor: pointer; font-family: 'JetBrains Mono', monospace; transition: all 0.15s; line-height: 1; } .composer-close:hover { border-color: var(--accent); color: var(--accent); } .composer-active .composer-close { display: block; } - /* Output-focused mode (after run) */ + /* Output-focused mode — full screen output, no left panel */ .output-focused .grid { grid-template-columns: 1fr; } .output-focused .left-scroll { display: none; } - .output-focused .grid > .panel:last-child { width: 100%; } - .new-prompt-btn { display: none; z-index: 90; background: var(--accent); color: #08090c; border: none; border-radius: 2px; padding: 5px 14px; font-size: 10px; font-weight: 700; cursor: pointer; font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 1px; transition: all 0.2s; } + .container.output-focused { max-width: none !important; padding: 0 4px !important; } + .container.output-focused .grid { gap: 0 !important; } + .container.output-focused .grid > .panel:last-child, + body.theme-modern .container.output-focused .grid > .panel:last-child, + body.theme-light .container.output-focused .grid > .panel:last-child, + body.theme-coral .container.output-focused .grid > .panel:last-child { + width: 100% !important; max-width: none !important; margin: 0 !important; + padding: 0 !important; border: none !important; background: transparent !important; + backdrop-filter: none !important; border-radius: 0 !important; box-shadow: none !important; + } + .container.output-focused .grid > .panel:last-child::before { display: none !important; } + .container.output-focused .grid > .panel:last-child > h2 { display: none !important; } + .container.output-focused .output-area { gap: 3px; padding: 0; max-height: calc(100vh - 80px); } + .container.output-focused .output-card { border-radius: 0; border-left: none; border-right: none; margin: 0; } + .new-prompt-btn { z-index: 90; background: var(--accent); color: #08090c; border: none; border-radius: 2px; padding: 5px 14px; font-size: 10px; font-weight: 700; cursor: pointer; font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 1px; transition: all 0.2s; } .new-prompt-btn:hover { opacity: 0.85; } - .output-focused .new-prompt-btn { display: inline-block; } /* Theme adjustments for composer */ @media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .composer-active .left-scroll { padding: 40px 12px 30px; } } @media (max-width: 768px) { .m-toggle { display: flex; } .m-collapse { display: none !important; } .m-collapse.open { display: block !important; } .composer-active .left-scroll { padding: 30px 10px 20px; } } @@ -2231,7 +2414,8 @@ HTML = r"""

LLM Team

0 models