AI Update: بله

This commit is contained in:
Antigravity Bot
2026-08-30 16:50:56 +03:30
parent 1d0c2e25d8
commit 3786bd766a
2 changed files with 22 additions and 15 deletions
+13 -6
View File
@@ -1210,17 +1210,17 @@ def clean_user_prompt(raw_text: Optional[str]) -> str:
if req_match:
text = req_match.group(1)
# 2. Remove standard outer XML/HTML metadata tags
# 2. Remove delimited system instruction blocks FIRST (before any HTML/XML tag stripping)
text = re.sub(r"<!--\s*SYSTEM_INSTRUCTIONS_START\s*-->.*?<!--\s*SYSTEM_INSTRUCTIONS_END\s*-->", "", text, flags=re.DOTALL)
text = re.sub(r"\[SYSTEM_INSTRUCTIONS_BLOCK\].*?\[/SYSTEM_INSTRUCTIONS_BLOCK\]", "", text, flags=re.DOTALL)
# 3. Remove standard outer XML/HTML metadata tags and sections
text = re.sub(r"<ADDITIONAL_METADATA>.*?</ADDITIONAL_METADATA>", "", text, flags=re.DOTALL)
text = re.sub(r"<USER_SETTINGS_CHANGE>.*?</USER_SETTINGS_CHANGE>", "", text, flags=re.DOTALL)
text = re.sub(r"<SYSTEM_MESSAGE>.*?</SYSTEM_MESSAGE>", "", text, flags=re.DOTALL)
text = re.sub(r"<[^>]+>", "", text)
# 3. Remove delimited system instruction blocks
text = re.sub(r"<!--\s*SYSTEM_INSTRUCTIONS_START\s*-->.*?<!--\s*SYSTEM_INSTRUCTIONS_END\s*-->", "", text, flags=re.DOTALL)
text = re.sub(r"\[SYSTEM_INSTRUCTIONS_BLOCK\].*?\[/SYSTEM_INSTRUCTIONS_BLOCK\]", "", text, flags=re.DOTALL)
# 4. Remove known structured system instructions (backward compatibility)
# 4. Remove known structured system instructions (backward compatibility & fallbacks)
# Language instruction
text = re.sub(r"\[SYSTEM INSTRUCTION:\s*You MUST respond and communicate in [^\]]+\]", "", text, flags=re.DOTALL)
@@ -1229,6 +1229,9 @@ def clean_user_prompt(raw_text: Optional[str]) -> str:
# Bot actions block
text = re.sub(r"\[SYSTEM INSTRUCTION:\s*TELEGRAM BOT ACTIONS & FUNCTION CALLING\].*?(?:Always explain to the user in a friendly and professional tone what actions have been performed\.?|\Z)", "", text, flags=re.DOTALL)
# Active project context block
text = re.sub(r"\[SYSTEM INSTRUCTION:\s*ACTIVE PROJECT CONTEXT\].*?(?:You are operating directly within[^\n]*|\Z)", "", text, flags=re.DOTALL)
# Memory instructions block
text = re.sub(r"\[SYSTEM INSTRUCTION:\s*AI PERSISTENT HIERARCHICAL MEMORY & CONTINUOUS LEARNING\].*?(?:5\. Do NOT store temporary or trivial small-talk\. Only store enduring and valuable knowledge\.?|\Z)", "", text, flags=re.DOTALL)
@@ -1236,6 +1239,10 @@ def clean_user_prompt(raw_text: Optional[str]) -> str:
# General fallback for any remaining [SYSTEM INSTRUCTION: ...]
text = re.sub(r"\[SYSTEM INSTRUCTION:[^\]]+\]", "", text)
text = re.sub(r"(?:^|\n)System Instruction:\s*", "", text)
text = re.sub(r"• Active Project Name:.*?(?:\n|\Z)", "", text)
text = re.sub(r"• Active Workspace Path:.*?(?:\n|\Z)", "", text)
text = re.sub(r"• Active Conversation ID:.*?(?:\n|\Z)", "", text)
text = re.sub(r"• AI Model:.*?(?:\n|\Z)", "", text)
# Clean uploaded file notifications
caption_m = re.search(r"\[User uploaded [^\]]+\]\s*(?:Caption:\s*(.*))?", text, re.DOTALL)
File diff suppressed because one or more lines are too long