paulofroes commited on
Commit
5978476
·
verified ·
1 Parent(s): dceab17

adding the nearest neighborhood tool

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from tools.cheapest_flight import get_flight
8
 
9
  from Gradio_UI import GradioUI
@@ -40,6 +41,19 @@ def get_cheapest_flight(departureId:str, arrivalId:str, departureDate:str)-> str
40
  except Exception as e:
41
  return f"Error fetching time for cheapest flight: {str(e)}"
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  @tool
45
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -78,7 +92,7 @@ with open("prompts.yaml", 'r') as stream:
78
 
79
  agent = CodeAgent(
80
  model=model,
81
- tools=[final_answer, get_cheapest_flight], ## add your tools here (don't remove final answer)
82
  max_steps=6,
83
  verbosity_level=1,
84
  grammar=None,
@@ -89,4 +103,4 @@ agent = CodeAgent(
89
  )
90
 
91
 
92
- GradioUI(agent).launch()
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from tools.neighborhood_finder import find_nearest_neighborhood
8
  from tools.cheapest_flight import get_flight
9
 
10
  from Gradio_UI import GradioUI
 
41
  except Exception as e:
42
  return f"Error fetching time for cheapest flight: {str(e)}"
43
 
44
+ @tool
45
+ def get_nearest_neighborhood(location:str,)-> str:
46
+ """A tool that returns the nearest neighborhood to the user, given the region the user has given
47
+ Args:
48
+ lacation: The location the user provided of where he is.
49
+ """
50
+
51
+ try:
52
+ neighborhood = find_nearest_neighborhood(location)
53
+ return neighborhood
54
+ except Exception as e:
55
+ return f"Error finding the nearest neighborhood: {str(e)}"
56
+
57
 
58
  @tool
59
  def get_current_time_in_timezone(timezone: str) -> str:
 
92
 
93
  agent = CodeAgent(
94
  model=model,
95
+ tools=[final_answer, get_nearest_neighborhood, get_cheapest_flight], ## add your tools here (don't remove final answer)
96
  max_steps=6,
97
  verbosity_level=1,
98
  grammar=None,
 
103
  )
104
 
105
 
106
+ GradioUI(agent).launch()