adelatorre84 commited on
Commit
cd18bcd
·
verified ·
1 Parent(s): edf39a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -9,14 +9,24 @@ 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
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
 
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def DuckDuckSearchTool(query: str, num_results: int = 3) -> str:
13
+ """A tool that searches the web using DuckDuckGo and returns the top results.
14
+
15
  Args:
16
+ query: The search query string.
17
+ num_results: Number of search results to retrieve (default is 3).
18
+
19
+ Returns:
20
+ A formatted string with search results.
21
  """
22
+ search_tool = DuckDuckGoSearchTool()
23
+ results = search_tool(query=query, num_results=num_results)
24
+
25
+ if results:
26
+ return "\n".join([f"{i+1}. {res['title']} - {res['href']}" for i, res in enumerate(results)])
27
+ else:
28
+ return "No results found."
29
+
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str: