Miquel Farré commited on
Commit
0185d4a
·
1 Parent(s): 2defc46

changing behavior after failure

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -484,10 +484,26 @@ with gr.Blocks(css=custom_css, js=custom_js) as demo:
484
  outputs=results_output
485
  )
486
 
487
- # 3. Then set back to interactive mode
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
  task_result.then(
489
- fn=set_interactive_mode,
490
- inputs=None, # No inputs needed here
491
  outputs=html_output
492
  )
493
 
 
484
  outputs=results_output
485
  )
486
 
487
+ # # 3. Then set back to interactive mode
488
+ # task_result.then(
489
+ # fn=set_interactive_mode,
490
+ # inputs=None, # No inputs needed here
491
+ # outputs=html_output
492
+ # )
493
+
494
+ # 3. Define a function to check the result and only return to interactive mode if successful
495
+ def check_result_and_set_mode(result, request: gr.Request):
496
+ # Only switch back to interactive mode if the agent completed successfully
497
+ if result.startswith("Task completed:"):
498
+ return update_html(True, request)
499
+ else:
500
+ # Keep the view-only mode (with BSOD displayed by JS)
501
+ return None
502
+
503
+ # 3. Then conditionally set back to interactive mode based on success
504
  task_result.then(
505
+ fn=check_result_and_set_mode,
506
+ inputs=[results_output], # Pass the result text to check
507
  outputs=html_output
508
  )
509