Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -7,16 +7,39 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  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:
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ search_tool = DuckDuckGoSearchTool()
11
+ # Initialize the DuckDuckGo search tool
12
+ search_tool = DuckDuckGoSearchTool()
13
+
14
+
15
  @tool
16
+ def get_top_places(city: str, category: str = "places", n: int = 5) -> list:
17
+ """
18
+ Get the top N places for a given category in a specified city.
19
+
20
+ Parameters:
21
+ city (str): The name of the city to search for.
22
+ category (str): The category to search (e.g., "places", "food", "museum"). Default is "places".
23
+ n (int): The number of results to return. Default is 5, maximum 100.
24
+
25
+ Returns:
26
+ list: A list of strings containing the title and URL for each result.
27
+
28
+ Raises:
29
+ ValueError: If the category is not one of "places", "food", or "museum".
30
+
31
+ Example:
32
+ >>> get_top_places("Paris", "food", 5)
33
+ ['Le Meurice - https://example.com', 'L'Ambroisie - https://example.com']
34
  """
35
+ valid_categories = ["places", "food", "museum"]
36
+ if category not in valid_categories:
37
+ raise ValueError(f"Invalid category. Choose from: {', '.join(valid_categories)}")
38
+
39
+ query = f"top {n} {category} in {city}"
40
+ results = search_tool.search(query, n)
41
+ return [f"{result['title']} - {result['url']}" for result in results]
42
+
43
 
44
  @tool
45
  def get_current_time_in_timezone(timezone: str) -> str: