import gradio as gr import os import plotly.graph_objects as go patient_info = {"id": "", "description": ""} qa_count = 0 patient_number = 0 def normalize_path(path): return os.path.normpath(path).replace('\\', '/') def reset_patient(): global patient_info, qa_count, patient_number patient_info = {"id": "", "description": ""} qa_count = 0 patient_number += 1 return ( "", # patient_desc gr.update(value=""), # qa_desc gr.update(visible=True), # patient_input gr.update(visible=False), # qa_interface gr.update(visible=False), # change_patient_btn "", # question_input "", # answer_output None, # image_output go.Figure() # graph_output (empty Plotly figure) ) def set_patient(patient_description): global patient_info, qa_count patient_info["description"] = patient_description qa_count = 0 return ( f"Patient Description: {patient_description}", gr.update(visible=True), gr.update(visible=False), "", # question_input "", # answer_output None, # image_output go.Figure(), # graph_output (empty Plotly figure) gr.update(visible=True), # ask_another_question_btn gr.update(visible=True) # change_patient_btn ) def ask_another_question(): return "", "", None, go.Figure(), gr.update(visible=True), gr.update(visible=False)