fix: bypass academic guard for reminder-related questions
This commit is contained in:
@@ -14,6 +14,7 @@ from guard import is_academic_topic, REJECT_MESSAGE
|
||||
|
||||
_pending_confirmations: dict = {}
|
||||
REMINDER_KEYWORDS = ["ingatkan", "pengingat", "remind", "jadwalkan", "tolong ingat"]
|
||||
REMINDER_BYPASS_KEYWORDS = ["ingatkan", "pengingat", "remind", "diingatkan", "jadwalkan", "kapan diingat"]
|
||||
|
||||
_client = AsyncOpenAI(api_key=DEEPSEEK_API_KEY, base_url=DEEPSEEK_BASE_URL)
|
||||
|
||||
@@ -316,6 +317,8 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
|
||||
# Deteksi intent reminder dari plain text
|
||||
text_lower = text.lower()
|
||||
is_reminder_related = any(kw in text_lower for kw in REMINDER_BYPASS_KEYWORDS)
|
||||
|
||||
if any(kw in text_lower for kw in REMINDER_KEYWORDS):
|
||||
await update.message.chat.send_action("typing")
|
||||
parsed = await reminder_module.parse_reminder_intent(text, _client, DEEPSEEK_MODEL)
|
||||
@@ -327,6 +330,8 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
question = text
|
||||
await update.message.chat.send_action("typing")
|
||||
|
||||
# Skip guard untuk pertanyaan tentang fitur bot sendiri
|
||||
if not is_reminder_related:
|
||||
if not await is_academic_topic(question, _client, DEEPSEEK_MODEL):
|
||||
await update.message.reply_text(REJECT_MESSAGE)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user