Spaces:
Sleeping
Sleeping
Commit Β·
5d3bbea
1
Parent(s): f2eac81
added first name and last name logging fields
Browse files55 unmodified lines56575859606162636438 unmodified lines1031041051061071081091101111121131141151161171181199 unmodified lines12913013113213313413513613713813914014155 unmodified linesquestion_state = gr.State({}) # holds the question dictso_state = gr.State("") # holds Subjective & Objective text# ββββββββββββββββββββββββββββββββββββββββββββββββββ Stepβ―1 Demographics β Questionswith gr.Row():age_input = gr.Number(label="Age (years)", precision=0)gender_input = gr.Dropdown(["Male", "Female"], label="Gender")cc_input = gr.Textbox(lines=2, label="Chief Complaint")gen_q_btn = gr.Button("Generate Questions", elem_classes="orange-btn")38 unmodified lines# Callbacks# -------------------------------------------------------------------------def _gen_questions(age, gender, cc):"""Call LLM β get question dict, then reveal answer boxes."""try:q_dict = generate_question_dict(age, gender, cc)except json.JSONDecodeError:# Return fixedβlength output list even on failurereturn ("β οΈ LLM failed to return valid JSON. Please try again.",*[gr.update(visible=False) for _ in range(MAX_QUESTIONS)],gr.update(visible=False),{},)# Prepare exactly MAX_QUESTIONS Textbox updates9 unmodified lines*box_updates, # Answer boxesgr.update(visible=True), # Show the column with answers & vitals inputsq_dict, # Save question dict to stategr.update(visible=False), # Hide loader)# Show loader quickly then run callbackgen_q_btn.click(lambda: gr.update(visible=True), None, loading_md, queue=False).then(_gen_questions,[age_input, gender_input, cc_input],[*answer_boxes, answer_sec, question_state, loading_md],)55 unmodified lines56575859606162636465666768697038 unmodified lines1091101111121131141151161171181191201211221231241251261271281291301311321339 unmodified lines14314414514614714814915015115215315415555 unmodified linesquestion_state = gr.State({}) # holds the question dictso_state = gr.State("") # holds Subjective & Objective text# ββββββββββββββββββββββββββββββββββββββββββββββββββ Step 1 Demographics β Questions# Personal detailswith gr.Row():name_input = gr.Textbox(label="Full Name", placeholder="Enter full name")email_input = gr.Textbox(label="Email Address", placeholder="Enter email address")# Demographics and chief complaintwith gr.Row():age_input = gr.Number(label="Age (years)", precision=0, value=None)gender_input = gr.Dropdown(["Male", "Female"], label="Gender")cc_input = gr.Textbox(lines=2, label="Chief Complaint")gen_q_btn = gr.Button("Generate Questions", elem_classes="orange-btn")38 unmodified lines# Callbacks# -------------------------------------------------------------------------def _gen_questions(name, email, age, gender, cc):"""Validate required fields, then call LLM β get question dict, then reveal answer boxes."""# Ensure required fields are providedif not name or not email:return (*[gr.update(visible=False) for _ in range(MAX_QUESTIONS)], # hide answer boxesgr.update(visible=False), # hide answers section{}, # clear question stategr.update(value="β οΈ Please enter both Full Name and Email address.", visible=True), # show error)try:q_dict = generate_question_dict(age, gender, cc)except json.JSONDecodeError:return (*[gr.update(visible=False) for _ in range(MAX_QUESTIONS)],gr.update(visible=False),{},gr.update(value="β οΈ LLM failed to return valid JSON. Please try again.", visible=True),)# Prepare exactly MAX_QUESTIONS Textbox updates9 unmodified lines*box_updates, # Answer boxesgr.update(visible=True), # Show the column with answers & vitals inputsq_dict, # Save question dict to stategr.update(visible=False), # Hide loader / message)# Show loader quickly then run callbackgen_q_btn.click(lambda: gr.update(value="β³ Loading ...", visible=True), None, loading_md, queue=False).then(_gen_questions,[name_input, email_input, age_input, gender_input, cc_input],[*answer_boxes, answer_sec, question_state, loading_md],)
app.py+23-9