From 6cca8b80283499bab21511cb4304f9fcda7690d5 Mon Sep 17 00:00:00 2001
From: oobabooga <112222186+oobabooga@users.noreply.github.com>
Date: Mon, 21 Aug 2023 05:39:55 -0700
Subject: [PATCH] Only update notebook token counter on input
For performance during streaming
---
modules/ui_notebook.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/ui_notebook.py b/modules/ui_notebook.py
index b4b859ee..7fbf7a85 100644
--- a/modules/ui_notebook.py
+++ b/modules/ui_notebook.py
@@ -85,5 +85,5 @@ def create_event_handlers():
lambda x: x + '.txt', gradio('prompt_menu-notebook'), gradio('delete_filename')).then(
lambda: gr.update(visible=True), None, gradio('file_deleter'))
- shared.gradio['textbox-notebook'].change(lambda x : f"{count_tokens(x)}", gradio('textbox-notebook'), gradio('token-counter-notebook'), show_progress=False)
+ shared.gradio['textbox-notebook'].input(lambda x : f"{count_tokens(x)}", gradio('textbox-notebook'), gradio('token-counter-notebook'), show_progress=False)
shared.gradio['get_logits-notebook'].click(logits.get_next_logits, gradio('textbox-notebook'), gradio('logits-notebook'))