mahreenfathima commited on
Commit
a1ed676
Β·
verified Β·
1 Parent(s): f20702b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
app.py CHANGED
@@ -380,6 +380,15 @@ def app():
380
 
381
  yield ("🟑 Processing...", output_log + eval_report_buffer, eval_report_buffer, gr.Button(visible=False))
382
  await asyncio.sleep(0.1)
 
 
 
 
 
 
 
 
 
383
 
384
  final_output = output_log
385
  if eval_report_buffer:
@@ -400,21 +409,26 @@ def app():
400
  [topic, samples, model_name, task_type],
401
  [status, output, eval_report_storage, copy_btn]
402
  )
 
 
 
 
 
403
  copy_btn.click(
404
- lambda x: (gr.Info("Evaluation report copied!") if x and x.strip() else gr.Warning("No evaluation report available yet!")),
405
- inputs=[eval_report_storage],
406
- outputs=[],
407
- ).then(
408
- None,
409
- inputs=[eval_report_storage],
410
- js="""
411
- (text) => {
412
- if (text && text.trim().length > 0) {
413
- navigator.clipboard.writeText(text);
414
- }
415
- }
416
- """
417
- )
418
 
419
  return demo
420
 
 
380
 
381
  yield ("🟑 Processing...", output_log + eval_report_buffer, eval_report_buffer, gr.Button(visible=False))
382
  await asyncio.sleep(0.1)
383
+ eval_report_buffer = ""
384
+ if "πŸ“Š **EVALUATION REPORT**" in full_log or "EVALUATION" in full_log:
385
+ parts = full_log.split("πŸ“Š")
386
+ if len(parts) > 1:
387
+ eval_report_buffer = "πŸ“Š" + parts[-1]
388
+ else:
389
+ # Fallback - get last 2000 characters as eval report
390
+ eval_report_buffer = full_log[-2000:]
391
+
392
 
393
  final_output = output_log
394
  if eval_report_buffer:
 
409
  [topic, samples, model_name, task_type],
410
  [status, output, eval_report_storage, copy_btn]
411
  )
412
+ def copy_report(report_text):
413
+ if report_text and report_text.strip():
414
+ return report_text
415
+ return ""
416
+
417
  copy_btn.click(
418
+ copy_report,
419
+ inputs=[eval_report_storage],
420
+ outputs=[],
421
+ js="""
422
+ (text) => {
423
+ if (text && text.trim().length > 0) {
424
+ navigator.clipboard.writeText(text);
425
+ alert('βœ… Evaluation report copied to clipboard!');
426
+ } else {
427
+ alert('⚠️ No evaluation report available yet!');
428
+ }
429
+ }
430
+ """
431
+ )
432
 
433
  return demo
434