MVP: rule-based cognition stub
Browse files- freestream/agent.py +40 -0
freestream/agent.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Cognition layer stub for the MVP slice.
|
| 2 |
+
|
| 3 |
+
The real participant is the agent driving MCP (freestream/mcp_server.py).
|
| 4 |
+
This rule-based responder stands in for it during the latency harness so
|
| 5 |
+
the pipeline can be measured end-to-end without a live agent. It is
|
| 6 |
+
deterministic on purpose: the win-condition question must produce a known
|
| 7 |
+
answer.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class RuleAgent:
|
| 14 |
+
def __init__(self, bot_name: str = "FREESTREAM"):
|
| 15 |
+
self.bot_name = bot_name
|
| 16 |
+
|
| 17 |
+
def reply(self, question: str) -> str:
|
| 18 |
+
q = question.lower()
|
| 19 |
+
if not q:
|
| 20 |
+
return "I didn't catch that. Could you repeat it?"
|
| 21 |
+
if "name" in q:
|
| 22 |
+
return (f"I'm {self.bot_name}, a local AI assistant running entirely on this "
|
| 23 |
+
f"machine. I can join meetings, listen, and answer questions.")
|
| 24 |
+
if "hello" in q or "hi" in q:
|
| 25 |
+
return f"Hello! I'm {self.bot_name}. What would you like to know?"
|
| 26 |
+
if "what can you do" in q or "can you do" in q:
|
| 27 |
+
return ("I join calls as an avatar, listen with local speech recognition, "
|
| 28 |
+
"and speak with an on-device voice. Nothing leaves this machine.")
|
| 29 |
+
return (f"You asked: {question.strip()[:120]}. That's beyond my current "
|
| 30 |
+
f"rule-based stub, but the pipeline works end to end.")
|
| 31 |
+
|
| 32 |
+
def first_utterance(self) -> str:
|
| 33 |
+
"""CONSENT.md #2: spoken self-identification in the first utterance."""
|
| 34 |
+
return (f"Hi everyone — I'm {self.bot_name}, an AI assistant. "
|
| 35 |
+
f"Just so you know, I'm fully automated.")
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def load_agent(system_prompt: str | None = None, bot_name: str = "FREESTREAM"):
|
| 39 |
+
"""Post-MVP: an MCP-backed agent. MVP: the deterministic rule stub."""
|
| 40 |
+
return RuleAgent(bot_name=bot_name)
|