From 5b5a18d73b9b90f1fa110d8fde63c8be0ee1628b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Thu, 19 Oct 2023 16:13:05 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20parametrize=20typing=5Floop=20wi?= =?UTF-8?q?th=20`typing=5Floop`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nio_llm/client.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/nio_llm/client.py b/src/nio_llm/client.py index c2aa204..7f89a82 100644 --- a/src/nio_llm/client.py +++ b/src/nio_llm/client.py @@ -74,14 +74,22 @@ class LLMClient(AsyncClient): # add callbacks self.add_event_callback(self.message_callback, RoomMessageText) # type: ignore - async def typing_loop(self) -> None: - """Send typing indicators every 5 seconds.""" + async def typing_loop( + self, + sleep_time: int = 10, + ) -> None: + """Send typing indicators every `sleep_time` seconds. + + Args: + sleep_time (`int`, default `10`): + The time to sleep between sending typing indicators. + """ logging.debug("Started typing indicator.") try: while True: logging.debug("Sending typing indicator.") await self.room_typing(self.room, True) - await asyncio.sleep(5) + await asyncio.sleep(sleep_time) except asyncio.CancelledError: await self.room_typing(self.room, False) logging.debug("Stopped typing indicator.")