Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,6 +34,70 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
| 37 |
+
# My test-tool 1!
|
| 38 |
+
@tool
|
| 39 |
+
def get_most_common_name_in_a_country(country: str) -> str:
|
| 40 |
+
"""Fetches the most common first name in a given country.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
country: The name of the country (e.g., "United States", "India").
|
| 44 |
+
|
| 45 |
+
Returns:
|
| 46 |
+
A string containing the most common first name in that country.
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
country_map = {
|
| 50 |
+
"United States": "US",
|
| 51 |
+
"India": "IN",
|
| 52 |
+
"United Kingdom": "GB",
|
| 53 |
+
"Germany": "DE",
|
| 54 |
+
"France": "FR",
|
| 55 |
+
"Canada": "CA",
|
| 56 |
+
"Australia": "AU",
|
| 57 |
+
"Brazil": "BR",
|
| 58 |
+
"China": "CN",
|
| 59 |
+
"Japan": "JP",
|
| 60 |
+
"Mexico": "MX",
|
| 61 |
+
"Russia": "RU",
|
| 62 |
+
"South Korea": "KR",
|
| 63 |
+
"South Africa": "ZA",
|
| 64 |
+
"Italy": "IT",
|
| 65 |
+
"Spain": "ES",
|
| 66 |
+
"Netherlands": "NL",
|
| 67 |
+
"Sweden": "SE",
|
| 68 |
+
"Norway": "NO",
|
| 69 |
+
"Denmark": "DK",
|
| 70 |
+
"Finland": "FI",
|
| 71 |
+
"Argentina": "AR",
|
| 72 |
+
"Colombia": "CO",
|
| 73 |
+
"Turkey": "TR",
|
| 74 |
+
"Saudi Arabia": "SA",
|
| 75 |
+
"Indonesia": "ID",
|
| 76 |
+
"Pakistan": "PK",
|
| 77 |
+
"Vietnam": "VN",
|
| 78 |
+
"Thailand": "TH",
|
| 79 |
+
"Egypt": "EG",
|
| 80 |
+
"Philippines": "PH"
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
country_code = country_map.get(country)
|
| 85 |
+
if not country_code:
|
| 86 |
+
return f"Sorry, I don't have data for {country}."
|
| 87 |
+
|
| 88 |
+
try:
|
| 89 |
+
response = requests.get(f"https://api.agify.io/?country_id={country_code}")
|
| 90 |
+
data = response.json()
|
| 91 |
+
|
| 92 |
+
if "name" in data:
|
| 93 |
+
return f"The most common name in {country} is {data['name']}."
|
| 94 |
+
else:
|
| 95 |
+
return f"Could not find common name data for {country}."
|
| 96 |
+
|
| 97 |
+
except Exception as e:
|
| 98 |
+
return f"Error fetching name data: {str(e)}"
|
| 99 |
+
|
| 100 |
+
|
| 101 |
final_answer = FinalAnswerTool()
|
| 102 |
|
| 103 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|