Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
def process(a): | |
out = a | |
return out | |
df = None | |
row_num = -1 | |
assessments=["N/A"] | |
txt1 = gr.Textbox(label='1st CHEW APSO Note', lines=16, interactive=False) | |
txt2 = gr.Textbox(label='GPT-4\'s Response', lines=16, interactive=False) | |
txt3 = gr.Textbox(label='2nd CHEW APSO Note', lines=16, interactive=False) | |
txt4 = gr.Textbox(label='Medical Officer\'s APSO Note', lines=16, interactive=False) | |
txt5 = gr.Textbox(label='Ravi 4-word', lines=16, interactive=False) | |
txt6 = gr.Textbox(label='Ravi Feedback 1', lines=16, interactive=False) | |
txt7 = gr.Textbox(label='Ravi Feedback 2', lines=16, interactive=False) | |
submit = gr.Button("Submit", variant='primary') | |
ddown = gr.Dropdown(assessments, label="Assessment", info="Select an assessment by clicking its ID", value=None, interactive=True) | |
def update_text(d): | |
out = ['']*7 | |
if d != None: | |
row_num = (df.assessment_id.values == d).argmax() | |
out[0] = df['soap_note'][row_num] | |
out[1] = df['ai_note'][row_num] | |
out[2] = df['soap_note'][row_num+1] | |
out[3] = df['soap_note'][row_num+2] | |
out[4] = df['4 word Ravi takeaway'][row_num] | |
out[5] = df['Ravi feedback to CHEW unassisted note'][row_num] | |
out[6] = df['Ravi feedback to GPT4 note'][row_num] | |
return out | |
def update_choices(files): | |
global df | |
assessments = [] | |
for f_o in files: | |
print(f_o) | |
df = pd.read_excel(f_o.name) | |
tmp = set(df['assessment_id'].tolist()) | |
for x in tmp: | |
if not (x in assessments): | |
assessments.append(x) | |
print(assessments) | |
return gr.update(choices=[c for c in assessments], value=None) | |
with gr.Blocks() as iface: | |
with gr.Row(): | |
with gr.Column(scale=1): | |
txt1.render() | |
with gr.Column(scale=1): | |
txt2.render() | |
with gr.Column(scale=1): | |
txt3.render() | |
with gr.Column(scale=1): | |
txt4.render() | |
with gr.Row(): | |
with gr.Column(scale=1): | |
txt5.render() | |
with gr.Column(scale=1): | |
txt6.render() | |
with gr.Column(scale=1): | |
txt7.render() | |
with gr.Row(): | |
with gr.Column(scale=1): | |
file_output = gr.File(file_count='multiple') | |
file_output.change(update_choices, inputs=[file_output], outputs=[ddown]) | |
with gr.Column(scale=1): | |
ddown.render() | |
ddown.change(update_text, inputs=[ddown], outputs=[txt1, txt2, txt3, txt4, txt5, txt6, txt7]) | |
iface.launch(debug=True) |