Crackershoot commited on
Commit
13737dd
·
verified ·
1 Parent(s): 853a786

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -264,23 +264,23 @@ theme = gr.themes.Ocean(
264
  demo_css = """
265
  .chatbot {
266
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
267
- font-size: 12px !important;
268
  }
269
 
270
  .chatbot .message code,
271
  .chatbot .message pre {
272
- font-size: 12px !important;
273
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
274
  }
275
 
276
  .component {
277
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
278
- font-size: 12px !important;
279
  }
280
 
281
  .gradio-container .examples {
282
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
283
- font-size: 12px !important;
284
  }
285
  """
286
 
@@ -315,6 +315,7 @@ with gr.Blocks(
315
  #ask_btn = gr.Button("Submit 📤", variant="primary")
316
  with gr.Row():
317
  ask_btn = gr.Button("Submit 📤", variant="primary", elem_classes="component")
 
318
  clear_btn = gr.Button("🧹 Clear Chat", elem_classes="component")
319
  # A section for example questions.
320
  gr.Markdown("### 💡 Example Questions", elem_classes="component")
@@ -402,7 +403,22 @@ with gr.Blocks(
402
  gr.update(value=None, visible=False), # Keep image preview hidden for now.
403
  "" # Keep textbox clear.
404
  )
405
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  # This is a helper function to avoid repeating the event handler chain.
407
  def submit_chain():
408
  # It specifies that `chat_ui` is the function to run.
 
264
  demo_css = """
265
  .chatbot {
266
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
267
+ font-size: 13px !important;
268
  }
269
 
270
  .chatbot .message code,
271
  .chatbot .message pre {
272
+ font-size: 13px !important;
273
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
274
  }
275
 
276
  .component {
277
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
278
+ font-size: 13px !important;
279
  }
280
 
281
  .gradio-container .examples {
282
  font-family: 'Inter', 'Segoe UI', sans-serif !important;
283
+ font-size: 13px !important;
284
  }
285
  """
286
 
 
315
  #ask_btn = gr.Button("Submit 📤", variant="primary")
316
  with gr.Row():
317
  ask_btn = gr.Button("Submit 📤", variant="primary", elem_classes="component")
318
+ regen_btn = gr.Button("🔄 Regenerate", elem_classes="component")
319
  clear_btn = gr.Button("🧹 Clear Chat", elem_classes="component")
320
  # A section for example questions.
321
  gr.Markdown("### 💡 Example Questions", elem_classes="component")
 
403
  gr.update(value=None, visible=False), # Keep image preview hidden for now.
404
  "" # Keep textbox clear.
405
  )
406
+
407
+ def regen_wrapper(chat_history):
408
+ if not chat_history or len(chat_history) < 2:
409
+ return chat_history, None, None, ""
410
+
411
+ last_user_msg = chat_history[-2]["content"]
412
+ new_history = chat_history[:-1]
413
+
414
+ return chat_ui(last_user_msg, new_history, "Hybrid")
415
+
416
+ regen_btn.click(
417
+ regen_wrapper,
418
+ inputs=chatbot,
419
+ outputs=[chatbot, link_state, output_image, question]
420
+ )
421
+
422
  # This is a helper function to avoid repeating the event handler chain.
423
  def submit_chain():
424
  # It specifies that `chat_ui` is the function to run.