khang119966 commited on
Commit
9875a55
·
verified ·
1 Parent(s): b7839ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -250,6 +250,7 @@ We currently only support one image at the start of the context! Please start a
250
  time.sleep(0.02)
251
  yield generated_text_without_prompt
252
  else:
 
253
  ####################################################### thinking #######################################################
254
  generation_config = dict(max_new_tokens= 2000, do_sample=False, num_beams = 2, repetition_penalty=2.5)
255
 
@@ -410,6 +411,9 @@ def toggle_think_mode(current_state):
410
  print("global_think_mode: ",global_think_mode,"="*20)
411
  button_label = "🧠DeepThink💡1minute⏳" if global_think_mode else "🧠Think"
412
  return new_state, button_label
 
 
 
413
 
414
  demo = gr.Blocks(css=CSS,js=js, theme='NoCrypt/miku')
415
  # demo = gr.Blocks( theme='NoCrypt/miku')
@@ -438,10 +442,7 @@ with demo:
438
 
439
  # Khi nhấn nút, trạng thái think_mode thay đổi + đổi nhãn nút
440
  think_button.click(toggle_think_mode, inputs=[think_mode], outputs=[think_mode, think_button])
441
- # chat_demo_interface.submit(
442
- # after_response,
443
- # inputs=[think_mode],
444
- # outputs=[think_mode, think_button]
445
- # )
446
 
447
  demo.queue().launch()
 
250
  time.sleep(0.02)
251
  yield generated_text_without_prompt
252
  else:
253
+ global_think_mode = False
254
  ####################################################### thinking #######################################################
255
  generation_config = dict(max_new_tokens= 2000, do_sample=False, num_beams = 2, repetition_penalty=2.5)
256
 
 
411
  print("global_think_mode: ",global_think_mode,"="*20)
412
  button_label = "🧠DeepThink💡1minute⏳" if global_think_mode else "🧠Think"
413
  return new_state, button_label
414
+
415
+ def reset_think_mode():
416
+ return False, "🧠Think" # Trả về trạng thái mặc định
417
 
418
  demo = gr.Blocks(css=CSS,js=js, theme='NoCrypt/miku')
419
  # demo = gr.Blocks( theme='NoCrypt/miku')
 
442
 
443
  # Khi nhấn nút, trạng thái think_mode thay đổi + đổi nhãn nút
444
  think_button.click(toggle_think_mode, inputs=[think_mode], outputs=[think_mode, think_button])
445
+ # Reset nút Think sau khi chat hoàn tất
446
+ chat_demo_interface.submit(reset_think_mode, inputs=[], outputs=[think_mode, think_button])
 
 
 
447
 
448
  demo.queue().launch()