zasharepw77 commited on
Commit
0256c0c
·
1 Parent(s): 9410d0a

Add application file 3

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