Aramide commited on
Commit
b425993
·
verified ·
1 Parent(s): 5ffb4a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -33
app.py CHANGED
@@ -10,38 +10,6 @@ from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
 
13
- @tool
14
- def web_search_tool(query: str, num_results: int = 3) -> str:
15
- """A tool that performs a web search and fetches up-to-date information using DuckDuckGo.
16
-
17
- Args:
18
- query: The search query or topic to look up on the web.
19
- num_results: The number of top search results to return (default is 3).
20
-
21
- Returns:
22
- A string containing summarized up-to-date information from the web.
23
- """
24
- try:
25
- with DDGS() as ddg:
26
- results = list(ddg.text(query, max_results=num_results))
27
-
28
- if not results:
29
- return f"No results found for '{query}'."
30
-
31
- info_list = []
32
- for i, r in enumerate(results):
33
- title = r.get("title") or "No title"
34
- body = r.get("body") or "No summary available."
35
- link = r.get("href") or r.get("url", "")
36
- info_list.append(f"{i+1}. {title}\n{body}\n({link})")
37
-
38
- return f"Here are the top {num_results} results for '{query}':\n\n" + "\n\n".join(info_list)
39
-
40
- except Exception as e:
41
- # return the exception text so debugging in the UI is easier
42
- return f"Error performing web search for '{query}': {type(e).__name__}: {e}"
43
-
44
-
45
 
46
  @tool
47
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -78,9 +46,10 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
78
  with open("prompts.yaml", 'r') as stream:
79
  prompt_templates = yaml.safe_load(stream)
80
 
 
81
  agent = CodeAgent(
82
  model=model,
83
- tools=[final_answer, get_current_time_in_timezone, web_search_tool], ## add your tools here (don't remove final answer)
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  @tool
15
  def get_current_time_in_timezone(timezone: str) -> str:
 
46
  with open("prompts.yaml", 'r') as stream:
47
  prompt_templates = yaml.safe_load(stream)
48
 
49
+ duckduckgo_tool = DuckDuckGoSearchTool()
50
  agent = CodeAgent(
51
  model=model,
52
+ tools=[final_answer, get_current_time_in_timezone, duckduckgo_tool],
53
  max_steps=6,
54
  verbosity_level=1,
55
  grammar=None,