VladyslavH commited on
Commit
f290234
·
1 Parent(s): aefce63
Files changed (2) hide show
  1. app.py +20 -14
  2. static/style.css +41 -0
app.py CHANGED
@@ -277,7 +277,6 @@ def bot(
277
  yield _clean_history_for_display(history)
278
 
279
  assistant_message = history[-1]["content"]
280
- logger.log_interaction(user=user_message_text, answer=assistant_message)
281
 
282
 
283
  # --- drop-in UI compatible with older Gradio versions ---
@@ -367,6 +366,13 @@ with gr.Blocks(theme=THEME, css=CSS, fill_height=True) as demo:
367
  elem_id="chat-input",
368
  elem_classes=["chat-input-box"]
369
  )
 
 
 
 
 
 
 
370
  stop_btn_visible = gr.Button(
371
  "⏹️",
372
  variant="secondary",
@@ -387,40 +393,40 @@ with gr.Blocks(theme=THEME, css=CSS, fill_height=True) as demo:
387
  gr.HTML('<div class="footer-tip">Shortcuts: Enter to send • Shift+Enter for new line</div>')
388
 
389
  # Helper functions for managing UI state
390
- def show_stop_button():
391
- return gr.update(visible=True)
392
 
393
- def hide_stop_button():
394
- return gr.update(visible=False)
395
 
396
  # Events (preserve your original handlers)
397
  e1 = msg.submit(fn=user, inputs=[msg, image_input, chatbot], outputs=[msg, image_input, chatbot], queue=True).then(
398
- fn=show_stop_button, inputs=None, outputs=stop_btn_visible
399
  ).then(
400
  fn=bot, inputs=chatbot, outputs=chatbot
401
  ).then(
402
- fn=hide_stop_button, inputs=None, outputs=stop_btn_visible
403
  )
404
 
405
- e2 = send_btn.click(fn=user, inputs=[msg, image_input, chatbot], outputs=[msg, image_input, chatbot], queue=True).then(
406
- fn=show_stop_button, inputs=None, outputs=stop_btn_visible
407
  ).then(
408
  fn=bot, inputs=chatbot, outputs=chatbot
409
  ).then(
410
- fn=hide_stop_button, inputs=None, outputs=stop_btn_visible
411
  )
412
 
413
  e3 = chatbot.example_select(fn=append_example_message, inputs=[chatbot], outputs=[chatbot], queue=True).then(
414
- fn=show_stop_button, inputs=None, outputs=stop_btn_visible
415
  ).then(
416
  fn=bot, inputs=chatbot, outputs=chatbot
417
  ).then(
418
- fn=hide_stop_button, inputs=None, outputs=stop_btn_visible
419
  )
420
 
421
  # Stop cancels running events (both buttons work)
422
- stop_btn.click(fn=hide_stop_button, inputs=None, outputs=stop_btn_visible, cancels=[e1, e2, e3], queue=True)
423
- stop_btn_visible.click(fn=hide_stop_button, inputs=None, outputs=stop_btn_visible, cancels=[e1, e2, e3], queue=True)
424
 
425
  # Clear chat + input
426
  clear_btn.click(fn=_clear_chat, inputs=None, outputs=[msg, image_input, chatbot])
 
277
  yield _clean_history_for_display(history)
278
 
279
  assistant_message = history[-1]["content"]
 
280
 
281
 
282
  # --- drop-in UI compatible with older Gradio versions ---
 
366
  elem_id="chat-input",
367
  elem_classes=["chat-input-box"]
368
  )
