samih-7 commited on
Commit
54ddbbb
·
verified ·
1 Parent(s): 9d8570b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -1,26 +1,28 @@
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
  from tools.visit_webpage import VisitWebpageTool
 
8
 
9
  from Gradio_UI import GradioUI
10
 
11
- ddg = DuckDuckGoSearchTool(max_results=5)
12
 
13
- @tool
14
- def search_web(query:str)-> str:
15
- """A tool that runs a DuckDuckGo search and returns a formatted result.
16
- Args:
17
- query: A string representing the query to search for.
18
- """
19
- try:
20
- results = ddg(query)
21
- return results
22
- except Exception as e:
23
- return f"Error while searching: {str(e)}"
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -39,6 +41,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
39
 
40
 
41
  final_answer = FinalAnswerTool()
 
42
  visit_webpage = VisitWebpageTool()
43
 
44
  # 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:
@@ -60,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
60
 
61
  agent = CodeAgent(
62
  model=model,
63
- tools=[final_answer, get_current_time_in_timezone, search_web, visit_webpage, image_generation_tool], ## add your tools here (don't remove final answer)
64
  max_steps=6,
65
  verbosity_level=1,
66
  grammar=None,
 
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
 
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:
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, get_current_time_in_timezone, web_search, visit_webpage, image_generation_tool], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,