mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-15 02:11:15 +08:00
da05e59a53
* changes
* add changeset
* changes
* changes
* Update many-tips-create.md
* notebooks
* chanegs
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changew
* changes
* changes
* changes
* changes
* chanegs
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* changes
* Revert "changes"
This reverts commit 0868c25c56
.
* changes
* changes
* changes
* changes
* changes
* changes
* change
* changes
* chaneges
* changes
* chagnes
* changes
* changes
* changes
* changes
* changes
* fix typing
* changes
---------
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import gradio as gr
|
|
|
|
with gr.Blocks() as demo:
|
|
error_box = gr.Textbox(label="Error", visible=False)
|
|
|
|
name_box = gr.Textbox(label="Name")
|
|
age_box = gr.Number(label="Age", minimum=0, maximum=100)
|
|
symptoms_box = gr.CheckboxGroup(["Cough", "Fever", "Runny Nose"])
|
|
submit_btn = gr.Button("Submit")
|
|
|
|
with gr.Column(visible=False) as output_col:
|
|
diagnosis_box = gr.Textbox(label="Diagnosis")
|
|
patient_summary_box = gr.Textbox(label="Patient Summary")
|
|
|
|
def submit(name, age, symptoms):
|
|
if len(name) == 0:
|
|
return {error_box: gr.Textbox(value="Enter name", visible=True)}
|
|
return {
|
|
output_col: gr.Column(visible=True),
|
|
diagnosis_box: "covid" if "Cough" in symptoms else "flu",
|
|
patient_summary_box: f"{name}, {age} y/o",
|
|
}
|
|
|
|
submit_btn.click(
|
|
submit,
|
|
[name_box, age_box, symptoms_box],
|
|
[error_box, diagnosis_box, patient_summary_box, output_col],
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|