mirror of
https://github.com/Laurent2916/nio-llm.git
synced 2024-11-09 23:12:05 +00:00
🎨 parametrize typing_loop with typing_loop
This commit is contained in:
parent
0f312a0a70
commit
5b5a18d73b
|
@ -74,14 +74,22 @@ class LLMClient(AsyncClient):
|
||||||
# add callbacks
|
# add callbacks
|
||||||
self.add_event_callback(self.message_callback, RoomMessageText) # type: ignore
|
self.add_event_callback(self.message_callback, RoomMessageText) # type: ignore
|
||||||
|
|
||||||
async def typing_loop(self) -> None:
|
async def typing_loop(
|
||||||
"""Send typing indicators every 5 seconds."""
|
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.")
|
logging.debug("Started typing indicator.")
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
logging.debug("Sending typing indicator.")
|
logging.debug("Sending typing indicator.")
|
||||||
await self.room_typing(self.room, True)
|
await self.room_typing(self.room, True)
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(sleep_time)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
await self.room_typing(self.room, False)
|
await self.room_typing(self.room, False)
|
||||||
logging.debug("Stopped typing indicator.")
|
logging.debug("Stopped typing indicator.")
|
||||||
|
|
Loading…
Reference in a new issue