Spaces:
Running
Running
Update index.html
Browse files- index.html +85 -8
index.html
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
|
@@ -277,6 +276,39 @@ th{font-weight:600}
|
|
| 277 |
margin-top: 8px; /* Add some spacing */
|
| 278 |
}
|
| 279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
/* responsive & print */
|
| 281 |
@media(max-width:768px){
|
| 282 |
.container{margin:20px 16px;padding:28px}
|
|
@@ -286,7 +318,7 @@ th{font-weight:600}
|
|
| 286 |
@media print{
|
| 287 |
body{background:#fff}
|
| 288 |
.container{box-shadow:none;border:none}
|
| 289 |
-
.header,.processing,.instructions,#themeToggle,#settingsBtn{display:none}
|
| 290 |
}
|
| 291 |
</style>
|
| 292 |
</head>
|
|
@@ -349,6 +381,22 @@ function hideProcessing(){
|
|
| 349 |
setTimeout(()=>processingNode.classList.remove('show'),300);
|
| 350 |
}
|
| 351 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
/* ======= markdown + latex pipeline ======= */
|
| 353 |
function processContent(text){
|
| 354 |
showProcessing();
|
|
@@ -413,7 +461,7 @@ async function ocrImage(base64Image) {
|
|
| 413 |
messages: [
|
| 414 |
{
|
| 415 |
role: 'system',
|
| 416 |
-
content: 'GIVE AS TEXT WITH LATEX like $this$ or $$this$$.
|
| 417 |
},
|
| 418 |
{
|
| 419 |
role: 'user',
|
|
@@ -444,14 +492,26 @@ async function ocrImage(base64Image) {
|
|
| 444 |
}
|
| 445 |
|
| 446 |
/* ======= UI Helpers for Streaming ======= */
|
|
|
|
|
|
|
|
|
|
| 447 |
function beginStreamingUI(question){
|
|
|
|
|
|
|
|
|
|
| 448 |
// Show a lightweight, non-MathJax view while the model streams
|
| 449 |
content.innerHTML = `
|
| 450 |
<div>
|
| 451 |
-
<
|
|
|
|
|
|
|
|
|
|
| 452 |
<div class="mono-stream" id="qStream"></div>
|
| 453 |
<hr style="opacity:.35; margin: 20px 0;">
|
| 454 |
-
<
|
|
|
|
|
|
|
|
|
|
| 455 |
<div class="mono-stream" id="aStream">(generating...)</div>
|
| 456 |
</div>`;
|
| 457 |
const qEl = document.getElementById('qStream');
|
|
@@ -462,9 +522,25 @@ function beginStreamingUI(question){
|
|
| 462 |
}
|
| 463 |
|
| 464 |
function finalizeStreaming(question, fullAnswer){
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
}
|
| 469 |
|
| 470 |
/* ======= Solve with Cerebras API (Streaming Optimization) ======= */
|
|
@@ -515,6 +591,7 @@ async function solveQuestion(question) {
|
|
| 515 |
const flushUI = () => {
|
| 516 |
// Update the lightweight streaming area without MathJax
|
| 517 |
ui.aEl.textContent = fullAnswer;
|
|
|
|
| 518 |
lastFlushTime = performance.now();
|
| 519 |
};
|
| 520 |
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
|
|
| 276 |
margin-top: 8px; /* Add some spacing */
|
| 277 |
}
|
| 278 |
|
| 279 |
+
/* ───────── copy button styles ───────── */
|
| 280 |
+
.copy-btn {
|
| 281 |
+
display: inline-block;
|
| 282 |
+
margin-left: 10px;
|
| 283 |
+
padding: 4px 8px;
|
| 284 |
+
background: var(--code-bg);
|
| 285 |
+
border: 1px solid var(--code-border);
|
| 286 |
+
border-radius: 4px;
|
| 287 |
+
font-family: 'PT Mono', monospace;
|
| 288 |
+
font-size: 12px;
|
| 289 |
+
cursor: pointer;
|
| 290 |
+
transition: all 0.2s;
|
| 291 |
+
user-select: none;
|
| 292 |
+
}
|
| 293 |
+
.copy-btn:hover {
|
| 294 |
+
background: var(--blockquote-bg);
|
| 295 |
+
transform: translateY(-1px);
|
| 296 |
+
}
|
| 297 |
+
.copy-btn.copied {
|
| 298 |
+
background: #4a5f4a;
|
| 299 |
+
color: #fff;
|
| 300 |
+
border-color: #4a5f4a;
|
| 301 |
+
}
|
| 302 |
+
.section-header {
|
| 303 |
+
display: flex;
|
| 304 |
+
align-items: center;
|
| 305 |
+
gap: 8px;
|
| 306 |
+
margin-bottom: 0;
|
| 307 |
+
}
|
| 308 |
+
.section-header strong {
|
| 309 |
+
margin: 0;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
/* responsive & print */
|
| 313 |
@media(max-width:768px){
|
| 314 |
.container{margin:20px 16px;padding:28px}
|
|
|
|
| 318 |
@media print{
|
| 319 |
body{background:#fff}
|
| 320 |
.container{box-shadow:none;border:none}
|
| 321 |
+
.header,.processing,.instructions,#themeToggle,#settingsBtn,.copy-btn{display:none}
|
| 322 |
}
|
| 323 |
</style>
|
| 324 |
</head>
|
|
|
|
| 381 |
setTimeout(()=>processingNode.classList.remove('show'),300);
|
| 382 |
}
|
| 383 |
|
| 384 |
+
/* ======= Copy to clipboard helper ======= */
|
| 385 |
+
function copyToClipboard(text, button) {
|
| 386 |
+
navigator.clipboard.writeText(text).then(() => {
|
| 387 |
+
const originalText = button.textContent;
|
| 388 |
+
button.textContent = '✓ Copied';
|
| 389 |
+
button.classList.add('copied');
|
| 390 |
+
setTimeout(() => {
|
| 391 |
+
button.textContent = originalText;
|
| 392 |
+
button.classList.remove('copied');
|
| 393 |
+
}, 2000);
|
| 394 |
+
}).catch(err => {
|
| 395 |
+
console.error('Failed to copy:', err);
|
| 396 |
+
alert('Failed to copy to clipboard');
|
| 397 |
+
});
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
/* ======= markdown + latex pipeline ======= */
|
| 401 |
function processContent(text){
|
| 402 |
showProcessing();
|
|
|
|
| 461 |
messages: [
|
| 462 |
{
|
| 463 |
role: 'system',
|
| 464 |
+
content: 'GIVE AS TEXT WITH LATEX like $this$ or $$this$$. NEVER USE \\itemize, \\begin{itemize}, \\end{itemize}, \\item or any list environments. Use plain text with numbers or letters for lists. DO NOT SOLVE THE QUESTION. DO NOT OUTPUT ANYTHING BUT THE EXACT FORMAT OF THE QUESTION AS IT APPEARS IN THE IMAGE.'
|
| 465 |
},
|
| 466 |
{
|
| 467 |
role: 'user',
|
|
|
|
| 492 |
}
|
| 493 |
|
| 494 |
/* ======= UI Helpers for Streaming ======= */
|
| 495 |
+
let currentQuestion = '';
|
| 496 |
+
let currentAnswer = '';
|
| 497 |
+
|
| 498 |
function beginStreamingUI(question){
|
| 499 |
+
currentQuestion = question;
|
| 500 |
+
currentAnswer = '';
|
| 501 |
+
|
| 502 |
// Show a lightweight, non-MathJax view while the model streams
|
| 503 |
content.innerHTML = `
|
| 504 |
<div>
|
| 505 |
+
<div class="section-header">
|
| 506 |
+
<p><strong>Question</strong>:</p>
|
| 507 |
+
<button class="copy-btn" onclick="copyToClipboard(currentQuestion, this)">📋 Copy</button>
|
| 508 |
+
</div>
|
| 509 |
<div class="mono-stream" id="qStream"></div>
|
| 510 |
<hr style="opacity:.35; margin: 20px 0;">
|
| 511 |
+
<div class="section-header">
|
| 512 |
+
<p><strong>Answer</strong>:</p>
|
| 513 |
+
<button class="copy-btn" onclick="copyToClipboard(currentAnswer, this)">📋 Copy</button>
|
| 514 |
+
</div>
|
| 515 |
<div class="mono-stream" id="aStream">(generating...)</div>
|
| 516 |
</div>`;
|
| 517 |
const qEl = document.getElementById('qStream');
|
|
|
|
| 522 |
}
|
| 523 |
|
| 524 |
function finalizeStreaming(question, fullAnswer){
|
| 525 |
+
currentQuestion = question;
|
| 526 |
+
currentAnswer = fullAnswer;
|
| 527 |
+
|
| 528 |
+
// Create HTML with copy buttons
|
| 529 |
+
const htmlContent = `
|
| 530 |
+
<div class="section-header">
|
| 531 |
+
<strong>Question</strong>:
|
| 532 |
+
<button class="copy-btn" onclick="copyToClipboard(currentQuestion, this)">📋 Copy</button>
|
| 533 |
+
</div>
|
| 534 |
+
<div style="margin-bottom: 20px;">${question}</div>
|
| 535 |
+
|
| 536 |
+
<div class="section-header">
|
| 537 |
+
<strong>Answer</strong>:
|
| 538 |
+
<button class="copy-btn" onclick="copyToClipboard(currentAnswer, this)">📋 Copy</button>
|
| 539 |
+
</div>
|
| 540 |
+
<div>${fullAnswer}</div>`;
|
| 541 |
+
|
| 542 |
+
// Process the content with Markdown and MathJax
|
| 543 |
+
processContent(htmlContent);
|
| 544 |
}
|
| 545 |
|
| 546 |
/* ======= Solve with Cerebras API (Streaming Optimization) ======= */
|
|
|
|
| 591 |
const flushUI = () => {
|
| 592 |
// Update the lightweight streaming area without MathJax
|
| 593 |
ui.aEl.textContent = fullAnswer;
|
| 594 |
+
currentAnswer = fullAnswer; // Update global variable for copy button
|
| 595 |
lastFlushTime = performance.now();
|
| 596 |
};
|
| 597 |
|