davidberenstein1957 HF staff commited on
Commit
b2f617d
1 Parent(s): 2081532

Set queue to False

Browse files
Files changed (1) hide show
  1. chat_interface_preference.py +11 -11
chat_interface_preference.py CHANGED
@@ -308,13 +308,13 @@ class ChatInterface(Blocks):
308
  self._setup_api()
309
 
310
  def _setup_events(self) -> None:
311
- submit_fn = self._stream_fn if self.is_generator else self._submit_fn
312
- submit_triggers = (
313
  [self.textbox.submit, self.submit_btn_one.click] if self.submit_btn_one else [self.textbox.submit]
314
  )
315
- submit_fn_partial = functools.partial(submit_fn, n_generations=2)
316
  submit_triggers_two = [self.submit_btn_two.click]
317
- for _fn, _triggers in [(submit_fn, submit_triggers), (submit_fn_partial, submit_triggers_two)]:
318
  submit_event = (
319
  on(
320
  _triggers,
@@ -339,7 +339,7 @@ class ChatInterface(Blocks):
339
  concurrency_limit=cast(Union[int, Literal["default"], None], self.concurrency_limit),
340
  )
341
  )
342
- self._setup_stop_events(submit_triggers, submit_event)
343
 
344
  partial_fn_a, partial_fn_b, partial_fn_ab = (
345
  functools.partial(self._log_fn, log="a"),
@@ -356,13 +356,13 @@ class ChatInterface(Blocks):
356
  [self.saved_input, self.chatbot_state],
357
  [self.chatbot, self.saved_input, self.chatbot_state],
358
  show_api=False,
359
- queue=True,
360
  ).then(
361
  async_lambda(lambda x: x),
362
  [self.saved_input],
363
  [self.textbox],
364
  show_api=False,
365
- queue=True,
366
  )
367
 
368
  # if self.retry_btn:
@@ -430,14 +430,14 @@ class ChatInterface(Blocks):
430
  None,
431
  [self.submit_btn_one, self.stop_btn],
432
  show_api=False,
433
- queue=True,
434
  )
435
  event_to_cancel.then(
436
  async_lambda(lambda: (Button(visible=True), Button(visible=False))),
437
  None,
438
  [self.submit_btn_one, self.stop_btn],
439
  show_api=False,
440
- queue=True,
441
  )
442
  else:
443
  for event_trigger in event_triggers:
@@ -446,14 +446,14 @@ class ChatInterface(Blocks):
446
  None,
447
  [self.stop_btn],
448
  show_api=False,
449
- queue=True,
450
  )
451
  event_to_cancel.then(
452
  async_lambda(lambda: Button(visible=False)),
453
  None,
454
  [self.stop_btn],
455
  show_api=False,
456
- queue=True,
457
  )
458
  self.stop_btn.click(
459
  None,
 
308
  self._setup_api()
309
 
310
  def _setup_events(self) -> None:
311
+ submit_fn_one = self._stream_fn if self.is_generator else self._submit_fn
312
+ submit_triggers_one = (
313
  [self.textbox.submit, self.submit_btn_one.click] if self.submit_btn_one else [self.textbox.submit]
314
  )
315
+ submit_fn_two = functools.partial(submit_fn_one, n_generations=2)
316
  submit_triggers_two = [self.submit_btn_two.click]
317
+ for _fn, _triggers in [(submit_fn_one, submit_triggers_one), (submit_fn_two, submit_triggers_two)]:
318
  submit_event = (
319
  on(
320
  _triggers,
 
339
  concurrency_limit=cast(Union[int, Literal["default"], None], self.concurrency_limit),
340
  )
341
  )
342
+ self._setup_stop_events(_triggers, submit_event)
343
 
344
  partial_fn_a, partial_fn_b, partial_fn_ab = (
345
  functools.partial(self._log_fn, log="a"),
 
356
  [self.saved_input, self.chatbot_state],
357
  [self.chatbot, self.saved_input, self.chatbot_state],
358
  show_api=False,
359
+ queue=False,
360
  ).then(
361
  async_lambda(lambda x: x),
362
  [self.saved_input],
363
  [self.textbox],
364
  show_api=False,
365
+ queue=False,
366
  )
367
 
368
  # if self.retry_btn:
 
430
  None,
431
  [self.submit_btn_one, self.stop_btn],
432
  show_api=False,
433
+ queue=False,
434
  )
435
  event_to_cancel.then(
436
  async_lambda(lambda: (Button(visible=True), Button(visible=False))),
437
  None,
438
  [self.submit_btn_one, self.stop_btn],
439
  show_api=False,
440
+ queue=False,
441
  )
442
  else:
443
  for event_trigger in event_triggers:
 
446
  None,
447
  [self.stop_btn],
448
  show_api=False,
449
+ queue=False,
450
  )
451
  event_to_cancel.then(
452
  async_lambda(lambda: Button(visible=False)),
453
  None,
454
  [self.stop_btn],
455
  show_api=False,
456
+ queue=False,
457
  )
458
  self.stop_btn.click(
459
  None,