Download src/agent_app/agent.py from ganeshkota/agent-app: direct link, hf CLI and curl.
- Browser
- Download file 739 Bytes
-
https://huggingface.co/ganeshkota/agent-app/resolve/main/src/agent_app/agent.py
- Command line
-
hf download hf://ganeshkota/agent-app/src/agent_app/agent.py
-
curl -L -o agent.py https://huggingface.co/ganeshkota/agent-app/resolve/main/src/agent_app/agent.py
739 Bytes
| from dataclasses import dataclass | |
| from typing import List | |
| 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) | |