Stoyan Georgiev commited on
Commit
8166b8e
·
1 Parent(s): b01d677

Updated the Space with new features

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -18,16 +18,23 @@ def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
- """A tool that fetches the current local time in a specified timezone.
24
- Args:
25
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
26
- """
 
 
 
 
 
 
 
 
27
  try:
28
- # Create timezone object
29
  tz = pytz.timezone(timezone)
30
- # Get current time in that timezone
31
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
32
  return f"The current local time in {timezone} is: {local_time}"
33
  except Exception as e:
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
24
+ # Falls der Nutzer eine Stadt statt eines gültigen Zeitzonen-IDs angibt,
25
+ # können wir eine Mapping-Tabelle verwenden.
26
+ timezone_mapping = {
27
+ "new york": "America/New_York",
28
+ "new york city": "America/New_York",
29
+ "nyc": "America/New_York",
30
+ # Füge hier weitere Mappings hinzu, falls nötig
31
+ }
32
+ key = timezone.lower().strip()
33
+ if key in timezone_mapping:
34
+ timezone = timezone_mapping[key]
35
+
36
  try:
 
37
  tz = pytz.timezone(timezone)
 
38
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
39
  return f"The current local time in {timezone} is: {local_time}"
40
  except Exception as e: