SecurityAgent / tools /guest_list_management.py
ahghorbe97's picture
Upload agent
60e03c1 verified
from typing import Any, Optional
from smolagents.tools import Tool
class GuestListManagementTool(Tool):
name = "guest_list_management"
description = """
This tool helps manage guest list for my event.
It provides functionalities to add, remove, and list guests."""
inputs = {'action': {'type': 'string', 'description': "The action to perform on the guest list (e.g., 'add', 'remove', 'list')."}, 'name': {'type': 'string', 'description': "The name of the guest to add or remove, required for 'add' and 'remove' actions.", 'nullable': True}}
output_type = "string"
def __init__(self):
self.guest_list = []
def forward(self, action: str, name: str = None):
if action == "add" and name:
if name not in self.guest_list:
self.guest_list.append(name)
return f"{name} has been added to the guest list."
else:
return f"{name} is already on the guest list."
elif action == "remove" and name:
if name in self.guest_list:
self.guest_list.remove(name)
return f"{name} has been removed from the guest list."
else:
return f"{name} is not on the guest list."
elif action == "list":
if self.guest_list:
return "Guest List: " + ", ".join(self.guest_list)
else:
return "The guest list is empty."
else:
return "Invalid action. Use 'add', 'remove', or 'list'."