blumski commited on
Commit
f1cfa4b
·
verified ·
1 Parent(s): 6ea6f60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -23,30 +23,30 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
23
  def get_coordinates_osm(location_name:str) -> str:
24
 
25
  """A tool that fetches gps coordinates of a given place in the world
26
- Args:
27
- arg1: the name of the location (e.g., 'Kinshasa, Gombe').
28
- """
29
- headers = {
30
- 'User-Agent': 'MyGeocodingApp/1.0 (youremail@example.com)'
31
- }
32
- location_name = location_name.replace(" ", "+")
33
- base_url = "https://nominatim.openstreetmap.org/search"
34
- full_url = f"{base_url}?q={requests.utils.quote(location_name)}&format=json&limit=5"
35
-
36
- response = requests.get(full_url, headers=headers)
37
-
38
- if response.status_code != 200:
39
- raise Exception("Erreur lors de la requête à l'API OpenStreetMap")
40
-
41
- response_list = response.json()
42
-
43
- if len(response_list) == 0:
44
- raise Exception("Aucune réponse trouvée pour cette recherche")
45
-
46
- latitude = float(response_list[0]['lat'])
47
- longitude = float(response_list[0]['lon'])
48
-
49
- return {'latitude': latitude, 'longitude': longitude}
50
 
51
  @tool
52
  def get_current_time_in_timezone(timezone: str) -> str:
 
23
  def get_coordinates_osm(location_name:str) -> str:
24
 
25
  """A tool that fetches gps coordinates of a given place in the world
26
+ Args:
27
+ arg1: the name of the location (e.g., 'Kinshasa, Gombe').
28
+ """
29
+ headers = {
30
+ 'User-Agent': 'MyGeocodingApp/1.0 (youremail@example.com)'
31
+ }
32
+ location_name = location_name.replace(" ", "+")
33
+ base_url = "https://nominatim.openstreetmap.org/search"
34
+ full_url = f"{base_url}?q={requests.utils.quote(location_name)}&format=json&limit=5"
35
+
36
+ response = requests.get(full_url, headers=headers)
37
+
38
+ if response.status_code != 200:
39
+ raise Exception("Erreur lors de la requête à l'API OpenStreetMap")
40
+
41
+ response_list = response.json()
42
+
43
+ if len(response_list) == 0:
44
+ raise Exception("Aucune réponse trouvée pour cette recherche")
45
+
46
+ latitude = float(response_list[0]['lat'])
47
+ longitude = float(response_list[0]['lon'])
48
+
49
+ return {'latitude': latitude, 'longitude': longitude}
50
 
51
  @tool
52
  def get_current_time_in_timezone(timezone: str) -> str: