Sharan1712 commited on
Commit
821b73b
·
verified ·
1 Parent(s): 22ee229

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -1,15 +1,17 @@
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.visit_webpage import VisitWebpageTool
7
  from tools.final_answer import FinalAnswerTool
 
8
 
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
- '''@tool
 
13
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
  """A tool that does nothing yet
@@ -17,8 +19,10 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
17
  arg1: the first argument
18
  arg2: the second argument
19
  """
20
- return "What magic will you build ?"'''
 
21
 
 
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
24
  """A tool that fetches the current local time in a specified timezone.
@@ -33,12 +37,11 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  return f"The current local time in {timezone} is: {local_time}"
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
 
36
 
37
  @tool
38
  def get_current_date() -> str:
39
- """A tool that fetches the current date in a specified timezone.
40
- Args:
41
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
42
  """
43
  try:
44
  date = datetime.date.today()
@@ -46,7 +49,6 @@ def get_current_date() -> str:
46
  except Exception as e:
47
  return f"Error fetching date: {str(e)}"
48
 
49
- date_fetch = get_current_date()
50
  visit_webpage = VisitWebpageTool()
51
  web_search = DuckDuckGoSearchTool()
52
  final_answer = FinalAnswerTool()
@@ -70,7 +72,7 @@ with open("new_prompts.yaml", 'r') as stream:
70
 
71
  agent = CodeAgent(
72
  model=model,
73
- tools=[date_fetch, visit_webpage, web_search, final_answer], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,
 
1
+ from smolagents import CodeAgent, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.visit_webpage import VisitWebpageTool
7
  from tools.final_answer import FinalAnswerTool
8
+ from tools.web_search import DuckDuckGoSearchTool
9
 
10
  from Gradio_UI import GradioUI
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
+ '''
14
+ @tool
15
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
16
  #Keep this format for the description / args / args description but feel free to modify the tool
17
  """A tool that does nothing yet
 
19
  arg1: the first argument
20
  arg2: the second argument
21
  """
22
+ return "What magic will you build ?"
23
+ '''
24
 
25
+ '''
26
  @tool
27
  def get_current_time_in_timezone(timezone: str) -> str:
28
  """A tool that fetches the current local time in a specified timezone.
 
37
  return f"The current local time in {timezone} is: {local_time}"
38
  except Exception as e:
39
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
40
+ '''
41
 
42
  @tool
43
  def get_current_date() -> str:
44
+ """A tool that fetches the current date.
 
 
45
  """
46
  try:
47
  date = datetime.date.today()
 
49
  except Exception as e:
50
  return f"Error fetching date: {str(e)}"
51
 
 
52
  visit_webpage = VisitWebpageTool()
53
  web_search = DuckDuckGoSearchTool()
54
  final_answer = FinalAnswerTool()
 
72
 
73
  agent = CodeAgent(
74
  model=model,
75
+ tools=[get_current_date, visit_webpage, web_search, final_answer], ## add your tools here (don't remove final answer)
76
  max_steps=6,
77
  verbosity_level=1,
78
  grammar=None,