Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -386,8 +386,23 @@ class AIEvaluationForm:
|
|
386 |
scorecard, # JSON display
|
387 |
gr.File(value=filename, visible=True), # File for download
|
388 |
gr.Button(visible=True) # Show download button
|
|
|
389 |
)
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
def clear_form():
|
392 |
"""Clear all form inputs"""
|
393 |
return [None] * len(all_inputs)
|
@@ -396,10 +411,16 @@ class AIEvaluationForm:
|
|
396 |
generate_btn.click(
|
397 |
fn=generate_with_progress,
|
398 |
inputs=all_inputs,
|
399 |
-
outputs=[json_output, download_file, download_btn],
|
400 |
show_progress="full"
|
401 |
)
|
402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
clear_btn.click(
|
404 |
fn=clear_form,
|
405 |
outputs=all_inputs
|
|
|
386 |
scorecard, # JSON display
|
387 |
gr.File(value=filename, visible=True), # File for download
|
388 |
gr.Button(visible=True) # Show download button
|
389 |
+
gr.HTML(visible=False) # Hidden HTML for download trigger
|
390 |
)
|
391 |
+
|
392 |
+
def trigger_download():
|
393 |
+
"""Trigger file download via JavaScript"""
|
394 |
+
return gr.HTML("""
|
395 |
+
<script>
|
396 |
+
// Find the download link and click it
|
397 |
+
setTimeout(() => {
|
398 |
+
const downloadLinks = document.querySelectorAll('a[download]');
|
399 |
+
if (downloadLinks.length > 0) {
|
400 |
+
downloadLinks[downloadLinks.length - 1].click();
|
401 |
+
}
|
402 |
+
}, 100);
|
403 |
+
</script>
|
404 |
+
""", visible=False)
|
405 |
+
|
406 |
def clear_form():
|
407 |
"""Clear all form inputs"""
|
408 |
return [None] * len(all_inputs)
|
|
|
411 |
generate_btn.click(
|
412 |
fn=generate_with_progress,
|
413 |
inputs=all_inputs,
|
414 |
+
outputs=[json_output, download_file, download_btn, download_html],
|
415 |
show_progress="full"
|
416 |
)
|
417 |
|
418 |
+
# Wire up download button to trigger download
|
419 |
+
download_btn.click(
|
420 |
+
fn=trigger_download,
|
421 |
+
outputs=download_html
|
422 |
+
)
|
423 |
+
|
424 |
clear_btn.click(
|
425 |
fn=clear_form,
|
426 |
outputs=all_inputs
|