From 012d6e0eaf66d3a0ba5989c3615c65c519293771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Sat, 27 May 2023 16:09:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20ignore=20messages=20comming=20fr?= =?UTF-8?q?om=20threads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nio_llm/client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nio_llm/client.py b/nio_llm/client.py index ca5e72c..7ab4ce3 100644 --- a/nio_llm/client.py +++ b/nio_llm/client.py @@ -69,6 +69,14 @@ class LLMClient(AsyncClient): logger.debug("Ignoring edited message.") return + # ignore thread messages + if ( + "m.relates_to" in event.source["content"] + and event.source["content"]["m.relates_to"]["rel_type"] == "m.thread" + ): + logger.debug("Ignoring thread message.") + return + # update history self.history.append(event) @@ -95,6 +103,7 @@ class LLMClient(AsyncClient): logger.debug(f"Prompt:\n{prompt}") logger.debug(f"Tokens: {len(tokens)}") + # ignore prompts that are too long if len(tokens) > 512: logger.debug("Prompt too long, skipping.") await self.room_send(