Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -486,31 +486,65 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
|
|
486 |
|
487 |
# Create HTML with JavaScript using string formatting
|
488 |
html_template = '''
|
489 |
-
<
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
// Fallback method
|
498 |
-
|
499 |
-
textarea.value = text;
|
500 |
-
document.body.appendChild(textarea);
|
501 |
-
textarea.select();
|
502 |
document.execCommand('copy');
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
'''
|
515 |
|
516 |
# Return all three expected outputs:
|
|
|
486 |
|
487 |
# Create HTML with JavaScript using string formatting
|
488 |
html_template = '''
|
489 |
+
<div style="text-align: center; margin: 10px;">
|
490 |
+
<button
|
491 |
+
onclick="
|
492 |
+
try {
|
493 |
+
// Try all possible selectors for the prompt textarea
|
494 |
+
const promptArea =
|
495 |
+
document.querySelector('#generated_prompt textarea') ||
|
496 |
+
document.querySelector('textarea#generated_prompt') ||
|
497 |
+
document.querySelector('.generated_prompt textarea') ||
|
498 |
+
Array.from(document.querySelectorAll('textarea')).find(el => el.value.includes('Summarize'));
|
499 |
+
|
500 |
+
if (promptArea && promptArea.value) {
|
501 |
+
navigator.clipboard.writeText(promptArea.value)
|
502 |
+
.then(() => {
|
503 |
+
this.textContent = 'β
Copied to clipboard!';
|
504 |
+
setTimeout(() => {
|
505 |
+
this.textContent = 'π Copy Text to Clipboard';
|
506 |
+
}, 2000);
|
507 |
+
})
|
508 |
+
.catch(err => {
|
509 |
+
console.error('Modern copy failed:', err);
|
510 |
// Fallback method
|
511 |
+
promptArea.select();
|
|
|
|
|
|
|
512 |
document.execCommand('copy');
|
513 |
+
this.textContent = 'β
Copied to clipboard!';
|
514 |
+
setTimeout(() => {
|
515 |
+
this.textContent = 'π Copy Text to Clipboard';
|
516 |
+
}, 2000);
|
517 |
+
});
|
518 |
+
} else {
|
519 |
+
this.textContent = 'β No text found. Generate one first.';
|
520 |
+
setTimeout(() => {
|
521 |
+
this.textContent = 'π Copy Text to Clipboard';
|
522 |
+
}, 2000);
|
523 |
+
}
|
524 |
+
} catch (err) {
|
525 |
+
console.error('Copy error:', err);
|
526 |
+
this.textContent = 'β Copy failed. Try again.';
|
527 |
+
setTimeout(() => {
|
528 |
+
this.textContent = 'π Copy Text to Clipboard';
|
529 |
+
}, 2000);
|
530 |
+
}
|
531 |
+
"
|
532 |
+
style="
|
533 |
+
padding: 10px 20px;
|
534 |
+
background-color: #2C3E50;
|
535 |
+
color: white;
|
536 |
+
border: none;
|
537 |
+
border-radius: 5px;
|
538 |
+
font-weight: bold;
|
539 |
+
cursor: pointer;
|
540 |
+
transition: background-color 0.3s ease;
|
541 |
+
"
|
542 |
+
onmouseover="this.style.backgroundColor='#34495E'"
|
543 |
+
onmouseout="this.style.backgroundColor='#2C3E50'"
|
544 |
+
>
|
545 |
+
π Copy Text to Clipboard
|
546 |
+
</button>
|
547 |
+
</div>
|
548 |
'''
|
549 |
|
550 |
# Return all three expected outputs:
|