Jeremy Live commited on
Commit
6f1251a
·
1 Parent(s): 50d0005
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -399,24 +399,36 @@ def create_interface():
399
  agent_thoughts,
400
  generated_code,
401
  execution_output,
402
- None, # This is for plot_output (we'll handle it separately)
403
- None # This is for image_output (we'll handle it separately)
404
  ]
405
 
406
  def process_results(chat, thoughts, code, output, plot_path):
407
  # This function will be called after run_crewai_process
408
  # Show the image in the image_output component
409
- return chat, thoughts, code, output, gr.update(visible=plot_path is not None), gr.update(value=plot_path, visible=plot_path is not None)
 
 
 
 
 
 
 
 
410
 
411
- submit_btn.click(
 
412
  fn=run_crewai_process,
413
  inputs=inputs,
414
  outputs=outputs,
415
  api_name="analyze"
416
- ).then(
 
 
 
417
  fn=process_results,
418
  inputs=[final_answer_chat, agent_thoughts, generated_code, execution_output, image_output],
419
- outputs=[final_answer_chat, agent_thoughts, generated_code, execution_output, plot_output, image_output]
420
  )
421
 
422
  return interface
 
399
  agent_thoughts,
400
  generated_code,
401
  execution_output,
402
+ plot_output, # Pass the actual component, not None
403
+ image_output # Pass the actual component, not None
404
  ]
405
 
406
  def process_results(chat, thoughts, code, output, plot_path):
407
  # This function will be called after run_crewai_process
408
  # Show the image in the image_output component
409
+ return [
410
+ chat,
411
+ thoughts,
412
+ code,
413
+ output,
414
+ gr.update(visible=plot_path is not None and os.path.exists(plot_path)),
415
+ gr.update(value=plot_path if (plot_path and os.path.exists(plot_path)) else None,
416
+ visible=plot_path is not None and os.path.exists(plot_path))
417
+ ]
418
 
419
+ # First, run the crewAI process
420
+ click_event = submit_btn.click(
421
  fn=run_crewai_process,
422
  inputs=inputs,
423
  outputs=outputs,
424
  api_name="analyze"
425
+ )
426
+
427
+ # Then update the UI with the results
428
+ click_event.then(
429
  fn=process_results,
430
  inputs=[final_answer_chat, agent_thoughts, generated_code, execution_output, image_output],
431
+ outputs=outputs
432
  )
433
 
434
  return interface