tune xiaoniu low-frequency social interjections

This commit is contained in:
liuwei
2026-04-07 14:52:38 +08:00
parent 5a02121ace
commit 5ca9a8d1d9
3 changed files with 22 additions and 4 deletions

View File

@@ -10,6 +10,10 @@ QUESTION_PATTERNS = [
r"有人知道", r"谁知道", r"能不能", r"可以吗", r"报错", r"怎么解决",
]
SOCIAL_PATTERNS = [r"小牛", r"在吗", r"出来", r"帮忙看", r"看看"]
LIGHT_SOCIAL_PATTERNS = [
r"哈哈", r"笑死", r"绷不住", r"离谱", r"逆天", r"牛逼", r"卧槽", r"我去",
r"确实", r"也是", r"6$", r"可以啊", r"有点东西", r"抽象",
]
@dataclass
@@ -66,6 +70,12 @@ class TriggerRouter:
result.priority = max(result.priority, float(self.config.get("social_call", 0.65)))
result.is_social_call = True
result.reasons.append("social_call")
elif self._is_light_social_moment(content_lower):
if result.priority < float(self.config.get("light_social", 0.45)):
result.trigger_type = result.trigger_type if result.trigger_type != "none" else "light_social_trigger"
result.priority = max(result.priority, float(self.config.get("light_social", 0.45)))
result.is_social_call = True
result.reasons.append("light_social")
if memory_hints.get("returning_member_state") in {"returning_member", "long_absent_member"}:
result.is_returning_member = True
result.reasons.append(memory_hints.get("returning_member_state"))
@@ -80,6 +90,11 @@ class TriggerRouter:
def _is_social_call(self, content: str) -> bool:
return any(re.search(pattern, content, flags=re.IGNORECASE) for pattern in SOCIAL_PATTERNS)
def _is_light_social_moment(self, content: str) -> bool:
if len(content) > 24:
return False
return any(re.search(pattern, content, flags=re.IGNORECASE) for pattern in LIGHT_SOCIAL_PATTERNS)
def _detect_topic(self, content_lower: str) -> str:
for keyword in self.topic_keywords:
if keyword and keyword in content_lower: