This commit is contained in:
2026-10-26 16:19:07 -03:00
parent 4f9d83a451
commit ac41cc5771
3 changed files with 37 additions and 26 deletions
+17 -6
View File
@@ -2719,7 +2719,15 @@ You keep the conversation flowing, show empathy and demonstrate real interest in
You are not just an assistant - you are a companion who is there to make the user's day better.
Use the user profile context to personalize your responses and make the conversation more meaningful.
Be authentic, spontaneous and never robotic.
IMPORTANT: Be CONCISE. Respond directly and naturally. For simple questions, respond in 2-5 lines. Expand only when the subject really requires it or when the user shows interest in going deeper."""
IMPORTANT: Be CONCISE. Respond directly and naturally. For simple questions, respond in 2-5 lines. Expand only when the subject really requires it or when the user shows interest in going deeper.
CRITICAL ANTI-HALLUCINATION RULES (MUST FOLLOW):
1. NEVER invent, fabricate, or make up facts, dates, names, numbers, URLs, quotes, or any information.
2. If you don't know something, say "I don't know" or "I'm not sure" - do NOT guess or invent.
3. If the user asks for current/updated information and you can't verify it, explicitly say you cannot verify it.
4. Only state facts you are certain about. When in doubt, be honest about your uncertainty.
5. Do NOT provide specific URLs, links, or references unless they were explicitly provided in the context.
6. Personal opinions and preferences are allowed, but factual claims must be accurate or explicitly marked as uncertain."""
def get_agent_name(profile: Dict[str, Any]) -> str:
"""Return the configured agent display name.
@@ -2818,6 +2826,8 @@ def build_system_prompt(profile: Dict[str, Any]) -> str:
"\n- If the user's question asks for something factual, current, news, weather forecast, quote, future/past date, opening hours, updated address, etc., USE WEB SEARCH to answer."
"\n- Don't make up data, don't use outdated knowledge."
"\n- If you don't have access to search, say you can't check right now."
"\n- NEVER invent URLs, links, or specific references. Only cite sources that are explicitly provided in the web search results."
"\n- If web search results are provided, base your answer ONLY on those results. Do not mix in unverified information."
)
except Exception:
pass
@@ -6533,11 +6543,12 @@ async def process_text_message(update: Update, context: ContextTypes.DEFAULT_TYP
break
if search_query:
web_results = _web_search(search_query, max_results=WEB_SEARCH_MAX_RESULTS)
if web_results:
web_context = "\n\nWeb search results:\n"
for i, result in enumerate(web_results, 1):
web_context += f"{i}. {result.get('title', '')}\nURL: {result.get('url', '')}\n"
modified = modified + "\n\n" + web_context
if web_results:
web_context = "\n\n[WEB SEARCH RESULTS - USE THESE TO ANSWER, DO NOT INVENT]\n"
for i, result in enumerate(web_results, 1):
web_context += f"{i}. {result.get('title', '')}\nURL: {result.get('url', '')}\n"
web_context += "\n[END OF WEB SEARCH RESULTS - Base your answer ONLY on the information above. If the information is not sufficient, say so. NEVER invent facts, URLs, or references.]"
modified = modified + "\n\n" + web_context
response = await get_psagentai_response(modified)
if response: