LucMarcelPellinger commited on
Commit
c7f9df4
·
verified ·
1 Parent(s): 985b17a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -23,10 +23,11 @@ def my_custom_tool(arg1:int, arg2:int)-> str: #it's import to specify the return
23
  return f"the result is {a}"
24
 
25
  @tool
26
- def todays_useless_fact(input_time: str) -> str:
27
  """Fetches today's useless fact from an external public API.
28
  Args:
29
- input_time: the datetime value as string for the specified time zone retrieved from get_current_time_in_timezone.
 
30
  """
31
  try:
32
  # Format date as YYYY-MM-DD (API only supports "today" or "random")
@@ -35,14 +36,13 @@ def todays_useless_fact(input_time: str) -> str:
35
  # input_time = datetime.fromisoformat(input_time)
36
  # except ValueError:
37
  # return "Invalid datetime format. Please use ISO format: YYYY-MM-DDTHH:MM:SS"
38
-
39
- formatted_date = input_time.strftime("%Y-%m-%d")
40
 
41
  # API doesn't actually support querying by date, so we just show today's
42
  response = requests.get("https://uselessfacts.jsph.pl/api/v2/facts/today")
43
  if response.status_code == 200:
44
  data = response.json()
45
- return f"On {formatted_date}, here's a useless fact: {data.get('text', 'No fact found.')}"
46
  else:
47
  return f"Failed to fetch fact: {response.status_code}"
48
  except Exception as e:
 
23
  return f"the result is {a}"
24
 
25
  @tool
26
+ def todays_useless_fact(result: str) -> str:
27
  """Fetches today's useless fact from an external public API.
28
  Args:
29
+ result: the datetime value and text for the result of the current time zone method
30
+ as string for the specified time zone retrieved from get_current_time_in_timezone.
31
  """
32
  try:
33
  # Format date as YYYY-MM-DD (API only supports "today" or "random")
 
36
  # input_time = datetime.fromisoformat(input_time)
37
  # except ValueError:
38
  # return "Invalid datetime format. Please use ISO format: YYYY-MM-DDTHH:MM:SS"
39
+
 
40
 
41
  # API doesn't actually support querying by date, so we just show today's
42
  response = requests.get("https://uselessfacts.jsph.pl/api/v2/facts/today")
43
  if response.status_code == 200:
44
  data = response.json()
45
+ return f"{result}. Here's a useless fact: {data.get('text', 'No fact found.')}"
46
  else:
47
  return f"Failed to fetch fact: {response.status_code}"
48
  except Exception as e: