Download harness/tool_base.py from ASown/agent-iot: direct link, hf CLI and curl.
- Browser
- Download file 740 Bytes
-
https://huggingface.co/spaces/ASown/agent-iot/resolve/main/harness/tool_base.py
- Command line
-
hf download hf://spaces/ASown/agent-iot/harness/tool_base.py
-
curl -L -o tool_base.py https://huggingface.co/spaces/ASown/agent-iot/resolve/main/harness/tool_base.py
740 Bytes
| """Contract every tool implements so the harness/agent can use it uniformly.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| class ToolResult: | |
| ok: bool | |
| summary: str # short human-readable line for the chat UI | |
| data: dict = field(default_factory=dict) | |
| class Tool: | |
| """A capability/machine plugged into the system. | |
| Subclasses set `name`, `description` (what it does + WHEN to use it — the | |
| router reads this), and implement `run(task)`. | |
| """ | |
| name: str = "tool" | |
| description: str = "" | |
| def run(self, task: str, **ctx) -> ToolResult: | |
| raise NotImplementedError | |
| def __repr__(self) -> str: | |
| return f"<Tool {self.name}>" | |