Edenbaba commited on
Commit
9cd5f5b
·
verified ·
1 Parent(s): 9f13b72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -1
app.py CHANGED
@@ -34,6 +34,67 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  final_answer = FinalAnswerTool()
39
  web_search = DuckDuckGoSearchTool()
@@ -58,7 +119,8 @@ with open("prompts.yaml", 'r') as stream:
58
 
59
  agent = CodeAgent(
60
  model=model,
61
- tools=[final_answer, image_generation_tool, my_custom_tool, get_current_time_in_timezone, web_search, visit_webpage], ## add your tools here (don't remove final answer)
 
62
  max_steps=10,
63
  verbosity_level=1,
64
  grammar=None,
 
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
+ @tool
38
+ def suggest_menu(occasion: str) -> str:
39
+ """
40
+ Suggests a menu based on the occasion.
41
+ Args:
42
+ occasion: The type of occasion for the party.
43
+ """
44
+ if occasion == "casual":
45
+ return "Pizza, snacks, and drinks."
46
+ elif occasion == "formal":
47
+ return "3-course dinner with wine and dessert."
48
+ elif occasion == "superhero":
49
+ return "Buffet with high-energy and healthy food."
50
+ else:
51
+ return "Custom menu for the butler."
52
+
53
+ @tool
54
+ def catering_service_tool(query: str) -> str:
55
+ """
56
+ This tool returns the highest-rated catering service in Gotham City.
57
+
58
+ Args:
59
+ query: A search term for finding catering services.
60
+ """
61
+ # Example list of catering services and their ratings
62
+ services = {
63
+ "Gotham Catering Co.": 4.9,
64
+ "Wayne Manor Catering": 4.8,
65
+ "Gotham City Events": 4.7,
66
+ }
67
+
68
+ # Find the highest rated catering service (simulating search query filtering)
69
+ best_service = max(services, key=services.get)
70
+
71
+ return best_service
72
+
73
+ class SuperheroPartyThemeTool(Tool):
74
+ name = "superhero_party_theme_generator"
75
+ description = """
76
+ This tool suggests creative superhero-themed party ideas based on a category.
77
+ It returns a unique party theme idea."""
78
+
79
+ inputs = {
80
+ "category": {
81
+ "type": "string",
82
+ "description": "The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic Gotham').",
83
+ }
84
+ }
85
+
86
+ output_type = "string"
87
+
88
+ def forward(self, category: str):
89
+ themes = {
90
+ "classic heroes": "Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like 'The Kryptonite Punch'.",
91
+ "villain masquerade": "Gotham Rogues' Ball: A mysterious masquerade where guests dress as classic Batman villains.",
92
+ "futuristic Gotham": "Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets."
93
+ }
94
+
95
+ return themes.get(category.lower(), "Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic Gotham'.")
96
+
97
+
98
 
99
  final_answer = FinalAnswerTool()
100
  web_search = DuckDuckGoSearchTool()
 
119
 
120
  agent = CodeAgent(
121
  model=model,
122
+ tools=[final_answer, image_generation_tool, my_custom_tool, get_current_time_in_timezone, web_search, visit_webpage,
123
+ suggest_menu, catering_service_tool, SuperheroPartyThemeTool()], ## add your tools here (don't remove final answer)
124
  max_steps=10,
125
  verbosity_level=1,
126
  grammar=None,