human behavior: classifier gate, pacing, splitting, quiet hours, stable prompt prefix
This commit is contained in:
@@ -154,17 +154,25 @@ class AIResponder(AIResponderBase):
|
||||
self.memory_manager = MemoryManager(self.store, lambda: self.config, self.consolidate, self.channel)
|
||||
logging.info(f"memmory:\n{self.memory}")
|
||||
|
||||
# Dynamic values move to a context suffix so the persona prefix
|
||||
# stays byte-stable for the prompt cache (ENV-20)
|
||||
DYNAMIC_PLACEHOLDERS = ("{date}", "{time}", "{news}", "{memory}")
|
||||
|
||||
def message(self, message: AIMessage, limit: Optional[int] = None) -> List[Dict[str, Any]]:
|
||||
messages = []
|
||||
system = self.config.get(self.channel, self.config["system"])
|
||||
system = system.replace("{date}", time.strftime("%Y-%m-%d")).replace("{time}", time.strftime("%H:%M:%S"))
|
||||
persona = self.config.get(self.channel, self.config["system"])
|
||||
for placeholder in self.DYNAMIC_PLACEHOLDERS:
|
||||
persona = persona.replace(placeholder, "")
|
||||
context = [f"date: {time.strftime('%Y-%m-%d')} ({time.strftime('%A')})", f"time: {time.strftime('%H:%M:%S')}"]
|
||||
news_feed = self.config.get("news")
|
||||
if news_feed and os.path.exists(news_feed):
|
||||
with open(news_feed) as fd:
|
||||
news_feed = fd.read().strip()
|
||||
system = system.replace("{news}", sanitize_external_text(news_feed))
|
||||
context.append("news:\n" + sanitize_external_text(fd.read().strip()))
|
||||
participants = [message.user] + [entry_user for entry_user in self._history_users(20)]
|
||||
system = system.replace("{memory}", self.memory_manager.memory_block(participants, self.memory))
|
||||
memory_block = self.memory_manager.memory_block(participants, self.memory)
|
||||
if memory_block:
|
||||
context.append("memory:\n" + memory_block)
|
||||
system = persona.rstrip() + "\n\n## Context\n" + "\n".join(context)
|
||||
messages.append({"role": "system", "content": system})
|
||||
if limit is not None:
|
||||
while len(self.history) > limit:
|
||||
@@ -238,6 +246,10 @@ class AIResponder(AIResponderBase):
|
||||
async def consolidate(self, observations: List[Dict[str, Any]], known_facts: List[Dict[str, Any]]) -> Optional[Dict[str, Any]]:
|
||||
raise NotImplementedError()
|
||||
|
||||
async def classify(self, message: AIMessage, history_tail: List[Dict[str, Any]]) -> Optional[Dict[str, Any]]:
|
||||
"""Cheap reply/factual/emoji pre-pass (BEH-01); None = fail open."""
|
||||
raise NotImplementedError()
|
||||
|
||||
async def translate(self, text: str, language: str = "english") -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user