24 lines
912 B
Python
24 lines
912 B
Python
from __future__ import annotations
|
|
|
|
from typing import Dict
|
|
|
|
|
|
class ResponsePlanner:
|
|
def choose_reply_mode(self, trigger: Dict, flow_state: str) -> str:
|
|
if trigger.get("is_question"):
|
|
return "qa_with_context" if flow_state in {"engaged", "deep_engaged"} else "qa_fast"
|
|
if trigger.get("is_followup"):
|
|
return "qa_with_context"
|
|
if trigger.get("is_social_call"):
|
|
return "social_short"
|
|
if trigger.get("is_returning_member"):
|
|
return "social_short"
|
|
return "social_short" if flow_state in {"deep_engaged"} else "refuse_or_skip"
|
|
|
|
def should_reply(self, trigger: Dict, flow_state: str, allow_proactive: bool) -> bool:
|
|
if trigger.get("should_respond"):
|
|
return True
|
|
if not allow_proactive:
|
|
return False
|
|
return flow_state in {"deep_engaged"} and trigger.get("priority", 0) >= 0.65
|