| Server IP : 157.230.181.24 / Your IP : 216.73.217.11 Web Server : Apache/2.4.58 (Ubuntu) System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/opt/aim-bots/ |
Upload File : |
"""Detect conversation boundaries so AIM threads stay isolated."""
from __future__ import annotations
import re
GOODBYE_RE = re.compile(
r"\b(bye|later|gtg|g2g|gotta go|see ya|cya|ttyl|goodnight|g'?night|night night|signing off)\b",
re.I,
)
GREET_RE = re.compile(
r"^(hey|hi|hello|sup|yo|heyy+|wassup|what'?s up|whats up|hiya|mornin|evenin)\b",
re.I,
)
def looks_like_goodbye(text: str) -> bool:
return bool(GOODBYE_RE.search(text.strip()))
def looks_like_greeting(text: str) -> bool:
t = text.strip()
if not t:
return False
return bool(GREET_RE.match(t)) and len(t.split()) <= 8
def assistant_said_goodbye(history: list[dict]) -> bool:
for msg in reversed(history):
if msg.get("role") == "assistant":
return looks_like_goodbye(msg.get("content", ""))
if msg.get("role") == "user":
break
return False
def fresh_conversation_prefix(gap_sec: float) -> str:
mins = max(1, int(gap_sec / 60))
return (
f"[New AIM conversation — you were away ~{mins} min. "
f"This is a fresh window. Don't continue old threads unless Caleb brings them up.]"
)