File size: 739 Bytes
2d1010b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from dataclasses import dataclass
from typing import List
@dataclass
class AgentResponse:
text: str
history: List[str]
class SimpleAgent:
def __init__(self, name: str = "StarterAgent") -> None:
self.name = name
self._history: List[str] = []
def respond(self, message: str) -> AgentResponse:
cleaned = message.strip()
if not cleaned:
reply = "How can I help?"
else:
reply = f"{self.name} received: {cleaned}"
self._history.append(f"user: {cleaned}")
self._history.append(f"{self.name}: {reply}")
return AgentResponse(text=reply, history=list(self._history))
def history(self) -> List[str]:
return list(self._history)
|