samih-7 commited on
Commit
f1acb6e
·
verified ·
1 Parent(s): 2701dc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -1,28 +1,28 @@
1
  from smolagents import CodeAgent,HfApiModel,load_tool,tool
2
- # from smolagents import CodeAgent,DuckDuckGoSearchTool,HfApiModel,load_tool,tool
3
  import datetime
4
  import requests
5
  import pytz
6
  import yaml
7
  from tools.final_answer import FinalAnswerTool
8
  from tools.visit_webpage import VisitWebpageTool
9
- from tools.web_search import DuckDuckGoSearchTool
10
 
11
  from Gradio_UI import GradioUI
12
 
13
- # ddg = DuckDuckGoSearchTool(max_results=5)
14
 
15
- # @tool
16
- # def search_web(query:str)-> str:
17
  # """A tool that runs a DuckDuckGo search and returns a formatted result.
18
  # Args:
19
  # query: A string representing the query to search for.
20
  # """
21
- # try:
22
- # results = ddg(query)
23
- # return results
24
- # except Exception as e:
25
- # return f"Error while searching: {str(e)}"
26
 
27
  @tool
28
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -41,7 +41,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
41
 
42
 
43
  final_answer = FinalAnswerTool()
44
- web_search = DuckDuckGoSearchTool()
45
  visit_webpage = VisitWebpageTool()
46
 
47
  # 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:
 
1
  from smolagents import CodeAgent,HfApiModel,load_tool,tool
2
+ from smolagents import CodeAgent,DuckDuckGoSearchTool,HfApiModel,load_tool,tool
3
  import datetime
4
  import requests
5
  import pytz
6
  import yaml
7
  from tools.final_answer import FinalAnswerTool
8
  from tools.visit_webpage import VisitWebpageTool
9
+ # from tools.web_search import DuckDuckGoSearchTool
10
 
11
  from Gradio_UI import GradioUI
12
 
13
+ ddg = DuckDuckGoSearchTool(max_results=5)
14
 
15
+ @tool
16
+ def web_search(query:str)-> str:
17
  # """A tool that runs a DuckDuckGo search and returns a formatted result.
18
  # Args:
19
  # query: A string representing the query to search for.
20
  # """
21
+ try:
22
+ results = ddg(query)
23
+ return results
24
+ except Exception as e:
25
+ return f"Error while searching: {str(e)}"
26
 
27
  @tool
28
  def get_current_time_in_timezone(timezone: str) -> str:
 
41
 
42
 
43
  final_answer = FinalAnswerTool()
44
+ # web_search = DuckDuckGoSearchTool()
45
  visit_webpage = VisitWebpageTool()
46
 
47
  # 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: