JrettB commited on
Commit
5a6c023
·
verified ·
1 Parent(s): b1e4c62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -9,18 +9,24 @@ from Gradio_UI import GradioUI
9
 
10
 
11
  @tool
12
- def get_geolocation(city:str)-> str:
13
  """A tool that fetches the geo location of the city (e.g., "latitude":40.71427,"longitude":-74.00597)
14
  Args:
15
  city: A string representing a valid city (e.g., New York)
16
  """
17
- api_url = f"https://geocoding-api.open-meteo.com/v1/search?name={city}&count=1&language=en&format=json"
18
- response = requests.get(api_url)
19
- if response.status_code == 200:
20
- data = response.json()
21
- return data.get("latitude", "longitude")
22
- else:
23
- return "Error: Unable to fetch geo location."
 
 
 
 
 
 
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -60,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
60
 
61
  agent = CodeAgent(
62
  model=model,
63
- tools=[final_answer,get_geolocation,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
64
  max_steps=6,
65
  verbosity_level=1,
66
  grammar=None,
 
9
 
10
 
11
  @tool
12
+ """def get_geolocation(city:str)-> str:
13
  """A tool that fetches the geo location of the city (e.g., "latitude":40.71427,"longitude":-74.00597)
14
  Args:
15
  city: A string representing a valid city (e.g., New York)
16
  """
17
+ Try:"""
18
+
19
+ @tool
20
+ def model_download_tool(task: str) -> str:
21
+ """This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub.
22
+ It returns the name of the checkpoint.
23
+
24
+ Args:
25
+ task: The task for which to get the download count.
26
+ """
27
+ most_downloaded_model = next(iter(list_models(filter=task, sort="download", direction=-1)))
28
+
29
+ return most_downloaded_model.id
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str:
 
66
 
67
  agent = CodeAgent(
68
  model=model,
69
+ tools=[final_answer,most_downloaded_model], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,