StringChaos commited on
Commit
0f609e5
1 Parent(s): 122ade4
app.py CHANGED
@@ -101,5 +101,52 @@ def problem(problem_idx):
101
  )
102
 
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  if __name__ == "__main__":
105
  app.run(host="0.0.0.0", port=7860)
 
101
  )
102
 
103
 
104
+ mini_models = [
105
+ "DeepSeek-V2",
106
+ "DeepSeekCoder-V2",
107
+ "DSCoder-33b-Ins",
108
+ "LLama3-70b-Ins",
109
+ "GPT-4-Turbo-2024-04-09",
110
+ "GPT-4O-2024-05-13",
111
+ "Claude-2",
112
+ "Claude-Instant-1",
113
+ "Claude-3-Opus",
114
+ "Claude-3-Sonnet",
115
+ "Claude-3-Haiku",
116
+ ]
117
+
118
+
119
+ @app.route("/mini")
120
+ def mini():
121
+ # Fetch your data here
122
+ return render_template(
123
+ "index_mini.html",
124
+ models=mini_models,
125
+ problems=all_evaluations_by_problem_colored,
126
+ )
127
+
128
+
129
+ @app.route("/problem_mini/<int:problem_idx>")
130
+ def problem_mini(problem_idx):
131
+ # Fetch your data here
132
+
133
+ data = {
134
+ model: all_data_for_view_formatted[model][problem_idx] for model in mini_models
135
+ }
136
+ evaluation = all_evaluations_by_problem_colored[problem_idx][1]
137
+ question = problems[problem_idx]
138
+
139
+ # print(data)
140
+
141
+ return render_template(
142
+ "problem_mini.html",
143
+ problem_idx=problem_idx,
144
+ evaluation=evaluation,
145
+ models=mini_models,
146
+ question=question,
147
+ data=data,
148
+ )
149
+
150
+
151
  if __name__ == "__main__":
152
  app.run(host="0.0.0.0", port=7860)
templates/index.html CHANGED
@@ -81,6 +81,7 @@
81
  <body>
82
 
83
 
 
84
 
85
  <table id='model-table' style="align:center">
86
  <thead>
 
81
  <body>
82
 
83
 
84
+ Full table here. Or go to <a href="{{ url_for('mini') }}">mini leaderboard</a>
85
 
86
  <table id='model-table' style="align:center">
87
  <thead>
