Fix regex pattern for chat history detection

- Updated regex to match newline characters
- Added re.MULTILINE flag for multiline matching
- Improved logging for regex match results
- Enhanced query content cleaning process
- Ensured consistent chat history detection
This commit is contained in:
yangdx
2025-01-24 23:39:33 +08:00
parent 930b6cf006
commit 11873625a3

View File

@@ -1540,7 +1540,7 @@ def create_app(args):
# 判断是否包含特定字符串,使用正则表达式进行匹配 # 判断是否包含特定字符串,使用正则表达式进行匹配
logging.info(f"Cleaned query content: {cleaned_query}") logging.info(f"Cleaned query content: {cleaned_query}")
match_result = re.search(r'\\n<chat_history>\\nUSER:', cleaned_query) match_result = re.search(r'\n<chat_history>\nUSER:', cleaned_query, re.MULTILINE)
logging.info(f"Regex match result: {bool(match_result)}") logging.info(f"Regex match result: {bool(match_result)}")
if match_result: if match_result: