deveshka commited on
Commit
3fffc75
·
verified ·
1 Parent(s): 19dfed1

added custom tool for party planner

Browse files
Files changed (1) hide show
  1. app.py +67 -2
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import os
@@ -8,6 +8,67 @@ from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  final_answer = FinalAnswerTool()
13
 
@@ -30,7 +91,11 @@ with open("prompts.yaml", 'r') as stream:
30
 
31
  agent = CodeAgent(
32
  model=model,
33
- tools=[final_answer, DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
 
 
 
 
34
  max_steps=6,
35
  verbosity_level=1,
36
  grammar=None,
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool,Tool,VisitWebpageTool
2
  import datetime
3
  import requests
4
  import os
 
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+ @tool
12
+ def suggest_menu(occasion: str) -> str:
13
+ """
14
+ Suggests a menu based on the occasion.
15
+ Args:
16
+ occasion: The type of occasion for the party.
17
+ """
18
+ if occasion == "casual":
19
+ return "Pizza, snacks, and drinks."
20
+ elif occasion == "formal":
21
+ return "3-course dinner with wine and dessert."
22
+ elif occasion == "superhero":
23
+ return "Buffet with high-energy and healthy food."
24
+ else:
25
+ return "Custom menu for the butler."
26
+
27
+ @tool
28
+ def catering_service_tool(query: str) -> str:
29
+ """
30
+ This tool returns the highest-rated catering service in Gotham City.
31
+
32
+ Args:
33
+ query: A search term for finding catering services.
34
+ """
35
+ # Example list of catering services and their ratings
36
+ services = {
37
+ "Gotham Catering Co.": 4.9,
38
+ "Wayne Manor Catering": 4.8,
39
+ "Gotham City Events": 4.7,
40
+ }
41
+
42
+ # Find the highest rated catering service (simulating search query filtering)
43
+ best_service = max(services, key=services.get)
44
+
45
+ return best_service
46
+
47
+ class SuperheroPartyThemeTool(Tool):
48
+ name = "superhero_party_theme_generator"
49
+ description = """
50
+ This tool suggests creative superhero-themed party ideas based on a category.
51
+ It returns a unique party theme idea."""
52
+
53
+ inputs = {
54
+ "category": {
55
+ "type": "string",
56
+ "description": "The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic Gotham').",
57
+ }
58
+ }
59
+
60
+ output_type = "string"
61
+
62
+ def forward(self, category: str):
63
+ themes = {
64
+ "classic heroes": "Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like 'The Kryptonite Punch'.",
65
+ "villain masquerade": "Gotham Rogues' Ball: A mysterious masquerade where guests dress as classic Batman villains.",
66
+ "futuristic Gotham": "Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets."
67
+ }
68
+
69
+ return themes.get(category.lower(), "Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic Gotham'.")
70
+
71
+
72
 
73
  final_answer = FinalAnswerTool()
74
 
 
91
 
92
  agent = CodeAgent(
93
  model=model,
94
+ tools=[final_answer, DuckDuckGoSearchTool(),VisitWebpageTool(),
95
+ suggest_menu,
96
+ catering_service_tool,
97
+ SuperheroPartyThemeTool()
98
+ ], ## add your tools here (don't remove final answer)
99
  max_steps=6,
100
  verbosity_level=1,
101
  grammar=None,