fix: replace LLM guard with simple keyword blocklist

This commit is contained in:
Power BI Dev
2026-06-04 13:11:16 +07:00
parent d0d3d1a95b
commit 91b7a2eeaf
2 changed files with 26 additions and 56 deletions
+5 -7
View File
@@ -10,7 +10,7 @@ import database as db
import rag
import reminder as reminder_module
import document as doc_processor
from guard import is_academic_topic, REJECT_MESSAGE
from guard import is_blocked, REJECT_MESSAGE
_pending_confirmations: dict = {}
REMINDER_KEYWORDS = ["ingatkan", "pengingat", "remind", "jadwalkan", "tolong ingat"]
@@ -140,7 +140,7 @@ async def ask(update: Update, context: ContextTypes.DEFAULT_TYPE):
question = " ".join(context.args)
await update.message.chat.send_action("typing")
if not await is_academic_topic(question, _client, DEEPSEEK_MODEL):
if is_blocked(question):
await update.message.reply_text(REJECT_MESSAGE)
return
@@ -330,11 +330,9 @@ 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
if is_blocked(question):
await update.message.reply_text(REJECT_MESSAGE)
return
relevant = await rag.search(user_data["id"], question, n_results=5)
context_text = ""