summaryrefslogtreecommitdiff
path: root/personal_agent/tools/hello.py
diff options
context:
space:
mode:
Diffstat (limited to 'personal_agent/tools/hello.py')
-rw-r--r--personal_agent/tools/hello.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/personal_agent/tools/hello.py b/personal_agent/tools/hello.py
new file mode 100644
index 0000000..8f1ce1f
--- /dev/null
+++ b/personal_agent/tools/hello.py
@@ -0,0 +1,40 @@
+from personal_agent.tools.base import Tool, ToolRegistry, ToolResult
+
+
+class HelloTool(Tool):
+ @property
+ def name(self) -> str:
+ return "hello"
+
+ @property
+ def description(self) -> str:
+ return "Say hello to someone."
+
+ @property
+ def schema(self) -> dict[str, object]:
+ return {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The person to greet.",
+ },
+ },
+ "required": ["name"],
+ }
+
+ def execute(self, arguments: dict[str, object]) -> ToolResult:
+ name = arguments.get("name", "stranger")
+ return ToolResult(content=f"Hello, {name}!")
+
+
+if __name__ == "__main__":
+ registry = ToolRegistry()
+
+ registry.register(HelloTool())
+ print(registry.schemas())
+ tool = registry.get("hello")
+
+ if tool is not None:
+ result = tool.execute({"name": "Joseph"})
+ print(result.content)