Spaces:
Runtime error
Runtime error
Download app.py from Krsnapriya/CodeReviewEnv-Elite: direct link, hf CLI and curl.
- Browser
- Download file 3.49 kB
-
https://huggingface.co/spaces/Krsnapriya/CodeReviewEnv-Elite/resolve/main/app.py
- Command line
-
hf download hf://spaces/Krsnapriya/CodeReviewEnv-Elite/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Krsnapriya/CodeReviewEnv-Elite/resolve/main/app.py
3.49 kB
| import streamlit as st # pyre-ignore | |
| import numpy as np | |
| import time | |
| from models import Action # pyre-ignore | |
| from server.env import DebugOpsEnv # pyre-ignore | |
| from run_baseline import random_agent, heuristic_agent # pyre-ignore | |
| st.set_page_config(page_title="DebugOps-RX", page_icon="🐞", layout="wide") | |
| st.title("🐞 DebugOps-RX Benchmark") | |
| st.markdown("Evaluating LLM Agents in Real-World Debugging Uncertainty. **[Train, Test, OOD]** Splits.") | |
| tab1, tab2 = st.tabs(["🏆 Leaderboard", "▶️ Live Agent Run"]) | |
| # ── Leaderboard ── | |
| with tab1: | |
| st.subheader("Leaderboard (Mean Score ± Std over 5 Seeds)") | |
| # We display statically calculated tables from our run_baseline.py outputs for instant viewing | |
| st.markdown(""" | |
| ### 🟢 Train Split | |
| | Agent | Easy | Medium | Hard | Extreme | | |
| |---|---|---|---|---| | |
| | **Heuristic** | 0.77 ± 0.01 | 0.18 ± 0.01 | 0.23 ± 0.00 | 0.79 ± 0.00 | | |
| | **Random** | 0.07 ± 0.06 | 0.04 ± 0.06 | 0.02 ± 0.03 | 0.00 ± 0.01 | | |
| ### 🔴 OOD Split | |
| | Agent | Easy | Medium | Hard | Extreme | | |
| |---|---|---|---|---| | |
| | **Heuristic** | 0.78 ± 0.01 | 0.18 ± 0.01 | 0.23 ± 0.00 | 0.79 ± 0.00 | | |
| | **Random** | 0.07 ± 0.05 | 0.03 ± 0.06 | 0.02 ± 0.03 | 0.00 ± 0.01 | | |
| """) | |
| # ── Live Run ── | |
| with tab2: | |
| st.subheader("Live Evaluation") | |
| col1, col2, col3 = st.columns(3) | |
| agent_sel = col1.selectbox("🤖 Select Agent", ["Heuristic", "Random"]) | |
| diff_sel = col2.selectbox("🔥 Difficulty", ["easy", "medium", "hard", "extreme"]) | |
| split_sel = col3.selectbox("🔀 Split", ["train", "test", "ood"]) | |
| if st.button("🚀 Run Agent", use_container_width=True): | |
| agent_fn = heuristic_agent if agent_sel == "Heuristic" else random_agent | |
| env = DebugOpsEnv(seed=42) | |
| try: | |
| obs = env.reset(difficulty=diff_sel, split=split_sel) | |
| except Exception as e: | |
| st.error(f"Error loading task: {e}") | |
| st.stop() | |
| st.info(f"Loaded Task. Bug: `{env.hidden.bug_type}` | Noise (η): `{env.hidden.eta:.2f}` | Drift (δ): `{env.hidden.delta:.2f}`") | |
| trajectory = [] | |
| done = False | |
| step_count = 0 | |
| log_container = st.container() | |
| with log_container: | |
| for step_count in range(30): | |
| if done: break | |
| action = agent_fn(obs) | |
| obs, reward, done, info = env.step(action) | |
| trajectory.append(action) | |
| target = action.target or "N/A" | |
| if action.type == "analyze_logs": | |
| st.toast(f"Step {step_count+1}: Extracted Logs") | |
| st.text(f"Action: {action.type} -> Observes:\n{obs.logs}") | |
| else: | |
| st.text(f"Step {step_count+1} | Action: {action.type} | Target: {target} | Reward: {reward}") | |
| time.sleep(0.1) # UI delay for live effect | |
| score = env.grade(trajectory) | |
| st.success(f"✅ Episode Finished in {step_count} steps.") | |
| c1, c2, c3, c4, c5 = st.columns(5) | |
| c1.metric("Correctness", f"{score.correctness:.2f}") | |
| c2.metric("Efficiency", f"{score.efficiency:.2f}") | |
| c3.metric("Reasoning", f"{score.reasoning_quality:.2f}") | |
| c4.metric("Robustness", f"{score.robustness:.2f}") | |
| c5.metric("🎯 Final Score", f"{score.final():.3f}") | |