Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -252,19 +252,33 @@ def build_interface():
|
|
252 |
outputs=[prompt_output, quality_report, token_stats],
|
253 |
api_name="generate"
|
254 |
)
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
|
269 |
return app
|
270 |
|
|
|
252 |
outputs=[prompt_output, quality_report, token_stats],
|
253 |
api_name="generate"
|
254 |
)
|
255 |
+
|
256 |
+
# Implement browser-based clipboard functionality instead of pyperclip
|
257 |
+
copy_btn.click(
|
258 |
+
None, # No Python function needed
|
259 |
+
inputs=prompt_output,
|
260 |
+
outputs=None,
|
261 |
+
_js="""
|
262 |
+
(text) => {
|
263 |
+
if (!text) return;
|
264 |
+
navigator.clipboard.writeText(text)
|
265 |
+
.then(() => {
|
266 |
+
// Show temporary success message
|
267 |
+
const button = document.querySelector("button:contains('Copy')");
|
268 |
+
const originalText = button.innerText;
|
269 |
+
button.innerText = "✓ Copied!";
|
270 |
+
setTimeout(() => {
|
271 |
+
button.innerText = originalText;
|
272 |
+
}, 2000);
|
273 |
+
})
|
274 |
+
.catch(err => {
|
275 |
+
console.error('Failed to copy: ', err);
|
276 |
+
alert('Copy failed. Please select and copy manually.');
|
277 |
+
});
|
278 |
+
return;
|
279 |
+
}
|
280 |
+
"""
|
281 |
+
)
|
282 |
|
283 |
return app
|
284 |
|