File size: 606 Bytes
26078c9
 
767deae
26078c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
Input guard — lightweight pre-check before LLM call.
No explicit word lists. Abuse handling is delegated to the system prompt.
"""


def check_input(message: str) -> tuple[bool, str | None]:
    """
    Basic pre-checks that don't need an LLM call.
    Returns (True, None) if OK, or (False, rejection_message) if blocked.
    Abuse/profanity is handled by the system prompt, not here.
    """
    text = message.strip()

    if not text:
        return False, "Empty message."

    if len(text) > 5000:
        return False, "Message too long. Keep it under 5000 characters."

    return True, None