Alfred_RAG / tools.py
nickyJames's picture
Create tools.py
cafa688 verified
# tools.py
# Additional tools for Alfred the Gala Agent
from smolagents import tool
import datetime
@tool
def get_current_time() -> str:
"""
Gets the current date and time.
Use this when you need to know what time it is for scheduling or time-related questions.
Returns:
The current date and time as a formatted string
"""
now = datetime.datetime.now()
return f"Current date and time: {now.strftime('%A, %B %d, %Y at %I:%M %p')}"
@tool
def calculate_party_budget(
num_guests: int,
cost_per_guest: float,
venue_cost: float,
entertainment_cost: float
) -> str:
"""
Calculate the total budget needed for the gala party.
Args:
num_guests: Number of guests attending
cost_per_guest: Cost per guest (food, drinks, favors)
venue_cost: Cost of the venue rental
entertainment_cost: Cost of entertainment (DJ, dancers, etc.)
Returns:
A breakdown of the party budget
"""
guest_total = num_guests * cost_per_guest
total = guest_total + venue_cost + entertainment_cost
return f"""
πŸŽ‰ GALA BUDGET BREAKDOWN πŸŽ‰
━━━━━━━━━━━━━━━━━━━━━━━━━
Guests: {num_guests} Γ— ${cost_per_guest:.2f} = ${guest_total:.2f}
Venue: ${venue_cost:.2f}
Entertainment: ${entertainment_cost:.2f}
━━━━━━━━━━━━━━━━━━━━━━━━━
TOTAL: ${total:.2f}
"""
@tool
def suggest_seating_arrangement(guest_names: str, table_size: int) -> str:
"""
Suggest a seating arrangement for guests.
Args:
guest_names: Comma-separated list of guest names
table_size: Number of seats per table
Returns:
A suggested seating arrangement
"""
guests = [name.strip() for name in guest_names.split(",")]
num_guests = len(guests)
num_tables = (num_guests + table_size - 1) // table_size
arrangement = "πŸͺ‘ SEATING ARRANGEMENT πŸͺ‘\n"
arrangement += "━" * 30 + "\n"
for table_num in range(num_tables):
start_idx = table_num * table_size
end_idx = min(start_idx + table_size, num_guests)
table_guests = guests[start_idx:end_idx]
arrangement += f"\nπŸ“ Table {table_num + 1}:\n"
for guest in table_guests:
arrangement += f" β€’ {guest}\n"
return arrangement
@tool
def dietary_check(dietary_requirement: str) -> str:
"""
Check common dietary requirements and suggest menu options.
Args:
dietary_requirement: The dietary requirement to check (e.g., vegetarian, vegan, gluten-free, halal, kosher)
Returns:
Menu suggestions for the dietary requirement
"""
menus = {
"vegetarian": """
πŸ₯— VEGETARIAN MENU OPTIONS:
β€’ Stuffed bell peppers with quinoa
β€’ Mushroom risotto
β€’ Caprese salad with fresh mozzarella
β€’ Vegetable lasagna
β€’ Spinach and ricotta ravioli
""",
"vegan": """
🌱 VEGAN MENU OPTIONS:
β€’ Grilled vegetable platter
β€’ Coconut curry with tofu
β€’ Mediterranean mezze board
β€’ Mushroom and walnut "meatballs"
β€’ Fresh fruit tart with coconut cream
""",
"gluten-free": """
🌾 GLUTEN-FREE MENU OPTIONS:
β€’ Grilled salmon with herb butter
β€’ Rice paper spring rolls
β€’ Quinoa stuffed tomatoes
β€’ Flourless chocolate cake
β€’ Fresh fruit platter
""",
"halal": """
πŸ– HALAL MENU OPTIONS:
β€’ Lamb kofta with yogurt sauce
β€’ Chicken shawarma
β€’ Beef kebabs with rice pilaf
β€’ Baklava dessert
β€’ Fresh salads
""",
"kosher": """
✑️ KOSHER MENU OPTIONS:
β€’ Roasted chicken with vegetables
β€’ Gefilte fish appetizer
β€’ Matzo ball soup
β€’ Brisket with roasted potatoes
β€’ Honey cake dessert
"""
}
requirement_lower = dietary_requirement.lower()
if requirement_lower in menus:
return menus[requirement_lower]
else:
return f"I don't have specific menu suggestions for '{dietary_requirement}'. Please consult with the catering team for custom options."