369
+ send_btn_visible = gr.Button(
370
+ "➤",
371
+ variant="primary",
372
+ elem_id="send-btn-visible",
373
+ elem_classes=["send-btn-chat"],
374
+ size="sm"
375
+ )
376
  stop_btn_visible = gr.Button(
377
  "⏹️",
378
  variant="secondary",
 
393
  gr.HTML('<div class="footer-tip">Shortcuts: Enter to send • Shift+Enter for new line</div>')
394
 
395
  # Helper functions for managing UI state
396
+ def show_stop_hide_send():
397
+ return gr.update(visible=True), gr.update(visible=False)
398
 
399
+ def hide_stop_show_send():
400
+ return gr.update(visible=False), gr.update(visible=True)
401
 
402
  # Events (preserve your original handlers)
403
  e1 = msg.submit(fn=user, inputs=[msg, image_input, chatbot], outputs=[msg, image_input, chatbot], queue=True).then(
404
+ fn=show_stop_hide_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible]
405
  ).then(
406
  fn=bot, inputs=chatbot, outputs=chatbot
407
  ).then(
408
+ fn=hide_stop_show_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible]
409
  )
410
 
411
+ e2 = send_btn_visible.click(fn=user, inputs=[msg, image_input, chatbot], outputs=[msg, image_input, chatbot], queue=True).then(
412
+ fn=show_stop_hide_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible]
413
  ).then(
414
  fn=bot, inputs=chatbot, outputs=chatbot
415
  ).then(
416
+ fn=hide_stop_show_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible]
417
  )
418
 
419
  e3 = chatbot.example_select(fn=append_example_message, inputs=[chatbot], outputs=[chatbot], queue=True).then(
420
+ fn=show_stop_hide_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible]
421
  ).then(
422
  fn=bot, inputs=chatbot, outputs=chatbot
423
  ).then(
424
+ fn=hide_stop_show_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible]
425
  )
426
 
427
  # Stop cancels running events (both buttons work)
428
+ stop_btn.click(fn=hide_stop_show_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible], cancels=[e1, e2, e3], queue=True)
429
+ stop_btn_visible.click(fn=hide_stop_show_send, inputs=None, outputs=[stop_btn_visible, send_btn_visible], cancels=[e1, e2, e3], queue=True)
430
 
431
  # Clear chat + input
432
  clear_btn.click(fn=_clear_chat, inputs=None, outputs=[msg, image_input, chatbot])
static/style.css CHANGED
@@ -189,6 +189,47 @@
189
  display: none;
190
  }
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  /* Right pane cards */
193
  .side-card {
194
  border: 1px solid rgba(59,130,246,0.2);
 
189
  display: none;
190
  }
191
 
192
+ /* Visible Send button styling */
193
+ .send-btn-chat {
194
+ flex-shrink: 0 !important;
195
+ width: 45px !important;
196
+ min-width: 45px !important;
197
+ max-width: 45px !important;
198
+ height: 45px !important;
199
+ margin: 0 !important;
200
+ padding: 0 !important;
201
+ border-radius: 100% !important;
202
+ }
203
+
204
+ .send-btn-chat button {
205
+ background: linear-gradient(135deg, #93c5fd 0%, #bfdbfe 100%) !important; /* light blue */
206
+ border: 1px solid rgba(147, 197, 253, 0.7) !important; /* light blue border */
207
+ color: #1e3a8a !important; /* deep blue icon/text for contrast */
208
+ border-radius: 50% !important;
209
+ padding: 6px !important;
210
+ min-width: 45px !important;
211
+ max-width: 45px !important;
212
+ width: 45px !important;
213
+ height: 45px !important;
214
+ font-size: 14px !important;
215
+ font-weight: 700 !important;
216
+ transition: all 0.2s ease !important;
217
+ display: flex !important;
218
+ align-items: center !important;
219
+ justify-content: center !important;
220
+ box-shadow: 0 6px 14px rgba(147, 197, 253, 0.45) !important; /* soft light-blue glow */
221
+ }
222
+
223
+ .send-btn-chat button:hover {
224
+ filter: brightness(1.03) !important;
225
+ transform: translateY(-1px) !important;
226
+ box-shadow: 0 10px 20px rgba(147, 197, 253, 0.55) !important;
227
+ }
228
+
229
+ .send-btn-chat button:active {
230
+ transform: translateY(0) scale(0.98) !important;
231
+ }
232
+
233
  /* Right pane cards */
234
  .side-card {
235
  border: 1px solid rgba(59,130,246,0.2);