diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index d8ed066c96..164ec4d3a1 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -3865,7 +3865,7 @@ async def background_tasks_handler(ctx): if isinstance(content, str): content = re.sub( - r']*>.*?<\/details>|!\[.*?\]\(.*?\)', + r']*>(?:(?!|!\[[^\[\]]*\]\([^()]*\)', '', content, flags=re.S | re.I,