faiyazansariusa commited on
Commit
0222827
·
verified ·
1 Parent(s): 8341278

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -10,6 +10,29 @@ from Gradio_UI import GradioUI
10
 
11
  print ("Hello This is sample AI Project by Faiyaz")
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
@@ -61,7 +84,7 @@ with open("prompts.yaml", 'r') as stream:
61
 
62
  agent = CodeAgent(
63
  model=model,
64
- tools=[final_answer,web_search], ## add your tools here (don't remove final answer)
65
  max_steps=6,
66
  verbosity_level=1,
67
  grammar=None,
 
10
 
11
  print ("Hello This is sample AI Project by Faiyaz")
12
 
13
+ # tool for attractions
14
+
15
+ def get_attractions(city: str) -> str:
16
+ """Fetches recommended places of attraction in a specified city.
17
+ Args:
18
+ city: The name of the city (e.g., 'New York').
19
+ Returns:
20
+ A string with the recommended places of attraction.
21
+ """
22
+ api_key = "YOUR_GOOGLE_PLACES_API_KEY"
23
+ url = f"https://maps.googleapis.com/maps/api/place/textsearch/json?query=attractions+in+{city}&key={api_key}"
24
+
25
+ try:
26
+ response = requests.get(url).json()
27
+ if response["status"] != "OK":
28
+ return f"Error: {response['status']}"
29
+
30
+ attractions = [result["name"] for result in response["results"]]
31
+ return f"Recommended places of attraction in {city}:\n" + "\n".join(attractions)
32
+ except Exception as e:
33
+ return f"Error fetching attractions data: {str(e)}"
34
+
35
+
36
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
37
  @tool
38
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
 
84
 
85
  agent = CodeAgent(
86
  model=model,
87
+ tools=[final_answer,web_search,get_attractions], ## add your tools here (don't remove final answer)
88
  max_steps=6,
89
  verbosity_level=1,
90
  grammar=None,