microhum commited on
Commit
36f07df
·
1 Parent(s): 70e2745

gradio re interface

Browse files
Files changed (2) hide show
  1. Dockerfile +0 -13
  2. interface.py +51 -28
Dockerfile DELETED
@@ -1,13 +0,0 @@
1
- FROM python:3.10.9
2
-
3
- RUN useradd -m -u 1000 user
4
- USER user
5
- ENV PATH="/home/user/.local/bin:$PATH"
6
-
7
- WORKDIR /app
8
-
9
- COPY --chown=user ./requirements.txt requirements.txt
10
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
11
-
12
- COPY --chown=user . /app
13
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
interface.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import requests
3
 
4
- API_BASE_URL = "http://127.0.0.1:8000" # Update this with your actual API base URL if deployed elsewhere
5
 
6
  # Function: Get nurse response
7
  def get_nurse_response(user_input, model_name, chat_history):
@@ -83,25 +83,59 @@ def create_gradio_interface():
83
  )
84
 
85
  # Main Input Section
86
- with gr.Row():
87
- with gr.Column():
88
  chat_box = gr.Chatbot(label="Chat with MALI Nurse", scale=1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- # Input Section
91
- with gr.Row():
92
- user_input = gr.Textbox(
93
- label="Your Message",
94
- placeholder="Type your question or message here...",
95
- lines=2,
96
  )
97
- model_name = gr.Radio(
98
- choices=["typhoon-v1.5x-70b-instruct", "openthaigpt", "llama-3.3-70b-versatile"],
99
- value="typhoon-v1.5x-70b-instruct",
100
- label="Model Selection",
 
 
 
101
  )
102
- with gr.Column():
103
- send_button = gr.Button("Send", variant="primary", size="lg")
104
- notification_box = gr.Textbox(interactive=False, lines=2)
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  # Bind Get Nurse Response button
107
  send_button.click(
@@ -117,16 +151,7 @@ def create_gradio_interface():
117
  chat_history_button = gr.Button("View Chat History")
118
  ehr_details_button = gr.Button("View EHR Details")
119
  with gr.Column():
120
- chat_history_output = gr.Textbox(
121
- label="Chat History",
122
- interactive=False,
123
- lines=6,
124
- )
125
- ehr_details_output = gr.Textbox(
126
- label="EHR Details",
127
- interactive=False,
128
- lines=6,
129
- )
130
  ehr_prompt_output = gr.Textbox(
131
  label="Outputs",
132
  interactive=False,
@@ -151,14 +176,12 @@ def create_gradio_interface():
151
  )
152
 
153
  send_button.click(
154
- fn=view_chat_history,
155
  fn=view_ehr_details,
156
  inputs=[gr.Textbox(value="details", visible=False)],
157
  outputs=ehr_details_output
158
  )
159
 
160
  send_button.click(
161
- fn=view_chat_history,
162
  fn=view_ehr_details,
163
  inputs=[gr.Textbox(value="prompt", visible=False)],
164
  outputs=ehr_prompt_output
 
1
  import gradio as gr
2
  import requests
3
 
4
+ API_BASE_URL = "http://localhost:8000" # Update this with your actual API base URL if deployed elsewhere
5
 
6
  # Function: Get nurse response
7
  def get_nurse_response(user_input, model_name, chat_history):
 
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(
 
151
  chat_history_button = gr.Button("View Chat History")
152
  ehr_details_button = gr.Button("View EHR Details")
153
  with gr.Column():
154
+
 
 
 
 
 
 
 
 
 
155
  ehr_prompt_output = gr.Textbox(
156
  label="Outputs",
157
  interactive=False,
 
176
  )
177
 
178
  send_button.click(
 
179
  fn=view_ehr_details,
180
  inputs=[gr.Textbox(value="details", visible=False)],
181
  outputs=ehr_details_output
182
  )
183
 
184
  send_button.click(
 
185
  fn=view_ehr_details,
186
  inputs=[gr.Textbox(value="prompt", visible=False)],
187
  outputs=ehr_prompt_output