Pkey commited on
Commit
d771735
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -6
app.py CHANGED
@@ -1,4 +1,7 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
 
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -8,15 +11,35 @@ from tools.final_answer import FinalAnswerTool
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:
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ from duckduckgo_search import DDGS
3
+ from typing import List
4
+ from huggingface_hub import tool
5
  import datetime
6
  import requests
7
  import pytz
 
11
  from Gradio_UI import GradioUI
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
+ # @tool
15
+ # def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
16
+ # #Keep this format for the description / args / args description but feel free to modify the tool
17
+ # """A tool that does nothing yet
18
+ # Args:
19
+ # arg1: the first argument
20
+ # arg2: the second argument
21
+ # """
22
+ # return "What magic will you build ?"
23
+
24
  @tool
25
+ def search_tourist_places(destination: str) -> str:
26
+ """Searches for top tourist places to visit in a given location using DuckDuckGo.
27
+
28
  Args:
29
+ destination: The name of the city or country to search tourist attractions for.
 
30
  """
31
+ try:
32
+ with DDGS() as ddgs:
33
+ results = ddgs.text(f"top tourist places to visit in {destination}", max_results=5)
34
+ if not results:
35
+ return f"No tourist places found for {destination}."
36
+
37
+ # Format the results into a string
38
+ formatted = "\n".join([f"- {r['title']}: {r['href']}" for r in results])
39
+ return f"Top tourist places in {destination}:\n{formatted}"
40
+ except Exception as e:
41
+ return f"Error occurred while searching: {str(e)}"
42
+
43
 
44
  @tool
45
  def get_current_time_in_timezone(timezone: str) -> str: