Spaces:
Sleeping
Sleeping
fix: gradio ui format display
Browse files- interface.py +49 -48
interface.py
CHANGED
|
@@ -83,59 +83,60 @@ def create_gradio_interface():
|
|
| 83 |
)
|
| 84 |
|
| 85 |
# Main Input Section
|
| 86 |
-
with gr.
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
)
|
| 95 |
-
model_name = gr.Radio(
|
| 96 |
-
choices=["typhoon-v1.5x-70b-instruct", "openthaigpt", "llama-3.3-70b-versatile"],
|
| 97 |
-
value="typhoon-v1.5x-70b-instruct",
|
| 98 |
-
label="Model Selection",
|
| 99 |
-
)
|
| 100 |
-
|
| 101 |
-
with gr.Column(scale=1):
|
| 102 |
-
output_selector = gr.Dropdown(
|
| 103 |
-
choices=["Chat History", "EHR Details"],
|
| 104 |
-
value="Chat History",
|
| 105 |
-
label="Select Output to Display",
|
| 106 |
-
)
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
|
| 138 |
-
|
| 139 |
|
| 140 |
# Bind Get Nurse Response button
|
| 141 |
send_button.click(
|
|
|
|
| 83 |
)
|
| 84 |
|
| 85 |
# Main Input Section
|
| 86 |
+
with gr.Row():
|
| 87 |
+
with gr.Column(scale=2):
|
| 88 |
+
chat_box = gr.Chatbot(label="Chat with MALI Nurse", scale=1)
|
| 89 |
+
send_button = gr.Button("Send", variant="primary", size="lg", scale=1)
|
| 90 |
+
with gr.Row():
|
| 91 |
+
user_input = gr.Textbox(
|
| 92 |
+
label="Your Message",
|
| 93 |
+
placeholder="Type your question or message here...",
|
| 94 |
+
lines=2,
|
| 95 |
+
)
|
| 96 |
+
model_name = gr.Radio(
|
| 97 |
+
choices=["typhoon-v1.5x-70b-instruct", "openthaigpt", "llama-3.3-70b-versatile"],
|
| 98 |
+
value="typhoon-v1.5x-70b-instruct",
|
| 99 |
+
label="Model Selection",
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
with gr.Column(scale=1):
|
| 103 |
+
output_selector = gr.Dropdown(
|
| 104 |
+
choices=["Chat History", "EHR Details"],
|
| 105 |
+
value="Chat History",
|
| 106 |
+
label="Select Output to Display",
|
| 107 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
chat_history_output = gr.Textbox(
|
| 110 |
+
label="Chat History Output",
|
| 111 |
+
interactive=False,
|
| 112 |
+
lines=6,
|
| 113 |
+
scale=1,
|
| 114 |
+
visible=True, # Initially visible
|
| 115 |
+
)
|
| 116 |
|
| 117 |
+
ehr_details_output = gr.Textbox(
|
| 118 |
+
label="EHR Details Output",
|
| 119 |
+
interactive=False,
|
| 120 |
+
lines=6,
|
| 121 |
+
scale=1,
|
| 122 |
+
visible=False, # Initially hidden
|
| 123 |
+
)
|
| 124 |
|
| 125 |
+
# Function to toggle visibility
|
| 126 |
+
def switch_output(selected_output):
|
| 127 |
+
if selected_output == "Chat History":
|
| 128 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 129 |
+
elif selected_output == "EHR Details":
|
| 130 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 131 |
+
|
| 132 |
+
# Set up the change event
|
| 133 |
+
output_selector.change(
|
| 134 |
+
fn=switch_output,
|
| 135 |
+
inputs=[output_selector],
|
| 136 |
+
outputs=[chat_history_output, ehr_details_output], # Update visibility of both components
|
| 137 |
+
)
|
| 138 |
|
| 139 |
+
notification_box = gr.Textbox(label="Error", interactive=False, lines=2)
|
| 140 |
|
| 141 |
# Bind Get Nurse Response button
|
| 142 |
send_button.click(
|