Spaces:
Running
Running
Commit ·
e1f5917
1
Parent(s): bef4051
testing
Browse files- OpenEnv +1 -0
- __pycache__/models.cpython-310.pyc +0 -0
- server/__pycache__/__init__.cpython-310.pyc +0 -0
- server/__pycache__/app.cpython-310.pyc +0 -0
- server/__pycache__/environment.cpython-310.pyc +0 -0
- server/app.py +7 -0
- server/graders/__pycache__/__init__.cpython-310.pyc +0 -0
- server/graders/__pycache__/grader_easy.cpython-310.pyc +0 -0
- server/graders/__pycache__/grader_hard.cpython-310.pyc +0 -0
- server/graders/__pycache__/grader_medium.cpython-310.pyc +0 -0
- server/static/index.html +132 -70
- server/tasks/__pycache__/__init__.cpython-310.pyc +0 -0
- server/tasks/__pycache__/task_easy.cpython-310.pyc +0 -0
- server/tasks/__pycache__/task_hard.cpython-310.pyc +0 -0
- server/tasks/__pycache__/task_medium.cpython-310.pyc +0 -0
OpenEnv
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit c719decf2b19175d5ca35301d58a14c83e985480
|
__pycache__/models.cpython-310.pyc
ADDED
|
Binary file (2.74 kB). View file
|
|
|
server/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (163 Bytes). View file
|
|
|
server/__pycache__/app.cpython-310.pyc
ADDED
|
Binary file (4.58 kB). View file
|
|
|
server/__pycache__/environment.cpython-310.pyc
ADDED
|
Binary file (3.63 kB). View file
|
|
|
server/app.py
CHANGED
|
@@ -9,6 +9,8 @@ from pydantic import BaseModel
|
|
| 9 |
|
| 10 |
from server.environment import CodeDebugEnvironment
|
| 11 |
from models import DebugAction, DebugObservation, DebugState
|
|
|
|
|
|
|
| 12 |
|
| 13 |
app = FastAPI(
|
| 14 |
title="Code Debug Environment",
|
|
@@ -29,6 +31,11 @@ app.add_middleware(
|
|
| 29 |
# One global environment instance (single session)
|
| 30 |
# For concurrent sessions, instantiate per-request with a session dict
|
| 31 |
env = CodeDebugEnvironment()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
# ─── Request Models ─────────────────────────────────────────────────────────
|
|
|
|
| 9 |
|
| 10 |
from server.environment import CodeDebugEnvironment
|
| 11 |
from models import DebugAction, DebugObservation, DebugState
|
| 12 |
+
from fastapi.responses import HTMLResponse
|
| 13 |
+
import os
|
| 14 |
|
| 15 |
app = FastAPI(
|
| 16 |
title="Code Debug Environment",
|
|
|
|
| 31 |
# One global environment instance (single session)
|
| 32 |
# For concurrent sessions, instantiate per-request with a session dict
|
| 33 |
env = CodeDebugEnvironment()
|
| 34 |
+
@app.get("/", response_class=HTMLResponse)
|
| 35 |
+
async def root():
|
| 36 |
+
html_path = os.path.join(os.path.dirname(__file__), "static", "index.html")
|
| 37 |
+
with open(html_path, "r") as f:
|
| 38 |
+
return f.read()
|
| 39 |
|
| 40 |
|
| 41 |
# ─── Request Models ─────────────────────────────────────────────────────────
|
server/graders/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (349 Bytes). View file
|
|
|
server/graders/__pycache__/grader_easy.cpython-310.pyc
ADDED
|
Binary file (2.89 kB). View file
|
|
|
server/graders/__pycache__/grader_hard.cpython-310.pyc
ADDED
|
Binary file (2.53 kB). View file
|
|
|
server/graders/__pycache__/grader_medium.cpython-310.pyc
ADDED
|
Binary file (746 Bytes). View file
|
|
|
server/static/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
<style>
|
| 8 |
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 9 |
body { font-family: system-ui, sans-serif; background: #0f1117; color: #e0e0e0; min-height: 100vh; padding: 2rem 1rem; }
|
| 10 |
-
.container { max-width:
|
| 11 |
.header { text-align: center; margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid #2a2a3a; }
|
| 12 |
.badge { display: inline-block; background: #1e3a5f; color: #60a5fa; font-size: 12px; padding: 4px 12px; border-radius: 20px; margin-bottom: 1rem; }
|
| 13 |
h1 { font-size: 2rem; font-weight: 600; color: #ffffff; margin-bottom: 0.5rem; }
|
|
@@ -21,6 +21,38 @@
|
|
| 21 |
.stat-value { font-size: 1.8rem; font-weight: 700; color: #60a5fa; }
|
| 22 |
.stat-label { font-size: 12px; color: #6b7280; margin-top: 4px; }
|
| 23 |
.section-title { font-size: 13px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
.endpoints { display: flex; flex-direction: column; gap: 10px; margin-bottom: 2rem; }
|
| 25 |
.endpoint { background: #1a1a2e; border: 1px solid #2a2a3a; border-radius: 10px; padding: 1rem 1.25rem; display: flex; align-items: center; gap: 12px; text-decoration: none; transition: border-color 0.2s; }
|
| 26 |
.endpoint:hover { border-color: #3b82f6; }
|
|
@@ -39,7 +71,7 @@
|
|
| 39 |
.diff-name.hard { color: #ef4444; }
|
| 40 |
.diff-detail { font-size: 12px; color: #6b7280; line-height: 1.5; }
|
| 41 |
.footer { text-align: center; padding-top: 1.5rem; border-top: 1px solid #2a2a3a; }
|
| 42 |
-
.docs-btn { display: inline-block; background: #1e3a5f; color: #60a5fa; padding: 10px 24px; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 500;
|
| 43 |
.docs-btn:hover { background: #2a4a7f; }
|
| 44 |
</style>
|
| 45 |
</head>
|
|
@@ -49,90 +81,120 @@
|
|
| 49 |
<div class="badge">OpenEnv Compatible</div>
|
| 50 |
<h1>Code Debug Environment</h1>
|
| 51 |
<p class="subtitle">An RL environment where LLM agents diagnose and fix buggy Python code</p>
|
| 52 |
-
<div class="status-bar">
|
| 53 |
-
<div class="dot"></div>
|
| 54 |
-
<span class="status-text">Live & Running</span>
|
| 55 |
-
</div>
|
| 56 |
</div>
|
| 57 |
|
| 58 |
<div class="stats">
|
| 59 |
-
<div class="stat">
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
</div>
|
| 63 |
-
<div class="
|
| 64 |
-
|
| 65 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
</div>
|
| 67 |
-
<div class="
|
| 68 |
-
|
| 69 |
-
<div class="
|
|
|
|
|
|
|
| 70 |
</div>
|
| 71 |
</div>
|
| 72 |
|
| 73 |
<div class="section-title">API Endpoints</div>
|
| 74 |
<div class="endpoints">
|
| 75 |
-
<a class="endpoint" href="/health">
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
</div>
|
| 81 |
-
<span class="arrow">→</span>
|
| 82 |
-
</a>
|
| 83 |
-
<a class="endpoint" href="/docs#/default/reset_reset_post">
|
| 84 |
-
<span class="method post">POST</span>
|
| 85 |
-
<div class="endpoint-info">
|
| 86 |
-
<div class="endpoint-path">/reset</div>
|
| 87 |
-
<div class="endpoint-desc">Start a new episode — pass difficulty: easy | medium | hard</div>
|
| 88 |
-
</div>
|
| 89 |
-
<span class="arrow">→</span>
|
| 90 |
-
</a>
|
| 91 |
-
<a class="endpoint" href="/docs#/default/step_step_post">
|
| 92 |
-
<span class="method post">POST</span>
|
| 93 |
-
<div class="endpoint-info">
|
| 94 |
-
<div class="endpoint-path">/step</div>
|
| 95 |
-
<div class="endpoint-desc">Submit fixed code — returns reward (0.0–1.0) and feedback</div>
|
| 96 |
-
</div>
|
| 97 |
-
<span class="arrow">→</span>
|
| 98 |
-
</a>
|
| 99 |
-
<a class="endpoint" href="/state">
|
| 100 |
-
<span class="method get">GET</span>
|
| 101 |
-
<div class="endpoint-info">
|
| 102 |
-
<div class="endpoint-path">/state</div>
|
| 103 |
-
<div class="endpoint-desc">Current episode state — step count, reward, done flag</div>
|
| 104 |
-
</div>
|
| 105 |
-
<span class="arrow">→</span>
|
| 106 |
-
</a>
|
| 107 |
-
<a class="endpoint" href="/tasks">
|
| 108 |
-
<span class="method get">GET</span>
|
| 109 |
-
<div class="endpoint-info">
|
| 110 |
-
<div class="endpoint-path">/tasks</div>
|
| 111 |
-
<div class="endpoint-desc">List all 45 task IDs across all difficulty levels</div>
|
| 112 |
-
</div>
|
| 113 |
-
<span class="arrow">→</span>
|
| 114 |
-
</a>
|
| 115 |
</div>
|
| 116 |
|
| 117 |
<div class="section-title">Difficulty Levels</div>
|
| 118 |
<div class="difficulties">
|
| 119 |
-
<div class="diff">
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
</div>
|
| 123 |
-
<div class="diff">
|
| 124 |
-
<div class="diff-name medium">Medium</div>
|
| 125 |
-
<div class="diff-detail">15 tasks<br>2 bugs per task<br>reward = tests passed / 3</div>
|
| 126 |
-
</div>
|
| 127 |
-
<div class="diff">
|
| 128 |
-
<div class="diff-name hard">Hard</div>
|
| 129 |
-
<div class="diff-detail">15 tasks<br>algorithmic bug<br>reward = 0.7×code + 0.3×explanation</div>
|
| 130 |
-
</div>
|
| 131 |
</div>
|
| 132 |
|
| 133 |
-
<div class="footer">
|
| 134 |
-
<a class="docs-btn" href="/docs">Open Interactive API Docs</a>
|
| 135 |
-
</div>
|
| 136 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
</body>
|
| 138 |
</html>
|
|
|
|
| 7 |
<style>
|
| 8 |
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 9 |
body { font-family: system-ui, sans-serif; background: #0f1117; color: #e0e0e0; min-height: 100vh; padding: 2rem 1rem; }
|
| 10 |
+
.container { max-width: 860px; margin: 0 auto; }
|
| 11 |
.header { text-align: center; margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid #2a2a3a; }
|
| 12 |
.badge { display: inline-block; background: #1e3a5f; color: #60a5fa; font-size: 12px; padding: 4px 12px; border-radius: 20px; margin-bottom: 1rem; }
|
| 13 |
h1 { font-size: 2rem; font-weight: 600; color: #ffffff; margin-bottom: 0.5rem; }
|
|
|
|
| 21 |
.stat-value { font-size: 1.8rem; font-weight: 700; color: #60a5fa; }
|
| 22 |
.stat-label { font-size: 12px; color: #6b7280; margin-top: 4px; }
|
| 23 |
.section-title { font-size: 13px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
|
| 24 |
+
.tester { background: #1a1a2e; border: 1px solid #2a2a3a; border-radius: 12px; padding: 1.5rem; margin-bottom: 2rem; }
|
| 25 |
+
.tester-title { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 1.2rem; }
|
| 26 |
+
.select-row { display: flex; gap: 10px; margin-bottom: 1rem; align-items: center; }
|
| 27 |
+
select { background: #0f1117; color: #e0e0e0; border: 1px solid #3a3a5a; border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer; flex: 1; outline: none; }
|
| 28 |
+
select:hover { border-color: #60a5fa; }
|
| 29 |
+
.btn { padding: 9px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; }
|
| 30 |
+
.btn-blue { background: #1e3a5f; color: #60a5fa; border: 1px solid #2a4a7f; }
|
| 31 |
+
.btn-blue:hover { background: #2a4a7f; }
|
| 32 |
+
.btn-green { background: #0d3321; color: #22c55e; border: 1px solid #1a5a3a; }
|
| 33 |
+
.btn-green:hover { background: #1a5a3a; }
|
| 34 |
+
.task-box { background: #0f1117; border: 1px solid #2a2a3a; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; display: none; }
|
| 35 |
+
.task-box.visible { display: block; }
|
| 36 |
+
.task-meta { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
|
| 37 |
+
.tag { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
|
| 38 |
+
.tag-easy { background: #0d3321; color: #22c55e; }
|
| 39 |
+
.tag-medium { background: #3a2500; color: #f59e0b; }
|
| 40 |
+
.tag-hard { background: #3a0d0d; color: #ef4444; }
|
| 41 |
+
.tag-id { background: #1a1a2e; color: #9ca3af; border: 1px solid #2a2a3a; }
|
| 42 |
+
.task-instructions { font-size: 13px; color: #9ca3af; margin-bottom: 10px; line-height: 1.5; }
|
| 43 |
+
.code-label { font-size: 11px; color: #6b7280; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
|
| 44 |
+
pre { background: #0a0a14; border: 1px solid #2a2a3a; border-radius: 6px; padding: 12px; font-size: 13px; color: #e0e0e0; overflow-x: auto; white-space: pre-wrap; font-family: monospace; }
|
| 45 |
+
textarea { width: 100%; background: #0a0a14; border: 1px solid #2a2a3a; border-radius: 6px; padding: 12px; font-size: 13px; color: #e0e0e0; font-family: monospace; resize: vertical; min-height: 120px; outline: none; margin-top: 6px; }
|
| 46 |
+
textarea:focus { border-color: #60a5fa; }
|
| 47 |
+
.reward-box { display: none; background: #0f1117; border-radius: 8px; padding: 1rem; margin-top: 1rem; border: 1px solid #2a2a3a; }
|
| 48 |
+
.reward-box.visible { display: block; }
|
| 49 |
+
.reward-value { font-size: 2rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
|
| 50 |
+
.reward-1 { color: #22c55e; }
|
| 51 |
+
.reward-mid { color: #f59e0b; }
|
| 52 |
+
.reward-0 { color: #ef4444; }
|
| 53 |
+
.feedback-text { font-size: 12px; color: #9ca3af; white-space: pre-wrap; line-height: 1.6; margin-top: 8px; border-top: 1px solid #2a2a3a; padding-top: 8px; }
|
| 54 |
+
.loading { color: #6b7280; font-size: 13px; text-align: center; padding: 1rem; display: none; }
|
| 55 |
+
.loading.visible { display: block; }
|
| 56 |
.endpoints { display: flex; flex-direction: column; gap: 10px; margin-bottom: 2rem; }
|
| 57 |
.endpoint { background: #1a1a2e; border: 1px solid #2a2a3a; border-radius: 10px; padding: 1rem 1.25rem; display: flex; align-items: center; gap: 12px; text-decoration: none; transition: border-color 0.2s; }
|
| 58 |
.endpoint:hover { border-color: #3b82f6; }
|
|
|
|
| 71 |
.diff-name.hard { color: #ef4444; }
|
| 72 |
.diff-detail { font-size: 12px; color: #6b7280; line-height: 1.5; }
|
| 73 |
.footer { text-align: center; padding-top: 1.5rem; border-top: 1px solid #2a2a3a; }
|
| 74 |
+
.docs-btn { display: inline-block; background: #1e3a5f; color: #60a5fa; padding: 10px 24px; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 500; }
|
| 75 |
.docs-btn:hover { background: #2a4a7f; }
|
| 76 |
</style>
|
| 77 |
</head>
|
|
|
|
| 81 |
<div class="badge">OpenEnv Compatible</div>
|
| 82 |
<h1>Code Debug Environment</h1>
|
| 83 |
<p class="subtitle">An RL environment where LLM agents diagnose and fix buggy Python code</p>
|
| 84 |
+
<div class="status-bar"><div class="dot"></div><span class="status-text">Live and Running</span></div>
|
|
|
|
|
|
|
|
|
|
| 85 |
</div>
|
| 86 |
|
| 87 |
<div class="stats">
|
| 88 |
+
<div class="stat"><div class="stat-value">45</div><div class="stat-label">Total Tasks</div></div>
|
| 89 |
+
<div class="stat"><div class="stat-value">3</div><div class="stat-label">Difficulty Levels</div></div>
|
| 90 |
+
<div class="stat"><div class="stat-value">0 to 1.0</div><div class="stat-label">Reward Range</div></div>
|
| 91 |
+
</div>
|
| 92 |
+
|
| 93 |
+
<div class="section-title">Live Tester</div>
|
| 94 |
+
<div class="tester">
|
| 95 |
+
<div class="tester-title">Try the environment interactively</div>
|
| 96 |
+
<div class="select-row">
|
| 97 |
+
<select id="difficulty-select">
|
| 98 |
+
<option value="">Random difficulty</option>
|
| 99 |
+
<option value="easy">Easy — 1 bug</option>
|
| 100 |
+
<option value="medium">Medium — 2 bugs</option>
|
| 101 |
+
<option value="hard">Hard — algorithmic bug + explanation</option>
|
| 102 |
+
</select>
|
| 103 |
+
<button class="btn btn-blue" onclick="doReset()">Get Task</button>
|
| 104 |
</div>
|
| 105 |
+
<div class="loading" id="loading-reset">Loading task...</div>
|
| 106 |
+
<div class="task-box" id="task-box">
|
| 107 |
+
<div class="task-meta">
|
| 108 |
+
<span class="tag tag-id" id="tag-id"></span>
|
| 109 |
+
<span class="tag" id="tag-diff"></span>
|
| 110 |
+
</div>
|
| 111 |
+
<div class="task-instructions" id="task-instructions"></div>
|
| 112 |
+
<div class="code-label">Buggy code</div>
|
| 113 |
+
<pre id="buggy-code"></pre>
|
| 114 |
+
<div class="code-label" style="margin-top:1rem;">Your fix</div>
|
| 115 |
+
<textarea id="fixed-code" placeholder="Paste your fixed code here..."></textarea>
|
| 116 |
+
<div id="explanation-section" style="display:none;">
|
| 117 |
+
<div class="code-label" style="margin-top:1rem;">Explanation (required for hard tasks)</div>
|
| 118 |
+
<textarea id="explanation" placeholder="Explain what was wrong and why your fix is correct..." style="min-height:80px;"></textarea>
|
| 119 |
+
</div>
|
| 120 |
+
<div style="margin-top:1rem;">
|
| 121 |
+
<button class="btn btn-green" onclick="doStep()">Submit Fix</button>
|
| 122 |
+
</div>
|
| 123 |
</div>
|
| 124 |
+
<div class="loading" id="loading-step">Grading your fix...</div>
|
| 125 |
+
<div class="reward-box" id="reward-box">
|
| 126 |
+
<div class="reward-value" id="reward-value"></div>
|
| 127 |
+
<div style="text-align:center; font-size:13px; color:#6b7280;" id="tests-info"></div>
|
| 128 |
+
<div class="feedback-text" id="feedback-text"></div>
|
| 129 |
</div>
|
| 130 |
</div>
|
| 131 |
|
| 132 |
<div class="section-title">API Endpoints</div>
|
| 133 |
<div class="endpoints">
|
| 134 |
+
<a class="endpoint" href="/health"><span class="method get">GET</span><div class="endpoint-info"><div class="endpoint-path">/health</div><div class="endpoint-desc">Health check</div></div><span class="arrow">→</span></a>
|
| 135 |
+
<a class="endpoint" href="/docs"><span class="method post">POST</span><div class="endpoint-info"><div class="endpoint-path">/reset</div><div class="endpoint-desc">Start a new episode — pass difficulty: easy | medium | hard</div></div><span class="arrow">→</span></a>
|
| 136 |
+
<a class="endpoint" href="/docs"><span class="method post">POST</span><div class="endpoint-info"><div class="endpoint-path">/step</div><div class="endpoint-desc">Submit fixed code — returns reward (0.0 to 1.0) and feedback</div></div><span class="arrow">→</span></a>
|
| 137 |
+
<a class="endpoint" href="/state"><span class="method get">GET</span><div class="endpoint-info"><div class="endpoint-path">/state</div><div class="endpoint-desc">Current episode state</div></div><span class="arrow">→</span></a>
|
| 138 |
+
<a class="endpoint" href="/tasks"><span class="method get">GET</span><div class="endpoint-info"><div class="endpoint-path">/tasks</div><div class="endpoint-desc">List all 45 task IDs</div></div><span class="arrow">→</span></a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
</div>
|
| 140 |
|
| 141 |
<div class="section-title">Difficulty Levels</div>
|
| 142 |
<div class="difficulties">
|
| 143 |
+
<div class="diff"><div class="diff-name easy">Easy</div><div class="diff-detail">15 tasks<br>1 bug per task<br>reward = tests passed / 3</div></div>
|
| 144 |
+
<div class="diff"><div class="diff-name medium">Medium</div><div class="diff-detail">15 tasks<br>2 bugs per task<br>reward = tests passed / 3</div></div>
|
| 145 |
+
<div class="diff"><div class="diff-name hard">Hard</div><div class="diff-detail">15 tasks<br>algorithmic bug<br>reward = 0.7 x code + 0.3 x explanation</div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
</div>
|
| 147 |
|
| 148 |
+
<div class="footer"><a class="docs-btn" href="/docs">Open Interactive API Docs</a></div>
|
|
|
|
|
|
|
| 149 |
</div>
|
| 150 |
+
|
| 151 |
+
<script>
|
| 152 |
+
async function doReset() {
|
| 153 |
+
const sel = document.getElementById('difficulty-select').value;
|
| 154 |
+
document.getElementById('loading-reset').classList.add('visible');
|
| 155 |
+
document.getElementById('task-box').classList.remove('visible');
|
| 156 |
+
document.getElementById('reward-box').classList.remove('visible');
|
| 157 |
+
document.getElementById('loading-step').classList.remove('visible');
|
| 158 |
+
try {
|
| 159 |
+
const body = sel ? { difficulty: sel } : {};
|
| 160 |
+
const res = await fetch('/reset', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
| 161 |
+
const data = await res.json();
|
| 162 |
+
const obs = data.observation;
|
| 163 |
+
document.getElementById('tag-id').textContent = obs.task_id;
|
| 164 |
+
const diffTag = document.getElementById('tag-diff');
|
| 165 |
+
diffTag.textContent = obs.difficulty.toUpperCase();
|
| 166 |
+
diffTag.className = 'tag tag-' + obs.difficulty;
|
| 167 |
+
document.getElementById('task-instructions').textContent = obs.instructions;
|
| 168 |
+
document.getElementById('buggy-code').textContent = obs.buggy_code;
|
| 169 |
+
document.getElementById('fixed-code').value = obs.buggy_code;
|
| 170 |
+
document.getElementById('explanation-section').style.display = obs.difficulty === 'hard' ? 'block' : 'none';
|
| 171 |
+
document.getElementById('task-box').classList.add('visible');
|
| 172 |
+
} catch(e) { alert('Error: ' + e.message); }
|
| 173 |
+
finally { document.getElementById('loading-reset').classList.remove('visible'); }
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
async function doStep() {
|
| 177 |
+
const fixedCode = document.getElementById('fixed-code').value.trim();
|
| 178 |
+
if (!fixedCode) { alert('Please enter your fixed code!'); return; }
|
| 179 |
+
document.getElementById('loading-step').classList.add('visible');
|
| 180 |
+
document.getElementById('reward-box').classList.remove('visible');
|
| 181 |
+
try {
|
| 182 |
+
const payload = { fixed_code: fixedCode };
|
| 183 |
+
const explanation = document.getElementById('explanation').value.trim();
|
| 184 |
+
if (explanation) payload.explanation = explanation;
|
| 185 |
+
const res = await fetch('/step', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
| 186 |
+
const data = await res.json();
|
| 187 |
+
const obs = data.observation;
|
| 188 |
+
const reward = data.reward;
|
| 189 |
+
const rewardEl = document.getElementById('reward-value');
|
| 190 |
+
rewardEl.textContent = 'Reward: ' + reward.toFixed(2);
|
| 191 |
+
rewardEl.className = 'reward-value ' + (reward === 1.0 ? 'reward-1' : reward > 0 ? 'reward-mid' : 'reward-0');
|
| 192 |
+
document.getElementById('tests-info').textContent = obs.passed_tests + ' / ' + obs.total_tests + ' tests passed' + (data.done ? ' — Episode complete' : '');
|
| 193 |
+
document.getElementById('feedback-text').textContent = obs.feedback || '';
|
| 194 |
+
document.getElementById('reward-box').classList.add('visible');
|
| 195 |
+
} catch(e) { alert('Error: ' + e.message); }
|
| 196 |
+
finally { document.getElementById('loading-step').classList.remove('visible'); }
|
| 197 |
+
}
|
| 198 |
+
</script>
|
| 199 |
</body>
|
| 200 |
</html>
|
server/tasks/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (451 Bytes). View file
|
|
|
server/tasks/__pycache__/task_easy.cpython-310.pyc
ADDED
|
Binary file (7.37 kB). View file
|
|
|
server/tasks/__pycache__/task_hard.cpython-310.pyc
ADDED
|
Binary file (16.5 kB). View file
|
|
|
server/tasks/__pycache__/task_medium.cpython-310.pyc
ADDED
|
Binary file (10.5 kB). View file
|
|
|