Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity
|
11 |
@tool
|
12 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
@@ -26,209 +26,226 @@ def get_country_capital(country_name:str)-> str:
|
|
26 |
country_name: A string representing the country name
|
27 |
"""
|
28 |
countries = {
|
29 |
-
"
|
30 |
-
"
|
31 |
-
"
|
32 |
-
"
|
33 |
-
"
|
34 |
-
"
|
35 |
-
"
|
36 |
-
"
|
37 |
-
"
|
38 |
-
"
|
39 |
-
"
|
40 |
-
"
|
41 |
-
"
|
42 |
-
"
|
43 |
-
"
|
44 |
-
"
|
45 |
-
"
|
46 |
-
"
|
47 |
-
"
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"
|
51 |
-
"
|
52 |
-
"
|
53 |
-
"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
-
"
|
59 |
-
"
|
60 |
-
"
|
61 |
-
"
|
62 |
-
"
|
63 |
-
"
|
64 |
-
"
|
65 |
-
"
|
66 |
-
"
|
67 |
-
"
|
68 |
-
"
|
69 |
-
"
|
70 |
-
"
|
71 |
-
"
|
72 |
-
"
|
73 |
-
"
|
74 |
-
"
|
75 |
-
"
|
76 |
-
"
|
77 |
-
"
|
78 |
-
"
|
79 |
-
"
|
80 |
-
"
|
81 |
-
"
|
82 |
-
"
|
83 |
-
"
|
84 |
-
"
|
85 |
-
"
|
86 |
-
"
|
87 |
-
"
|
88 |
-
"
|
89 |
-
"
|
90 |
-
"
|
91 |
-
"
|
92 |
-
"
|
93 |
-
"
|
94 |
-
"
|
95 |
-
"
|
96 |
-
"
|
97 |
-
"
|
98 |
-
"
|
99 |
-
"
|
100 |
-
"
|
101 |
-
"
|
102 |
-
"
|
103 |
-
"
|
104 |
-
"
|
105 |
-
"
|
106 |
-
"
|
107 |
-
"
|
108 |
-
"
|
109 |
-
"
|
110 |
-
"
|
111 |
-
"
|
112 |
-
"
|
113 |
-
"
|
114 |
-
"
|
115 |
-
"
|
116 |
-
"
|
117 |
-
"
|
118 |
-
"
|
119 |
-
"
|
120 |
-
"
|
121 |
-
"
|
122 |
-
"
|
123 |
-
"
|
124 |
-
"
|
125 |
-
"
|
126 |
-
"
|
127 |
-
"
|
128 |
-
"
|
129 |
-
"
|
130 |
-
"
|
131 |
-
"
|
132 |
-
"
|
133 |
-
"
|
134 |
-
"
|
135 |
-
"
|
136 |
-
"
|
137 |
-
"
|
138 |
-
"
|
139 |
-
"
|
140 |
-
"
|
141 |
-
"
|
142 |
-
"
|
143 |
-
"
|
144 |
-
"
|
145 |
-
"
|
146 |
-
"
|
147 |
-
"
|
148 |
-
"
|
149 |
-
"
|
150 |
-
"
|
151 |
-
"
|
152 |
-
"
|
153 |
-
"
|
154 |
-
"
|
155 |
-
"
|
156 |
-
"
|
157 |
-
"
|
158 |
-
"
|
159 |
-
"
|
160 |
-
"
|
161 |
-
"
|
162 |
-
"
|
163 |
-
"
|
164 |
-
"
|
165 |
-
"
|
166 |
-
"
|
167 |
-
"
|
168 |
-
"
|
169 |
-
"
|
170 |
-
"
|
171 |
-
"
|
172 |
-
"
|
173 |
-
"
|
174 |
-
"
|
175 |
-
"
|
176 |
-
"
|
177 |
-
"
|
178 |
-
"
|
179 |
-
"
|
180 |
-
"
|
181 |
-
"
|
182 |
-
"
|
183 |
-
"
|
184 |
-
"
|
185 |
-
"
|
186 |
-
"
|
187 |
-
"
|
188 |
-
"
|
189 |
-
"
|
190 |
-
"
|
191 |
-
"
|
192 |
-
"
|
193 |
-
"
|
194 |
-
"
|
195 |
-
"
|
196 |
-
"
|
197 |
-
"
|
198 |
-
"
|
199 |
-
"
|
200 |
-
"
|
201 |
-
"
|
202 |
-
"
|
203 |
-
"
|
204 |
-
"
|
205 |
-
"
|
206 |
-
"
|
207 |
-
"
|
208 |
-
"
|
209 |
-
"
|
210 |
-
"
|
211 |
-
"
|
212 |
-
"
|
213 |
-
"
|
214 |
-
"
|
215 |
-
"
|
216 |
-
"
|
217 |
-
"
|
218 |
-
"
|
219 |
-
"
|
220 |
-
"
|
221 |
-
"
|
222 |
-
"
|
223 |
-
"
|
224 |
-
"
|
225 |
}
|
226 |
|
227 |
-
|
|
|
228 |
if not capital:
|
229 |
return f"Cannot find the capital of {country_name} Try to enter the name correct"
|
230 |
return f"The Capital of {country_name} is {capital}"
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
@tool
|
234 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -267,7 +284,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
267 |
|
268 |
agent = CodeAgent(
|
269 |
model=model,
|
270 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
271 |
max_steps=6,
|
272 |
verbosity_level=1,
|
273 |
grammar=None,
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
+
# Below is an example of a tool that does nothing. Amaze us with your creativity!
|
11 |
@tool
|
12 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
|
26 |
country_name: A string representing the country name
|
27 |
"""
|
28 |
countries = {
|
29 |
+
"afghanistan": "Kabul",
|
30 |
+
"albania": "Tirana",
|
31 |
+
"algeria": "Algiers",
|
32 |
+
"andorra": "Andorra la Vella",
|
33 |
+
"angola": "Luanda",
|
34 |
+
"antigua and barbuda": "Saint John’s",
|
35 |
+
"argentina": "Buenos Aires",
|
36 |
+
"armenia": "Yerevan",
|
37 |
+
"australia": "Canberra",
|
38 |
+
"austria": "Vienna",
|
39 |
+
"azerbaijan": "Baku",
|
40 |
+
"the bahamas": "Nassau",
|
41 |
+
"bahrain": "Manama",
|
42 |
+
"bangladesh": "Dhaka",
|
43 |
+
"barbados": "Bridgetown",
|
44 |
+
"belarus": "Minsk",
|
45 |
+
"belgium": "Brussels",
|
46 |
+
"belize": "Belmopan",
|
47 |
+
"benin": "Porto-Novo",
|
48 |
+
"bhutan": "Thimphu",
|
49 |
+
"bolivia": "La Paz, Sucre",
|
50 |
+
"bosnia and herzegovina": "Sarajevo",
|
51 |
+
"botswana": "Gaborone",
|
52 |
+
"brazil": "Brasilia",
|
53 |
+
"brunei": "Bandar Seri Begawan",
|
54 |
+
"bulgaria": "Sofia",
|
55 |
+
"burkina faso": "Ouagadougou",
|
56 |
+
"burundi": "Bujumbura",
|
57 |
+
"cambodia": "Phnom Penh",
|
58 |
+
"cameroon": "Yaounde",
|
59 |
+
"canada": "Ottawa",
|
60 |
+
"cape verde": "Praia",
|
61 |
+
"central african republic": "Bangui",
|
62 |
+
"chad": "N’Djamena",
|
63 |
+
"chile": "Santiago",
|
64 |
+
"china": "Beijing",
|
65 |
+
"colombia": "Bogota",
|
66 |
+
"comoros": "Moroni",
|
67 |
+
"republic of the congo": "Brazzaville",
|
68 |
+
"democratic republic of the congo": "Kinshasa",
|
69 |
+
"costa rica": "San Jose",
|
70 |
+
"cote d’ivoire": "Yamoussoukro",
|
71 |
+
"croatia": "Zagreb",
|
72 |
+
"cuba": "Havana",
|
73 |
+
"cyprus": "Nicosia",
|
74 |
+
"czech republic": "Prague",
|
75 |
+
"denmark": "Copenhagen",
|
76 |
+
"djibouti": "Djibouti",
|
77 |
+
"dominica": "Roseau",
|
78 |
+
"dominican republic": "Santo Domingo",
|
79 |
+
"east timor": "Dili",
|
80 |
+
"ecuador": "Quito",
|
81 |
+
"egypt": "Cairo",
|
82 |
+
"el salvador": "San Salvador",
|
83 |
+
"equatorial guinea": "Malabo",
|
84 |
+
"eritrea": "Asmara",
|
85 |
+
"estonia": "Tallinn",
|
86 |
+
"ethiopia": "Addis Ababa",
|
87 |
+
"fiji": "Suva",
|
88 |
+
"finland": "Helsinki",
|
89 |
+
"france": "Paris",
|
90 |
+
"gabon": "Libreville",
|
91 |
+
"the gambia": "Banjul",
|
92 |
+
"georgia": "Tbilisi",
|
93 |
+
"germany": "Berlin",
|
94 |
+
"ghana": "Accra",
|
95 |
+
"greece": "Athens",
|
96 |
+
"grenada": "Saint George’s",
|
97 |
+
"guatemala": "Guatemala City",
|
98 |
+
"guinea": "Conakry",
|
99 |
+
"guinea-bissau": "Bissau",
|
100 |
+
"guyana": "Georgetown",
|
101 |
+
"haiti": "Port-au-Prince",
|
102 |
+
"honduras": "Tegucigalpa",
|
103 |
+
"hungary": "Budapest",
|
104 |
+
"iceland": "Reykjavik",
|
105 |
+
"india": "New Delhi",
|
106 |
+
"indonesia": "Jakarta",
|
107 |
+
"iran": "Tehran",
|
108 |
+
"iraq": "Baghdad",
|
109 |
+
"ireland": "Dublin",
|
110 |
+
"israel": "Jerusalem",
|
111 |
+
"italy": "Rome",
|
112 |
+
"jamaica": "Kingston",
|
113 |
+
"japan": "Tokyo",
|
114 |
+
"jordan": "Amman",
|
115 |
+
"kazakhstan": "Astana",
|
116 |
+
"kenya": "Nairobi",
|
117 |
+
"kiribati": "Tarawa Atoll",
|
118 |
+
"north korea": "Pyongyang",
|
119 |
+
"south korea": "Seoul",
|
120 |
+
"kosovo": "Pristina",
|
121 |
+
"kuwait": "Kuwait City",
|
122 |
+
"kyrgyzstan": "Bishkek",
|
123 |
+
"laos": "Vientiane",
|
124 |
+
"latvia": "Riga",
|
125 |
+
"lebanon": "Beirut",
|
126 |
+
"lesotho": "Maseru",
|
127 |
+
"liberia": "Monrovia",
|
128 |
+
"libya": "Tripoli",
|
129 |
+
"liechtenstein": "Vaduz",
|
130 |
+
"lithuania": "Vilnius",
|
131 |
+
"luxembourg": "Luxembourg",
|
132 |
+
"macedonia": "Skopje",
|
133 |
+
"madagascar": "Antananarivo",
|
134 |
+
"malawi": "Lilongwe",
|
135 |
+
"malaysia": "Kuala Lumpur",
|
136 |
+
"maldives": "Male",
|
137 |
+
"mali": "Bamako",
|
138 |
+
"malta": "Valletta",
|
139 |
+
"marshall islands": "Majuro",
|
140 |
+
"mauritania": "Nouakchott",
|
141 |
+
"mauritius": "Port Louis",
|
142 |
+
"mexico": "Mexico City",
|
143 |
+
"federated states of micronesia": "Palikir",
|
144 |
+
"moldova": "Chisinau",
|
145 |
+
"monaco": "Monaco",
|
146 |
+
"mongolia": "Ulaanbaatar",
|
147 |
+
"montenegro": "Podgorica",
|
148 |
+
"morocco": "Rabat",
|
149 |
+
"mozambique": "Maputo",
|
150 |
+
"myanmar": "Naypyidaw",
|
151 |
+
"namibia": "Windhoek",
|
152 |
+
"nauru": "Yaren District",
|
153 |
+
"nepal": "Kathmandu",
|
154 |
+
"netherlands": "Amsterdam",
|
155 |
+
"new zealand": "Wellington",
|
156 |
+
"nicaragua": "Managua",
|
157 |
+
"niger": "Niamey",
|
158 |
+
"nigeria": "Abuja",
|
159 |
+
"norway": "Oslo",
|
160 |
+
"oman": "Muscat",
|
161 |
+
"pakistan": "Islamabad",
|
162 |
+
"palau": "Melekeok",
|
163 |
+
"panama": "Panama City",
|
164 |
+
"papua new guinea": "Port Moresby",
|
165 |
+
"paraguay": "Asuncion",
|
166 |
+
"peru": "Lima",
|
167 |
+
"philippines": "Manila",
|
168 |
+
"poland": "Warsaw",
|
169 |
+
"portugal": "Lisbon",
|
170 |
+
"qatar": "Doha",
|
171 |
+
"romania": "Bucharest",
|
172 |
+
"russia": "Moscow",
|
173 |
+
"rwanda": "Kigali",
|
174 |
+
"saint kitts and nevis": "Basseterre",
|
175 |
+
"saint lucia": "Castries",
|
176 |
+
"saint vincent and the grenadines": "Kingstown",
|
177 |
+
"samoa": "Apia",
|
178 |
+
"san marino": "San Marino",
|
179 |
+
"sao tome and principe": "Sao Tome",
|
180 |
+
"saudi arabia": "Riyadh",
|
181 |
+
"senegal": "Dakar",
|
182 |
+
"serbia": "Belgrade",
|
183 |
+
"seychelles": "Victoria",
|
184 |
+
"sierra leone": "Freetown",
|
185 |
+
"singapore": "Singapore",
|
186 |
+
"slovakia": "Bratislava",
|
187 |
+
"slovenia": "Ljubljana",
|
188 |
+
"solomon islands": "Honiara",
|
189 |
+
"somalia": "Mogadishu",
|
190 |
+
"south africa": "Pretoria, Cape Town, Bloemfontein",
|
191 |
+
"south sudan": "Juba",
|
192 |
+
"spain": "Madrid",
|
193 |
+
"sri lanka": "Colombo, Sri Jayewardenepura Kotte",
|
194 |
+
"sudan": "Khartoum",
|
195 |
+
"suriname": "Paramaribo",
|
196 |
+
"swaziland": "Mbabane",
|
197 |
+
"sweden": "Stockholm",
|
198 |
+
"switzerland": "Bern",
|
199 |
+
"syria": "Damascus",
|
200 |
+
"taiwan": "Taipei",
|
201 |
+
"tajikistan": "Dushanbe",
|
202 |
+
"tanzania": "Dodoma",
|
203 |
+
"thailand": "Bangkok",
|
204 |
+
"togo": "Lome",
|
205 |
+
"tonga": "Nuku’alofa",
|
206 |
+
"trinidad and tobago": "Port-of-Spain",
|
207 |
+
"tunisia": "Tunis",
|
208 |
+
"turkey": "Ankara",
|
209 |
+
"turkmenistan": "Ashgabat",
|
210 |
+
"tuvalu": "Funafuti",
|
211 |
+
"uganda": "Kampala",
|
212 |
+
"ukraine": "Kyiv",
|
213 |
+
"united arab emirates": "Abu Dhabi",
|
214 |
+
"united kingdom": "London",
|
215 |
+
"united states of america": "Washington D.C.",
|
216 |
+
"uruguay": "Montevideo",
|
217 |
+
"uzbekistan": "Tashkent",
|
218 |
+
"vanuatu": "Port-Vila",
|
219 |
+
"vatican city": "Vatican City",
|
220 |
+
"venezuela": "Caracas",
|
221 |
+
"vietnam": "Hanoi",
|
222 |
+
"yemen": "Sanaa",
|
223 |
+
"zambia": "Lusaka",
|
224 |
+
"zimbabwe": "Harare",
|
225 |
}
|
226 |
|
227 |
+
|
228 |
+
capital = countries.get(country_name.lower())
|
229 |
if not capital:
|
230 |
return f"Cannot find the capital of {country_name} Try to enter the name correct"
|
231 |
return f"The Capital of {country_name} is {capital}"
|
232 |
|
233 |
+
@tool
|
234 |
+
def search(text: str) -> str:
|
235 |
+
"""A tool that uses DuckDuckGoSearchTool to search.
|
236 |
+
Args:
|
237 |
+
text:
|
238 |
+
"""
|
239 |
+
try:
|
240 |
+
# Create timezone object
|
241 |
+
tz = pytz.timezone(timezone)
|
242 |
+
# Get current time in that timezone
|
243 |
+
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
244 |
+
return f"The current local time in {timezone} is: {local_time}"
|
245 |
+
except Exception as e:
|
246 |
+
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
247 |
+
|
248 |
+
|
249 |
|
250 |
@tool
|
251 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
284 |
|
285 |
agent = CodeAgent(
|
286 |
model=model,
|
287 |
+
tools=[final_answer, DuckDuckGoSearchTool(), get_country_capital], ## add your tools here (don't remove final answer)
|
288 |
max_steps=6,
|
289 |
verbosity_level=1,
|
290 |
grammar=None,
|