khang119966 commited on
Commit
acaae82
·
verified ·
1 Parent(s): 6492ca5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -233,7 +233,8 @@ We currently only support one image at the start of the context! Please start a
233
  time.sleep(0.02)
234
  yield generated_text_without_prompt
235
  else:
236
- generation_config = dict(max_new_tokens= 2000, do_sample=False, num_beams = 3, repetition_penalty=2.0)
 
237
 
238
  if len(history) == 0:
239
  if pixel_values is not None:
@@ -273,7 +274,7 @@ We currently only support one image at the start of the context! Please start a
273
  for char in thinking:
274
  temp_text += char
275
  yield accumulated_text + temp_text + "\n</code></pre>\n\n---\n"
276
- time.sleep(0.02)
277
 
278
  accumulated_text += temp_text + "\n</code></pre>\n\n---\n"
279
 
@@ -284,7 +285,7 @@ We currently only support one image at the start of the context! Please start a
284
  for char in conclusion_part:
285
  temp_text += char
286
  yield accumulated_text + temp_text + "\n\n---\n"
287
- time.sleep(0.02)
288
 
289
  accumulated_text += temp_text + "\n\n---\n"
290
 
@@ -313,9 +314,9 @@ CSS ="""
313
  border-style: solid;
314
  overflow: hidden;
315
  flex-grow: 7;
316
- min-width: min(160px, 100%);
317
  border-width: var(--block-border-width);
318
- height: 100px !important;
319
  }
320
 
321
  #think-button {
@@ -383,13 +384,21 @@ function forceLightTheme() {
383
  }
384
  """
385
 
386
- # Hàm bật/tắt Think Mode
 
 
 
 
 
 
387
  def toggle_think_mode(current_state):
388
  global global_think_mode
389
  new_state = not current_state
390
- global_think_mode = not global_think_mode
391
  button_label = "🧠Think💡" if new_state else "🧠Think"
392
- return new_state, button_label
 
 
393
 
394
  demo = gr.Blocks(css=CSS,js=js, theme='NoCrypt/miku')
395
 
 
233
  time.sleep(0.02)
234
  yield generated_text_without_prompt
235
  else:
236
+ ####################################################### thinking #######################################################
237
+ generation_config = dict(max_new_tokens= 2000, do_sample=False, num_beams = 2, repetition_penalty=2.0)
238
 
239
  if len(history) == 0:
240
  if pixel_values is not None:
 
274
  for char in thinking:
275
  temp_text += char
276
  yield accumulated_text + temp_text + "\n</code></pre>\n\n---\n"
277
+ time.sleep(0.002)
278
 
279
  accumulated_text += temp_text + "\n</code></pre>\n\n---\n"
280
 
 
285
  for char in conclusion_part:
286
  temp_text += char
287
  yield accumulated_text + temp_text + "\n\n---\n"
288
+ time.sleep(0.01)
289
 
290
  accumulated_text += temp_text + "\n\n---\n"
291
 
 
314
  border-style: solid;
315
  overflow: hidden;
316
  flex-grow: 7;
317
+ min-width: min(160px, 100%);
318
  border-width: var(--block-border-width);
319
+ height: 10dvh !important;
320
  }
321
 
322
  #think-button {
 
384
  }
385
  """
386
 
387
+ # def toggle_think_mode(current_state):
388
+ # global global_think_mode
389
+ # new_state = not current_state
390
+ # global_think_mode = not global_think_mode
391
+ # button_label = "🧠Think💡" if new_state else "🧠Think"
392
+ # return new_state, button_label
393
+
394
  def toggle_think_mode(current_state):
395
  global global_think_mode
396
  new_state = not current_state
397
+ global_think_mode = new_state
398
  button_label = "🧠Think💡" if new_state else "🧠Think"
399
+ # Khi Think Mode bật, đổi nền chat thành đỏ, khi tắt quay về mặc định
400
+ chat_bg_color = "#ffcccc" if new_state else "#ffffff"
401
+ return new_state, button_label, gr.update(css=f"body {{ background-color: {chat_bg_color}; }}")
402
 
403
  demo = gr.Blocks(css=CSS,js=js, theme='NoCrypt/miku')
404