fix: replace LLM guard with simple keyword blocklist
This commit is contained in:
@@ -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 = ""
|
||||
|
||||
Reference in New Issue
Block a user