templates/index_mini.html ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <style>
6
+ body {
7
+ font-family: Arial, sans-serif;
8
+ margin: 0;
9
+ padding: 20px;
10
+ background-color: #f4f4f4;
11
+ }
12
+
13
+ #checkboxes {
14
+ margin-bottom: 20px;
15
+ }
16
+
17
+ .model-checkbox+label {
18
+ margin-right: 10px;
19
+ padding: 5px 10px;
20
+ background-color: #e7e7e7;
21
+ border-radius: 5px;
22
+ cursor: pointer;
23
+ user-select: none;
24
+ }
25
+
26
+ .model-checkbox {
27
+ display: none;
28
+ /* Hide the default checkbox */
29
+ }
30
+
31
+ .model-checkbox:checked+label {
32
+ background-color: #d0e6a5;
33
+ color: #0b4d03;
34
+ }
35
+
36
+ table {
37
+ width: 100%;
38
+ border-collapse: collapse;
39
+ background-color: #fff;
40
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
41
+ margin: auto;
42
+ overflow: hidden;
43
+ /* Add this line to handle overflow */
44
+ }
45
+
46
+ th,
47
+ td {
48
+ border: 1px solid #ddd;
49
+ padding: 10px 15px;
50
+ text-align: center;
51
+ }
52
+
53
+ th {
54
+ background-color: #f8f8f8;
55
+ font-weight: bold;
56
+ }
57
+
58
+ tr:nth-child(even) {
59
+ background-color: #f2f2f2;
60
+ }
61
+
62
+ .performance-bar {
63
+ display: block;
64
+ height: 20px;
65
+ background: linear-gradient(to right, #00ff00 0%, #ff0000 100%);
66
+ border-radius: 5px;
67
+ }
68
+
69
+ .performance {
70
+ font-weight: bold;
71
+ color: #fff;
72
+ text-align: center;
73
+ line-height: 20px;
74
+ height: 20px;
75
+ margin: 0;
76
+ }
77
+ </style>
78
+
79
+ </head>
80
+
81
+ <body>
82
+
83
+
84
+
85
+ <table id='model-table' style="align:center">
86
+ <thead>
87
+ <tr>
88
+ <th>Problem ID</th>
89
+ <th>Difficulty</th>
90
+ {% for model in models %}
91
+ <th class="column-{{ model }}">{{ model }}</th>
92
+ {% endfor %}
93
+ </tr>
94
+ </thead>
95
+ <tbody>
96
+ {% for problem_idx, problem, difficulty in problems %}
97
+ <tr>
98
+ <td> <a href="{{ url_for('problem_mini', problem_idx=problem_idx) }}"> {{ problem_idx }} </a> </td>
99
+ <td> {{ difficulty }} </td>
100
+ {% for model in models %}
101
+ <td style="background-color: {{ problem[model]['correctness_color'] }};" class="column-{{ model }}">
102
+ {% if model in problem %}
103
+ <div>
104
+ <!-- {{ problem[model]['correctness'] }}% -->
105
+ {{ problem[model]['correctness'] }}%
106
+ </div>
107
+ {% else %}
108
+ -
109
+ {% endif %}
110
+ </td>
111
+ {% endfor %}
112
+ </tr>
113
+ {% endfor %}
114
+
115
+ </tbody>
116
+ </table>
117
+
118
+
119
+ </body>
120
+
121
+ </html>
templates/problem.html CHANGED
@@ -182,8 +182,21 @@
182
 
183
  {% set prev_problem_idx = problem_idx - 1 %}
184
  <a href="{{ url_for('problem', problem_idx=prev_problem_idx) }}" class="other-button">Prev Problem</a>
185
- </div>
186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  <br />
188
  <br />
189
 
@@ -221,6 +234,8 @@
221
  <div class="model" id="code-{{ model }}" style="display: none;">
222
  <h2> {{ model }}</h2>
223
 
 
 
224
  <div class="solutions-container">
225
  {% for code in data[model] %}
226
 
@@ -239,8 +254,6 @@
239
 
240
  {% endfor %}
241
  </div>
242
- <button data-model="{{ model }}" class="prev-solution">Previous</button>
243
- <button data-model="{{ model }}" class="next-solution">Next</button>
244
 
245
  </div>
246
  {% endfor %}
@@ -259,14 +272,14 @@
259
  <script>
260
  document.addEventListener('DOMContentLoaded', function () {
261
  var allModels = document.querySelectorAll('.model');
262
- console.log(allModels);
263
 
264
  allModels.forEach(function (model) {
265
- console.log(model);
266
  var solutions = model.querySelectorAll('.solution');
267
  var totalSolutions = solutions.length;
268
  var currentIndex = 0;
269
- console.log(totalSolutions, currentIndex);
270
 
271
  function updateActiveSolution(index) {
272
  solutions.forEach(function (solution, i) {
@@ -279,13 +292,13 @@
279
  }
280
 
281
  model.querySelector('.prev-solution').addEventListener('click', function () {
282
- console.log(currentIndex, model);
283
  currentIndex = (currentIndex - 1 + totalSolutions) % totalSolutions;
284
  updateActiveSolution(currentIndex);
285
  });
286
 
287
  model.querySelector('.next-solution').addEventListener('click', function () {
288
- console.log(currentIndex, model);
289
  currentIndex = (currentIndex + 1) % totalSolutions;
290
  updateActiveSolution(currentIndex);
291
  });
 
182
 
183
  {% set prev_problem_idx = problem_idx - 1 %}
184
  <a href="{{ url_for('problem', problem_idx=prev_problem_idx) }}" class="other-button">Prev Problem</a>
 
185
 
186
+ <form id="jumpToProblemForm" method="GET">
187
+ <input type="number" id="problemInput" name="problem_idx" placeholder="Enter problem number" required>
188
+ <button type="submit">Go</button>
189
+ </form>
190
+ </div>
191
+ <script>
192
+ document.getElementById('jumpToProblemForm').addEventListener('submit', function (event) {
193
+ event.preventDefault(); // Prevent the form from submitting normally
194
+ var problemIndex = document.getElementById('problemInput').value;
195
+ var baseUrl = "{{ url_for('problem', problem_idx=0) }}"; // Generate the base URL with a placeholder
196
+ var newUrl = baseUrl.replace('0', problemIndex); // Replace the placeholder with the actual index
197
+ window.location.href = newUrl; // Redirect to the new URL
198
+ });
199
+ </script>
200
  <br />
201
  <br />
202
 
 
234
  <div class="model" id="code-{{ model }}" style="display: none;">
235
  <h2> {{ model }}</h2>
236
 
237
+ <button data-model="{{ model }}" class="prev-solution">Previous</button>
238
+ <button data-model="{{ model }}" class="next-solution">Next</button>
239
  <div class="solutions-container">
240
  {% for code in data[model] %}
241
 
 
254
 
255
  {% endfor %}
256
  </div>
 
 
257
 
258
  </div>
259
  {% endfor %}
 
272
  <script>
273
  document.addEventListener('DOMContentLoaded', function () {
274
  var allModels = document.querySelectorAll('.model');
275
+ // console.log(allModels);
276
 
277
  allModels.forEach(function (model) {
278
+ // console.log(model);
279
  var solutions = model.querySelectorAll('.solution');
280
  var totalSolutions = solutions.length;
281
  var currentIndex = 0;
282
+ // console.log(totalSolutions, currentIndex);
283
 
284
  function updateActiveSolution(index) {
285
  solutions.forEach(function (solution, i) {
 
292
  }
293
 
294
  model.querySelector('.prev-solution').addEventListener('click', function () {
295
+ // console.log(currentIndex, model);
296
  currentIndex = (currentIndex - 1 + totalSolutions) % totalSolutions;
297
  updateActiveSolution(currentIndex);
298
  });
299
 
300
  model.querySelector('.next-solution').addEventListener('click', function () {
301
+ // console.log(currentIndex, model);
302
  currentIndex = (currentIndex + 1) % totalSolutions;
303
  updateActiveSolution(currentIndex);
304
  });
templates/problem_mini.html ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <style>
6
+ pre {
7
+ white-space: pre-wrap;
8
+ /* Wraps the text */
9
+ word-break: break-word;
10
+ /* Ensures words break to prevent overflow */
11
+ background-color: #f4f4f4;
12
+ /* Light grey background */
13
+ padding: 2px;
14
+ /* Padding around the text */
15
+ border-radius: 2px;
16
+ /* Rounded corners */
17
+ border: 1px solid #ccc;
18
+ /* Light grey border */
19
+ }
20
+
21
+ .container {
22
+ display: flex;
23
+ /* Use flexbox to layout children */
24
+ justify-content: space-between;
25
+ /* Space between the children */
26
+ margin-bottom: 10px;
27
+ /* Space between each container */
28
+ background-color: #ddd;
29
+ /* Debug: background color */
30
+ }
31
+
32
+ .sub-container {
33
+ flex: 1;
34
+ /* Each sub-container takes equal width */
35
+ padding: 20px;
36
+ /* Padding inside each sub-container */
37
+ background-color: #f4f4f4;
38
+ /* Background color */
39
+ border-radius: 2px;
40
+ /* Rounded corners */
41
+ border: 1px solid #ccc;
42
+ /* Border */
43
+ margin: 0 10px;
44
+ /* Margin between sub-containers */
45
+ }
46
+
47
+ body {
48
+ font-family: Arial, sans-serif;
49
+ margin: 0;
50
+ padding: 20px;
51
+ background-color: #f4f4f4;
52
+ }
53
+
54
+ #checkboxes {
55
+ margin-bottom: 20px;
56
+ }
57
+
58
+ .model-checkbox+label {
59
+ margin-right: 10px;
60
+ padding: 5px 10px;
61
+ background-color: #e7e7e7;
62
+ border-radius: 5px;
63
+ cursor: pointer;
64
+ user-select: none;
65
+ }
66
+
67
+ .model-checkbox {
68
+ display: none;
69
+ /* Hide the default checkbox */
70
+ }
71
+
72
+ .model-checkbox:checked+label {
73
+ background-color: #d0e6a5;
74
+ color: #0b4d03;
75
+ }
76
+
77
+ .model {
78
+ border: 1px solid black;
79
+ padding: 10px;
80
+ }
81
+
82
+ .counter {
83
+ margin-top: 20px;
84
+ }
85
+
86
+ .passed code.hljs {
87
+ background-color: #e6ffe6 !important;
88
+ /* light green */
89
+ color: black !important;
90
+ }
91
+
92
+ .failed code.hljs {
93
+ background-color: #ffe6e6 !important;
94
+ /* light red */
95
+ color: black !important;
96
+ }
97
+
98
+ .solution {
99
+ display: none;
100
+ /* Hide all solutions by default */
101
+ }
102
+
103
+ .solution.active {
104
+ display: block;
105
+ /* Only show the active solution */
106
+ }
107
+
108
+ .button-container {
109
+ text-align: center;
110
+ /* Center the button container */
111
+ margin-top: 20px;
112
+ /* Add some space above the button */
113
+ }
114
+
115
+ .other-button {
116
+ display: inline-block;
117
+ padding: 10px 20px;
118
+ background-color: #BBBBBB;
119
+ color: white;
120
+ text-decoration: none;
121
+ border-radius: 5px;
122
+ font-weight: bold;
123
+ }
124
+
125
+ .other-button:hover {
126
+ background-color: #0056b3;
127
+ }
128
+ </style>
129
+ <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
130
+ <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css">
131
+
132
+ <script>
133
+ // Wait for the DOM to be fully loaded
134
+ document.addEventListener('DOMContentLoaded', function () {
135
+ // Get all checkboxes with the class 'model-checkbox'
136
+ var checkboxes = document.querySelectorAll('.model-checkbox');
137
+
138
+ // Load the checkbox states from localStorage and apply them
139
+ checkboxes.forEach(function (checkbox) {
140
+ var model = checkbox.id.replace('checkbox-', '');
141
+ var savedState = localStorage.getItem('checkbox-' + model);
142
+ if (savedState !== null) {
143
+ checkbox.checked = savedState === 'true';
144
+ var modelElement = document.getElementById('code-' + model);
145
+ modelElement.style.display = checkbox.checked ? 'block' : 'none';
146
+ }
147
+ });
148
+
149
+
150
+
151
+ // Add a change event listener to each checkbox
152
+ checkboxes.forEach(function (checkbox) {
153
+ checkbox.addEventListener('change', function () {
154
+ // Get the model name from the checkbox ID
155
+ var model = this.id.replace('checkbox-', '');
156
+
157
+ // Get the model element
158
+ var modelElement = document.getElementById('code-' + model);
159
+
160
+ // toggle the display of the model element
161
+ modelElement.style.display = this.checked ? 'block' : 'none';
162
+
163
+ // Save the state of all checkboxes to localStorage
164
+ checkboxes.forEach(function (cb) {
165
+ var modelId = cb.id.replace('checkbox-', '');
166
+ localStorage.setItem('checkbox-' + modelId, cb.checked);
167
+ });
168
+
169
+ });
170
+ });
171
+ });
172
+ </script>
173
+ </head>
174
+
175
+ <body>
176
+ <h1>Problem {{ problem_idx }}</h1>
177
+
178
+
179
+ <div class="button-container">
180
+ {% set next_problem_idx = problem_idx + 1 %}
181
+ <a href="{{ url_for('problem_mini', problem_idx=next_problem_idx) }}" class="other-button">Next Problem</a>
182
+
183
+ {% set prev_problem_idx = problem_idx - 1 %}
184
+ <a href="{{ url_for('problem_mini', problem_idx=prev_problem_idx) }}" class="other-button">Prev Problem</a>
185
+
186
+ <form id="jumpToProblemForm" method="GET">
187
+ <input type="number" id="problemInput" name="problem_idx" placeholder="Enter problem number" required>
188
+ <button type="submit">Go</button>
189
+ </form>
190
+ </div>
191
+ <script>
192
+ document.getElementById('jumpToProblemForm').addEventListener('submit', function (event) {
193
+ event.preventDefault(); // Prevent the form from submitting normally
194
+ var problemIndex = document.getElementById('problemInput').value;
195
+ var baseUrl = "{{ url_for('problem_mini', problem_idx=0) }}"; // Generate the base URL with a placeholder
196
+ var newUrl = baseUrl.replace('0', problemIndex); // Replace the placeholder with the actual index
197
+ window.location.href = newUrl; // Redirect to the new URL
198
+ });
199
+ </script>
200
+ <br />
201
+ <br />
202
+
203
+ <!-- <div id="checkboxes">
204
+ {% for model in models %}
205
+ <input type="checkbox" class="model-checkbox" id="checkbox-{{ model }}" checked>
206
+ <label for="checkbox-{{ model }}">{{ model }}@{{ evaluation[model]['correctness'] }}/{{
207
+ evaluation[model]['performance'] }}</label>
208
+ {% endfor %}
209
+ </div> -->
210
+
211
+ <div class="container">
212
+ <div class="sub-container">
213
+ <h3>{{ question['question_title'] }} || {{ question['difficulty'] }} || {{
214
+ question['contest_date'].split('T')[0]}}</h3>
215
+
216
+ <pre overflow="auto">
217
+ {{ question['question_content'] }}
218
+ </pre>
219
+ </div>
220
+
221
+ <div class="sub-container">
222
+ <select id="model-select" class="model-select">
223
+ {% for model in models %}
224
+ <option value="{{ model }}">{{ model }}@{{ evaluation[model]['correctness']
225
+ }}/{{evaluation[model]['performance'] }}</option>
226
+ {% endfor %}
227
+ </select>
228
+
229
+
230
+ <div id="all-results">
231
+
232
+ {% for model in models %}
233
+
234
+ <div class="model" id="code-{{ model }}" style="display: none;">
235
+ <h2> {{ model }}</h2>
236
+
237
+ <button data-model="{{ model }}" class="prev-solution">Previous</button>
238
+ <button data-model="{{ model }}" class="next-solution">Next</button>
239
+ <div class="solutions-container">
240
+ {% for code in data[model] %}
241
+
242
+ <div class="solution{% if loop.first %} active{% endif %}" id="solution-{{ loop.index }}">
243
+
244
+ <ul>
245
+ <li> solution idx -- {{ loop.index }} </li>
246
+ <li>correctness -- {{ code['pass1'] }}</li>
247
+ </ul>
248
+
249
+ <div>
250
+ <pre
251
+ class="{{ 'passed' if code['correctness'] else 'failed' }}"><code class="language-python">{{ code['code'] }}</code></pre>
252
+ </div>
253
+ </div>
254
+
255
+ {% endfor %}
256
+ </div>
257
+
258
+ </div>
259
+ {% endfor %}
260
+ </div>
261
+ </div>
262
+ </div>
263
+ </div>
264
+
265
+
266
+
267
+
268
+
269
+ <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
270
+ <script>hljs.highlightAll();</script>
271
+
272
+ <script>
273
+ document.addEventListener('DOMContentLoaded', function () {
274
+ var allModels = document.querySelectorAll('.model');
275
+ // console.log(allModels);
276
+
277
+ allModels.forEach(function (model) {
278
+ // console.log(model);
279
+ var solutions = model.querySelectorAll('.solution');
280
+ var totalSolutions = solutions.length;
281
+ var currentIndex = 0;
282
+ // console.log(totalSolutions, currentIndex);
283
+
284
+ function updateActiveSolution(index) {
285
+ solutions.forEach(function (solution, i) {
286
+ if (i === index) {
287
+ solution.classList.add('active');
288
+ } else {
289
+ solution.classList.remove('active');
290
+ }
291
+ });
292
+ }
293
+
294
+ model.querySelector('.prev-solution').addEventListener('click', function () {
295
+ // console.log(currentIndex, model);
296
+ currentIndex = (currentIndex - 1 + totalSolutions) % totalSolutions;
297
+ updateActiveSolution(currentIndex);
298
+ });
299
+
300
+ model.querySelector('.next-solution').addEventListener('click', function () {
301
+ // console.log(currentIndex, model);
302
+ currentIndex = (currentIndex + 1) % totalSolutions;
303
+ updateActiveSolution(currentIndex);
304
+ });
305
+ });
306
+ });
307
+ </script>
308
+
309
+ <script>
310
+ document.addEventListener('DOMContentLoaded', function () {
311
+ var modelSelect = document.getElementById('model-select');
312
+ var models = document.querySelectorAll('.model');
313
+ modelSelect.addEventListener('change', function () {
314
+ var selectedModel = this.value;
315
+ models.forEach(function (model) {
316
+ if (model.id === 'code-' + selectedModel) {
317
+ model.style.display = 'block';
318
+ } else {
319
+ model.style.display = 'none';
320
+ }
321
+ });
322
+ });
323
+ });
324
+ document.addEventListener('DOMContentLoaded', function () {
325
+ var selectElement = document.getElementById('model-select');
326
+ selectElement.value = 'GPT-4-Turbo-2024-04-09';
327
+
328
+ var codeElement = document.getElementById('code-GPT-4-Turbo-2024-04-09');
329
+ if (codeElement) {
330
+ codeElement.style.display = 'block';
331
+ }
332
+ });
333
+
334
+ </script>
335
+
336
+ </body>
337
+
338
+ </html>