Reshmarb commited on
Commit
1fea6a7
·
1 Parent(s): 76b88b3
Files changed (3) hide show
  1. app.py +40 -4
  2. bot.jpg +0 -0
  3. user.png +0 -0
app.py CHANGED
@@ -135,7 +135,36 @@ def customLLMBot(user_input, uploaded_image, chat_history):
135
 
136
  # Gradio Interface
137
  def chatbot_ui():
138
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  gr.Markdown("# Healthcare Chatbot Doctor")
140
 
141
  # State for user chat history
@@ -157,24 +186,31 @@ def chatbot_ui():
157
  clear_btn = gr.Button("Clear")
158
  audio_output = gr.Audio(label="Audio Response")
159
 
 
 
 
 
160
  # Define actions
161
  def handle_submit(user_query, image, history):
162
  logger.info("User submitted a query.")
163
  response, audio = customLLMBot(user_query, image, history)
164
- return response, audio, None,"",history # Clear the image after submission
 
 
 
165
 
166
  # Submit on pressing Enter key
167
  user_input.submit(
168
  handle_submit,
169
  inputs=[user_input, uploaded_image, chat_history],
170
- outputs=[chatbot, audio_output, uploaded_image,user_input, chat_history],
171
  )
172
 
173
  # Submit on button click
174
  submit_btn.click(
175
  handle_submit,
176
  inputs=[user_input, uploaded_image, chat_history],
177
- outputs=[chatbot, audio_output, uploaded_image,user_input, chat_history],
178
  )
179
 
180
  # Action for clearing all fields
 
135
 
136
  # Gradio Interface
137
  def chatbot_ui():
138
+ with gr.Blocks(css="""
139
+ #chatbot .chat-message {
140
+ display: flex;
141
+ align-items: flex-start;
142
+ margin-bottom: 10px;
143
+ }
144
+ #chatbot .chat-message.user {
145
+ justify-content: flex-end;
146
+ }
147
+ #chatbot .chat-message.bot img {
148
+ margin-right: 10px;
149
+ }
150
+ #chatbot .chat-message.user img {
151
+ margin-left: 10px;
152
+ }
153
+ #chatbot .chat-message img {
154
+ width: 40px;
155
+ height: 40px;
156
+ border-radius: 50%;
157
+ }
158
+ #chatbot .chat-message .message-content {
159
+ max-width: 70%;
160
+ padding: 10px;
161
+ border-radius: 8px;
162
+ background-color: #f0f0f0;
163
+ }
164
+ #chatbot .chat-message.user .message-content {
165
+ background-color: #d4f0ff;
166
+ }
167
+ """) as demo:
168
  gr.Markdown("# Healthcare Chatbot Doctor")
169
 
170
  # State for user chat history
 
186
  clear_btn = gr.Button("Clear")
187
  audio_output = gr.Audio(label="Audio Response")
188
 
189
+ # Define user and bot logos
190
+ user_logo = "user.png" # Replace with actual path
191
+ bot_logo = "bot.jpg" # Replace with actual path
192
+
193
  # Define actions
194
  def handle_submit(user_query, image, history):
195
  logger.info("User submitted a query.")
196
  response, audio = customLLMBot(user_query, image, history)
197
+
198
+ # Append user and bot messages
199
+ history = history + [(f'<img src="{user_logo}" /> {user_query}', f'<img src="{bot_logo}" /> {response}')]
200
+ return history, audio, None, "", history # Clear the image after submission
201
 
202
  # Submit on pressing Enter key
203
  user_input.submit(
204
  handle_submit,
205
  inputs=[user_input, uploaded_image, chat_history],
206
+ outputs=[chatbot, audio_output, uploaded_image, user_input, chat_history],
207
  )
208
 
209
  # Submit on button click
210
  submit_btn.click(
211
  handle_submit,
212
  inputs=[user_input, uploaded_image, chat_history],
213
+ outputs=[chatbot, audio_output, uploaded_image, user_input, chat_history],
214
  )
215
 
216
  # Action for clearing all fields
bot.jpg ADDED
user.png ADDED