nizar125 commited on
Commit
a68741e
·
verified ·
1 Parent(s): dacd7cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -1,14 +1,11 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  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
 
13
  @tool
14
  def get_weather(city: str) -> str:
@@ -22,8 +19,6 @@ def get_weather(city: str) -> str:
22
  A string describing the current weather.
23
  """
24
  try:
25
- import requests
26
-
27
  api_key = "5499415a1e8327b9200f4df7eb114c11"
28
 
29
  # Step 1: Get coordinates
@@ -49,25 +44,22 @@ def get_weather(city: str) -> str:
49
  return f"Error fetching weather: {str(e)}"
50
 
51
 
52
-
53
  @tool
54
  def get_current_time_in_timezone(timezone: str) -> str:
55
- """A tool that fetches the current local time in a specified timezone.
 
 
56
  Args:
57
  timezone: A string representing a valid timezone (e.g., 'America/New_York').
58
  """
59
  try:
60
- # Create timezone object
61
  tz = pytz.timezone(timezone)
62
- # Get current time in that timezone
63
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
64
  return f"The current local time in {timezone} is: {local_time}"
65
  except Exception as e:
66
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
67
 
68
 
69
- final_answer = FinalAnswerTool()
70
-
71
  # 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:
72
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
73
 
 
1
+ from smolagents import CodeAgent, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from Gradio_UI import GradioUI
8
 
 
 
9
 
10
  @tool
11
  def get_weather(city: str) -> str:
 
19
  A string describing the current weather.
20
  """
21
  try:
 
 
22
  api_key = "5499415a1e8327b9200f4df7eb114c11"
23
 
24
  # Step 1: Get coordinates
 
44
  return f"Error fetching weather: {str(e)}"
45
 
46
 
 
47
  @tool
48
  def get_current_time_in_timezone(timezone: str) -> str:
49
+ """
50
+ A tool that fetches the current local time in a specified timezone.
51
+
52
  Args:
53
  timezone: A string representing a valid timezone (e.g., 'America/New_York').
54
  """
55
  try:
 
56
  tz = pytz.timezone(timezone)
 
57
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
58
  return f"The current local time in {timezone} is: {local_time}"
59
  except Exception as e:
60
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
61
 
62
 
 
 
63
  # 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:
64
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
65