sovholms commited on
Commit
af613bc
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -9,14 +9,34 @@ 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
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def get_country_info(country: str) -> str:
13
+ """A tool that returns general information about a given country, including currency, capital, population, and region.
 
14
  Args:
15
+ country: The name of the country (e.g., 'United States').
 
16
  """
17
+ try:
18
+ url = "https://restcountries.com/v3.1/name/" + country
19
+ response = requests.get(url)
20
+ data = response.json()
21
+
22
+ if isinstance(data, list) and len(data) > 0:
23
+ country_data = data[0]
24
+ currency_info = country_data.get("currencies", {})
25
+ currency_code = list(currency_info.keys())[0] if currency_info else "Unknown"
26
+ currency_name = currency_info[currency_code]["name"] if currency_code != "Unknown" else "Unknown"
27
+ capital = country_data.get("capital", ["Unknown"])[0]
28
+ population = country_data.get("population", "Unknown")
29
+ region = country_data.get("region", "Unknown")
30
+ return (f"Country: {country}\n"
31
+ f"Capital: {capital}\n"
32
+ f"Region: {region}\n"
33
+ f"Population: {population}\n"
34
+ f"Currency: {currency_name} ({currency_code})")
35
+ else:
36
+ return "Invalid country name. Please check your input."
37
+ except Exception as e:
38
+ return f"Error fetching country information: {str(e)}"
39
+
40
 
41
  @tool
42
  def get_current_time_in_timezone(timezone: str) -> str: