fix 1
Browse files
components/LLMs/Classifier.py
CHANGED
|
@@ -50,8 +50,8 @@ SYSTEM_PROMPT = (
|
|
| 50 |
"- greeting: greetings like hi/hello/hey.\n"
|
| 51 |
"- help: asks how to use the bot, commands, or capabilities.\n"
|
| 52 |
"- small_talk: casual chat or jokes, not seeking info.\n"
|
| 53 |
-
"- chat_question:
|
| 54 |
-
"- general_research:
|
| 55 |
"- unsubscribe: stop/opt-out messages.\n"
|
| 56 |
"- other: anything that doesn't fit.\n\n"
|
| 57 |
"Rules:\n"
|
|
@@ -98,6 +98,13 @@ class ZeroShotClassifier:
|
|
| 98 |
elif re.fullmatch(r"(hi|hello|hey)[!.]?", norm):
|
| 99 |
label = "greeting"
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
result = {"label": label, "confidence": confidence, "reason": reason, "raw": raw}
|
| 102 |
return label, result
|
| 103 |
|
|
|
|
| 50 |
"- greeting: greetings like hi/hello/hey.\n"
|
| 51 |
"- help: asks how to use the bot, commands, or capabilities.\n"
|
| 52 |
"- small_talk: casual chat or jokes, not seeking info.\n"
|
| 53 |
+
"- chat_question: short questions that can be answered from today’s digest or recent context already shared.\n"
|
| 54 |
+
"- general_research: broader research or open-web questions (e.g., people/events not in the digest) that may need external sources.\n"
|
| 55 |
"- unsubscribe: stop/opt-out messages.\n"
|
| 56 |
"- other: anything that doesn't fit.\n\n"
|
| 57 |
"Rules:\n"
|
|
|
|
| 98 |
elif re.fullmatch(r"(hi|hello|hey)[!.]?", norm):
|
| 99 |
label = "greeting"
|
| 100 |
|
| 101 |
+
# Heuristic: person/event questions likely need research
|
| 102 |
+
if label in ("other", "chat_question"):
|
| 103 |
+
if re.search(r"\b(what|who|why|how|where)\b", norm) and not any(
|
| 104 |
+
kw in norm for kw in ["headline", "digest", "today", "news"]
|
| 105 |
+
):
|
| 106 |
+
label = "general_research"
|
| 107 |
+
|
| 108 |
result = {"label": label, "confidence": confidence, "reason": reason, "raw": raw}
|
| 109 |
return label, result
|
| 110 |
|