From 8aa2a44da705902b027e3af97813e36c2abc4bf3 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Mon, 22 Jul 2024 19:32:15 +0200 Subject: [PATCH] handle some errors in output sanitizing filter --- output_sanitizing_filter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/output_sanitizing_filter.py b/output_sanitizing_filter.py index 2697990..f877e3f 100644 --- a/output_sanitizing_filter.py +++ b/output_sanitizing_filter.py @@ -2,7 +2,7 @@ title: Output Sanitization Filter author: projectmoon author_url: https://git.agnos.is/projectmoon/open-webui-filters -version: 0.1.0 +version: 0.1.2 required_open_webui_version: 0.3.9 """ @@ -55,4 +55,9 @@ class Filter: last_reply: dict = body["messages"][-1] last_reply = last_reply["content"].strip() replaced_message = strip_prefixes(last_reply, self.valves.start_removals) - await self.replace_message(replaced_message) + + if replaced_message != last_reply: + body["messages"][-1]["content"] = replaced_message + await self.replace_message(replaced_message) + + return body