microhum commited on
Commit
adbdaee
·
1 Parent(s): 4bd456c

fix: gradio ui format display

Browse files
Files changed (1) hide show
  1. interface.py +49 -48
interface.py CHANGED
@@ -83,59 +83,60 @@ def create_gradio_interface():
83
  )
84
 
85
  # Main Input Section
86
- with gr.Column(scale=2):
87
- chat_box = gr.Chatbot(label="Chat with MALI Nurse", scale=1)
88
- send_button = gr.Button("Send", variant="primary", size="lg", scale=1)
89
- with gr.Row():
90
- user_input = gr.Textbox(
91
- label="Your Message",
92
- placeholder="Type your question or message here...",
93
- lines=2,
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- chat_history_output = gr.Textbox(
109
- label="Chat History Output",
110
- interactive=False,
111
- lines=6,
112
- scale=1,
113
- visible=True, # Initially visible
114
- )
115
 
116
- ehr_details_output = gr.Textbox(
117
- label="EHR Details Output",
118
- interactive=False,
119
- lines=6,
120
- scale=1,
121
- visible=False, # Initially hidden
122
- )
123
 
124
- # Function to toggle visibility
125
- def switch_output(selected_output):
126
- if selected_output == "Chat History":
127
- return gr.update(visible=True), gr.update(visible=False)
128
- elif selected_output == "EHR Details":
129
- return gr.update(visible=False), gr.update(visible=True)
130
-
131
- # Set up the change event
132
- output_selector.change(
133
- fn=switch_output,
134
- inputs=[output_selector],
135
- outputs=[chat_history_output, ehr_details_output], # Update visibility of both components
136
- )
137
 
138
- notification_box = gr.Textbox(label="Error", interactive=False, lines=2)
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(