syum-af commited on
Commit
cf8bc9c
·
1 Parent(s): 25c502e
Files changed (6) hide show
  1. .gitignore +12 -0
  2. .python-version +1 -0
  3. app.py +77 -5
  4. pyproject.toml +13 -0
  5. requirements.txt +246 -0
  6. uv.lock +0 -0
.gitignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ .env
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11
app.py CHANGED
@@ -1,7 +1,79 @@
1
- import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, InferenceClientModel, 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
+ FinalAnswerTool()
73
+ ],
74
+ model=InferenceClientModel(),
75
+ max_steps=10,
76
+ verbosity_level=2
77
+ )
78
+
79
+ agent.run("Give me the best playlist for a party at the Wayne's mansion. The party idea is a 'villain masquerade' theme")
pyproject.toml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "alfredagent"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "duckduckgo-search>=8.0.3",
9
+ "gradio>=5.33.1",
10
+ "litellm>=1.72.4",
11
+ "python-dotenv>=1.1.0",
12
+ "smolagents>=1.18.0",
13
+ ]
requirements.txt ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile pyproject.toml -o requirements.txt
3
+ aiofiles==24.1.0
4
+ # via gradio
5
+ aiohappyeyeballs==2.6.1
6
+ # via aiohttp
7
+ aiohttp==3.12.12
8
+ # via litellm
9
+ aiosignal==1.3.2
10
+ # via aiohttp
11
+ annotated-types==0.7.0
12
+ # via pydantic
13
+ anyio==4.9.0
14
+ # via
15
+ # gradio
16
+ # httpx
17
+ # openai
18
+ # starlette
19
+ attrs==25.3.0
20
+ # via
21
+ # aiohttp
22
+ # jsonschema
23
+ # referencing
24
+ certifi==2025.4.26
25
+ # via
26
+ # httpcore
27
+ # httpx
28
+ # requests
29
+ charset-normalizer==3.4.2
30
+ # via requests
31
+ click==8.2.1
32
+ # via
33
+ # duckduckgo-search
34
+ # litellm
35
+ # typer
36
+ # uvicorn
37
+ distro==1.9.0
38
+ # via openai
39
+ duckduckgo-search==8.0.3
40
+ # via alfredagent (pyproject.toml)
41
+ fastapi==0.115.12
42
+ # via gradio
43
+ ffmpy==0.6.0
44
+ # via gradio
45
+ filelock==3.18.0
46
+ # via huggingface-hub
47
+ frozenlist==1.7.0
48
+ # via
49
+ # aiohttp
50
+ # aiosignal
51
+ fsspec==2025.5.1
52
+ # via
53
+ # gradio-client
54
+ # huggingface-hub
55
+ gradio==5.33.1
56
+ # via alfredagent (pyproject.toml)
57
+ gradio-client==1.10.3
58
+ # via gradio
59
+ groovy==0.1.2
60
+ # via gradio
61
+ h11==0.16.0
62
+ # via
63
+ # httpcore
64
+ # uvicorn
65
+ hf-xet==1.1.3
66
+ # via huggingface-hub
67
+ httpcore==1.0.9
68
+ # via httpx
69
+ httpx==0.28.1
70
+ # via
71
+ # gradio
72
+ # gradio-client
73
+ # litellm
74
+ # openai
75
+ # safehttpx
76
+ huggingface-hub==0.32.6
77
+ # via
78
+ # gradio
79
+ # gradio-client
80
+ # smolagents
81
+ # tokenizers
82
+ idna==3.10
83
+ # via
84
+ # anyio
85
+ # httpx
86
+ # requests
87
+ # yarl
88
+ importlib-metadata==8.7.0
89
+ # via litellm
90
+ jinja2==3.1.6
91
+ # via
92
+ # gradio
93
+ # litellm
94
+ # smolagents
95
+ jiter==0.10.0
96
+ # via openai
97
+ jsonschema==4.24.0
98
+ # via litellm
99
+ jsonschema-specifications==2025.4.1
100
+ # via jsonschema
101
+ litellm==1.72.4
102
+ # via alfredagent (pyproject.toml)
103
+ lxml==5.4.0
104
+ # via duckduckgo-search
105
+ markdown-it-py==3.0.0
106
+ # via rich
107
+ markupsafe==3.0.2
108
+ # via
109
+ # gradio
110
+ # jinja2
111
+ mdurl==0.1.2
112
+ # via markdown-it-py
113
+ multidict==6.4.4
114
+ # via
115
+ # aiohttp
116
+ # yarl
117
+ numpy==2.3.0
118
+ # via
119
+ # gradio
120
+ # pandas
121
+ openai==1.86.0
122
+ # via litellm
123
+ orjson==3.10.18
124
+ # via gradio
125
+ packaging==25.0
126
+ # via
127
+ # gradio
128
+ # gradio-client
129
+ # huggingface-hub
130
+ pandas==2.3.0
131
+ # via gradio
132
+ pillow==11.2.1
133
+ # via
134
+ # gradio
135
+ # smolagents
136
+ primp==0.15.0
137
+ # via duckduckgo-search
138
+ propcache==0.3.2
139
+ # via
140
+ # aiohttp
141
+ # yarl
142
+ pydantic==2.11.5
143
+ # via
144
+ # fastapi
145
+ # gradio
146
+ # litellm
147
+ # openai
148
+ pydantic-core==2.33.2
149
+ # via pydantic
150
+ pydub==0.25.1
151
+ # via gradio
152
+ pygments==2.19.1
153
+ # via rich
154
+ python-dateutil==2.9.0.post0
155
+ # via pandas
156
+ python-dotenv==1.1.0
157
+ # via
158
+ # alfredagent (pyproject.toml)
159
+ # litellm
160
+ # smolagents
161
+ python-multipart==0.0.20
162
+ # via gradio
163
+ pytz==2025.2
164
+ # via pandas
165
+ pyyaml==6.0.2
166
+ # via
167
+ # gradio
168
+ # huggingface-hub
169
+ referencing==0.36.2
170
+ # via
171
+ # jsonschema
172
+ # jsonschema-specifications
173
+ regex==2024.11.6
174
+ # via tiktoken
175
+ requests==2.32.4
176
+ # via
177
+ # huggingface-hub
178
+ # smolagents
179
+ # tiktoken
180
+ rich==14.0.0
181
+ # via
182
+ # smolagents
183
+ # typer
184
+ rpds-py==0.25.1
185
+ # via
186
+ # jsonschema
187
+ # referencing
188
+ ruff==0.11.13
189
+ # via gradio
190
+ safehttpx==0.1.6
191
+ # via gradio
192
+ semantic-version==2.10.0
193
+ # via gradio
194
+ shellingham==1.5.4
195
+ # via typer
196
+ six==1.17.0
197
+ # via python-dateutil
198
+ smolagents==1.18.0
199
+ # via alfredagent (pyproject.toml)
200
+ sniffio==1.3.1
201
+ # via
202
+ # anyio
203
+ # openai
204
+ starlette==0.46.2
205
+ # via
206
+ # fastapi
207
+ # gradio
208
+ tiktoken==0.9.0
209
+ # via litellm
210
+ tokenizers==0.21.1
211
+ # via litellm
212
+ tomlkit==0.13.3
213
+ # via gradio
214
+ tqdm==4.67.1
215
+ # via
216
+ # huggingface-hub
217
+ # openai
218
+ typer==0.16.0
219
+ # via gradio
220
+ typing-extensions==4.14.0
221
+ # via
222
+ # anyio
223
+ # fastapi
224
+ # gradio
225
+ # gradio-client
226
+ # huggingface-hub
227
+ # openai
228
+ # pydantic
229
+ # pydantic-core
230
+ # referencing
231
+ # typer
232
+ # typing-inspection
233
+ typing-inspection==0.4.1
234
+ # via pydantic
235
+ tzdata==2025.2
236
+ # via pandas
237
+ urllib3==2.4.0
238
+ # via requests
239
+ uvicorn==0.34.3
240
+ # via gradio
241
+ websockets==15.0.1
242
+ # via gradio-client
243
+ yarl==1.20.1
244
+ # via aiohttp
245
+ zipp==3.23.0
246
+ # via importlib-metadata
uv.lock ADDED
The diff for this file is too large to render. See raw diff