Create Relay Bot MVP
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
from dataclasses import dataclass
|
||||
from hashlib import sha256
|
||||
|
||||
from app.llm.schemas import Classification
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ProactiveDecision:
|
||||
respond: bool
|
||||
reason: str
|
||||
fingerprint: str
|
||||
|
||||
|
||||
def decide(
|
||||
mode: str,
|
||||
classification: Classification,
|
||||
*,
|
||||
is_mention: bool,
|
||||
duplicate: bool,
|
||||
cooldown: bool,
|
||||
threshold: float,
|
||||
) -> ProactiveDecision:
|
||||
fingerprint = sha256(repr(classification).encode()).hexdigest()
|
||||
if mode == "off":
|
||||
return ProactiveDecision(False, "mode_off", fingerprint)
|
||||
if mode == "mentions" and not is_mention:
|
||||
return ProactiveDecision(False, "not_mentioned", fingerprint)
|
||||
if duplicate or cooldown:
|
||||
return ProactiveDecision(False, "anti_spam", fingerprint)
|
||||
if not classification.is_question or classification.rhetorical:
|
||||
return ProactiveDecision(False, "not_actionable_question", fingerprint)
|
||||
if not classification.project_related:
|
||||
return ProactiveDecision(False, "not_project_related", fingerprint)
|
||||
if classification.asks_new_decision:
|
||||
return ProactiveDecision(False, "requires_human_decision", fingerprint)
|
||||
if classification.confidence < threshold:
|
||||
return ProactiveDecision(False, "low_confidence", fingerprint)
|
||||
return ProactiveDecision(True, "confirmed_fact_candidate", fingerprint)
|
||||
Reference in New Issue
Block a user