Spaces:
Sleeping
Sleeping
File size: 18,149 Bytes
83bf9a2 e3bcf07 0dc8726 e3bcf07 83bf9a2 0dc8726 83bf9a2 0dc8726 878c60c 83bf9a2 878c60c 63064d5 878c60c 63064d5 878c60c 5e0aa92 eb990da c7b94d2 eb990da 878c60c 83bf9a2 878c60c f29ca65 878c60c f29ca65 878c60c f29ca65 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoopBreakers – Reward-Hacking Resistant Math AI</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- KaTeX CSS and JS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '\\(', right: '\\)', display: false}
]
});"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<style>
.gradient-bg {
background: linear-gradient(135deg, #7e22ce 0%, #9333ea 50%, #a855f7 100%);
}
.solution-section {
transition: all 0.3s ease;
max-height: 0;
overflow: hidden;
}
.solution-section.show {
max-height: 2000px;
}
.fade-in {
animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.step-highlight {
border-left: 4px solid #9333ea;
background-color: #f5f3ff;
}
textarea {
min-height: 120px;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Header -->
<header class="gradient-bg text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-robot text-3xl"></i>
<h1 class="text-2xl md:text-3xl font-bold">LoopBreakers</h1>
</div>
<p class="text-sm md:text-base font-medium bg-white/20 px-3 py-1 rounded-full">
Reward-Hacking Resistant Math AI
</p>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<div class="max-w-4xl mx-auto">
<!-- Intro Section -->
<section class="mb-12 text-center">
<h2 class="text-3xl font-bold text-gray-800 mb-3">AI-Powered Math Problem Solver</h2>
<p class="text-gray-600 text-lg">
Get reliable, step-by-step solutions for Year 5–10 math problems with alignment-focused explanations.
</p>
</section>
<!-- Input Section -->
<section class="mb-8 bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-6">
<label for="math-problem" class="block text-lg font-medium text-gray-700 mb-3">
Enter your math word problem:
</label>
<textarea
id="math-problem"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 transition"
placeholder="E.g., If a train leaves station A at 60 mph and another leaves station B at 40 mph 2 hours later, when will they meet if the stations are 300 miles apart?"
></textarea>
</div>
<div class="bg-gray-50 px-6 py-4 flex justify-end">
<button id="solve-btn" class="gradient-bg text-white px-6 py-3 rounded-lg font-medium hover:opacity-90 transition flex items-center">
<i class="fas fa-lightbulb mr-2"></i> Get Solution
</button>
</div>
</section>
<!-- Solution Section (Initially hidden) -->
<section id="solution-section" class="solution-section bg-white rounded-xl shadow-md overflow-hidden mb-8">
<div class="p-6">
<!-- Loading State -->
<div id="loading" class="text-center py-8 hidden">
<div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-purple-500 mx-auto mb-4"></div>
<p class="text-gray-600">Analyzing your problem with alignment-focused reasoning...</p>
</div>
<!-- Solution Content -->
<div id="solution-content" class="hidden fade-in">
<!-- Step-by-Step Explanation -->
<div class="mb-8">
<h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-list-ol text-purple-600 mr-2"></i> Step-by-Step Explanation
</h3>
<div id="steps-container" class="space-y-4">
<!-- Steps will be inserted here by JavaScript -->
</div>
</div>
<!-- Final Answer -->
<div class="mb-8 p-4 bg-purple-50 rounded-lg border border-purple-100">
<h3 class="text-xl font-bold text-gray-800 mb-2 flex items-center">
<i class="fas fa-check-circle text-purple-600 mr-2"></i> Final Answer
</h3>
<p id="final-answer" class="text-2xl font-bold text-purple-700">
<!-- Final answer will be inserted here -->
</p>
</div>
<!-- Alignment Reasoning -->
<div class="mb-8">
<h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-brain text-purple-600 mr-2"></i> Alignment Reasoning
</h3>
<div id="alignment-reasoning" class="bg-gray-50 p-4 rounded-lg">
<!-- Alignment reasoning will be inserted here -->
</div>
</div>
<div class="flex justify-end mt-4">
<button id="download-pdf" class="bg-purple-600 text-white px-5 py-2 rounded-lg font-medium hover:opacity-90 transition">
<i class="fas fa-download mr-2"></i>Download PDF
</button>
</div>
<!-- Feedback Section -->
<div class="border-t pt-6">
<h3 class="text-lg font-medium text-gray-700 mb-3">Was this solution helpful?</h3>
<div class="flex space-x-4">
<button id="correct-btn" class="flex-1 bg-green-100 text-green-800 px-4 py-2 rounded-lg font-medium hover:bg-green-200 transition flex items-center justify-center">
<i class="fas fa-thumbs-up mr-2"></i> Correct
</button>
<button id="incorrect-btn" class="flex-1 bg-red-100 text-red-800 px-4 py-2 rounded-lg font-medium hover:bg-red-200 transition flex items-center justify-center">
<i class="fas fa-thumbs-down mr-2"></i> Incorrect
</button>
</div>
<div id="feedback-thanks" class="hidden mt-3 text-center text-green-600 font-medium">
<i class="fas fa-check-circle mr-1"></i> Thank you for your feedback!
</div>
</div>
</div>
</div>
</section>
<!-- Features Section -->
<section class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div class="text-purple-600 mb-3">
<i class="fas fa-shield-alt text-2xl"></i>
</div>
<h3 class="font-bold text-lg mb-2">Alignment Focused</h3>
<p class="text-gray-600">Our AI explains why each step aligns with proper mathematical reasoning, not just pattern matching.</p>
</div>
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div class="text-purple-600 mb-3">
<i class="fas fa-graduation-cap text-2xl"></i>
</div>
<h3 class="font-bold text-lg mb-2">Curriculum Aligned</h3>
<p class="text-gray-600">Solutions tailored for Year 5–10 students, matching school curriculum standards.</p>
</div>
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<div class="text-purple-600 mb-3">
<i class="fas fa-mobile-alt text-2xl"></i>
</div>
<h3 class="font-bold text-lg mb-2">Mobile Friendly</h3>
<p class="text-gray-600">Learn on any device with our responsive design that works perfectly on phones and tablets.</p>
</div>
</section>
</div>
</main>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-8">
<div class="container mx-auto px-4">
<div class="max-w-4xl mx-auto flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<h2 class="text-xl font-bold flex items-center">
<i class="fas fa-robot mr-2"></i> LoopBreakers
</h2>
<p class="text-gray-400 text-sm mt-1">Reward-Hacking Resistant Math AI</p>
</div>
<div class="flex space-x-6">
<a href="#" class="text-gray-300 hover:text-white transition">
<i class="fab fa-twitter"></i>
</a>
<a href="#" class="text-gray-300 hover:text-white transition">
<i class="fab fa-facebook"></i>
</a>
<a href="#" class="text-gray-300 hover:text-white transition">
<i class="fab fa-instagram"></i>
</a>
</div>
</div>
<div class="max-w-4xl mx-auto mt-6 pt-6 border-t border-gray-700 text-center text-gray-400 text-sm">
<p>© 2023 LoopBreakers. All rights reserved.</p>
</div>
</div>
</footer>
<script>
document.getElementById('download-pdf').addEventListener('click', function () {
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
const problem = document.getElementById('math-problem').value;
const steps = Array.from(document.querySelectorAll('#steps-container .step-highlight'))
.map(el => el.textContent.trim());
const answer = document.getElementById('final-answer').textContent;
let y = 10;
doc.setFontSize(14);
doc.text("Math Problem:", 10, y);
y += 10;
doc.setFontSize(12);
doc.text(problem, 10, y);
y += 15;
doc.setFontSize(14);
doc.text("Step-by-Step Working:", 10, y);
y += 10;
steps.forEach((step, i) => {
const lines = doc.splitTextToSize(`${i + 1}. ${step}`, 180);
doc.text(lines, 10, y);
y += lines.length * 7;
if (y > 270) {
doc.addPage();
y = 10;
}
});
doc.setFontSize(14);
doc.text("Final Answer:", 10, y + 10);
doc.setFontSize(12);
doc.text(answer, 10, y + 20);
doc.save("math_solution.pdf");
});
document.addEventListener('DOMContentLoaded', function() {
const solveBtn = document.getElementById('solve-btn');
const solutionSection = document.getElementById('solution-section');
const loading = document.getElementById('loading');
const solutionContent = document.getElementById('solution-content');
const mathProblemInput = document.getElementById('math-problem');
const stepsContainer = document.getElementById('steps-container');
const finalAnswer = document.getElementById('final-answer');
const alignmentReasoning = document.getElementById('alignment-reasoning');
const correctBtn = document.getElementById('correct-btn');
const incorrectBtn = document.getElementById('incorrect-btn');
const feedbackThanks = document.getElementById('feedback-thanks');
solveBtn.addEventListener('click', function() {
const problem = mathProblemInput.value.trim();
if (!problem) {
alert('Please enter a math problem to solve.');
return;
}
// Show loading
solutionSection.classList.add('show');
loading.classList.remove('hidden');
solutionContent.classList.add('hidden');
stepsContainer.innerHTML = '';
finalAnswer.textContent = '';
alignmentReasoning.textContent = '';
// Send to backend
fetch("/solve", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ question: problem })
})
.then(res => res.json())
.then(data => {
loading.classList.add('hidden');
solutionContent.classList.remove('hidden');
const steps = data.steps.split('\n').filter(line => line.trim() !== "");
steps.forEach((step, index) => {
const stepElement = document.createElement('div');
stepElement.className = 'step-highlight p-4 rounded-lg flex';
const numberBadge = document.createElement('span');
numberBadge.className = 'flex-shrink-0 bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3';
numberBadge.textContent = index + 1;
const content = document.createElement('div');
content.innerHTML = step;
// 🧠 Automatically render LaTeX inside the step
if (window.renderMathInElement) {
renderMathInElement(content, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false}
]
});
}
stepElement.appendChild(numberBadge);
stepElement.appendChild(content);
stepsContainer.appendChild(stepElement);
});
finalAnswer.innerHTML = data.final_answer;
if (window.renderMathInElement) {
renderMathInElement(finalAnswer, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false}
]
});
}
alignmentReasoning.textContent = "Reasoning is generated with reward-hacking resistance in mind. The model uses prompting strategies to ensure it avoids shortcuts or incorrect logic patterns.";
})
.catch(err => {
loading.classList.add('hidden');
alert("❌ Error fetching solution. Please try again.");
console.error(err);
});
});
correctBtn.addEventListener('click', function() {
feedbackThanks.classList.remove('hidden');
setTimeout(() => feedbackThanks.classList.add('hidden'), 3000);
});
incorrectBtn.addEventListener('click', function() {
feedbackThanks.textContent = "We'll review this solution to improve our AI. Thank you!";
feedbackThanks.className = "hidden mt-3 text-center text-purple-600 font-medium";
feedbackThanks.classList.remove('hidden');
setTimeout(() => feedbackThanks.classList.add('hidden'), 3000);
});
mathProblemInput.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=JoshAbrahams21/loopbreakers" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>
|