From 4144a8bbb451ed3091d8a452de825e634d6fe6f0 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Tue, 7 Nov 2023 15:44:26 -0800 Subject: [PATCH] Prevent sending an input until the previous response has been handled This would ideally use a queue but that will require using a different UI since the gradio ChatBot expects each input to return a value synchronously Relates to #26 --- neon_iris/web_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/neon_iris/web_client.py b/neon_iris/web_client.py index 7e6f92c..0e61126 100644 --- a/neon_iris/web_client.py +++ b/neon_iris/web_client.py @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - +from asyncio import Queue from os import makedirs from os.path import isfile, join, isdir from time import time @@ -128,7 +128,9 @@ def on_user_input(self, utterance: str, *args, **kwargs) -> str: @param utterance: String utterance submitted by the user @returns: String response from Neon (or "ERROR") """ - # TODO: This should probably queue with a separate iterator thread + LOG.debug(f"Input received") + if not self._await_response.wait(30): + LOG.error("Previous response not completed after 30 seconds") LOG.debug(f"args={args}|kwargs={kwargs}") self._await_response.clear() self._response = None