From 4fe4becdd5a42e8e4661cc30c6e5a74f3b90614f Mon Sep 17 00:00:00 2001 From: ydy0615 Date: Thu, 19 Feb 2026 11:14:43 +0800 Subject: [PATCH] fix(backend): filter out
tags from prompt context Filter out potential web-scraping or legacy artifacts like
,
, from prefix/suffix before using in model completion context --- backend/prompt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/prompt.py b/backend/prompt.py index 6c35132..10ed6db 100644 --- a/backend/prompt.py +++ b/backend/prompt.py @@ -37,8 +37,13 @@ def _sanitize_language_id(language_id: str) -> str: def _prepare_context(prefix: str, suffix: str) -> Tuple[str, str]: """ Prepare prefix/suffix for model completion context. + Filter out potential web-scraping or legacy artifacts like
,
, . """ - return prefix, suffix + import re + br_pattern = re.compile(r'', re.IGNORECASE) + clean_prefix = br_pattern.sub('', prefix or "") + clean_suffix = br_pattern.sub('', suffix or "") + return clean_prefix, clean_suffix def prepare_prompt_context(prefix: str, suffix: str) -> Tuple[str, str]: