ignacio-ferreira-dev commited on
Commit
6a1dc95
·
verified ·
1 Parent(s): 951828c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -4,7 +4,6 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from Gradio_UI import GradioUI
9
  import os
10
  from twilio.rest import Client
@@ -34,6 +33,30 @@ def send_message(phone_number:str, text:str)-> str:
34
  return "Error while sending request: "+str(e)
35
  return "Message sent correctly to "+phone_number + " "+str(message)
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  @tool
38
  def get_current_time_in_timezone(timezone: str) -> str:
39
  """A tool that fetches the current local time in a specified timezone.
@@ -71,7 +94,7 @@ with open("prompts.yaml", 'r') as stream:
71
 
72
  agent = CodeAgent(
73
  model=model,
74
- tools=[send_message, final_answer], ## add your tools here (don't remove final answer)
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from Gradio_UI import GradioUI
8
  import os
9
  from twilio.rest import Client
 
33
  return "Error while sending request: "+str(e)
34
  return "Message sent correctly to "+phone_number + " "+str(message)
35
 
36
+ @tool
37
+ def get_cat_fact()-> [str | None]:
38
+ """A tool that gives you a random fact about cats each time, it can return a string in case the result is correctly obtained, or none in case there was an error
39
+ Args: no args
40
+ """
41
+ url = "https://meowfacts.herokuapp.com/"
42
+ try:
43
+ # Make a GET request to the API
44
+ response = requests.get(url)
45
+
46
+ # Check that the request was successful
47
+ if response.status_code == 200:
48
+ # Parse the JSON response
49
+ data = response.json()
50
+ # Extract the fact (if available)
51
+ fact = data.get('data', [])[0] if 'data' in data and data['data'] else None
52
+ return fact
53
+ else:
54
+ print(f"Failed to fetch data. Status code: {response.status_code}")
55
+ return None
56
+ except requests.exceptions.RequestException as e:
57
+ print(f"An error occurred: {e}")
58
+ return None
59
+
60
  @tool
61
  def get_current_time_in_timezone(timezone: str) -> str:
62
  """A tool that fetches the current local time in a specified timezone.
 
94
 
95
  agent = CodeAgent(
96
  model=model,
97
+ tools=[send_message, get_cat_fact, final_answer], ## add your tools here (don't remove final answer)
98
  max_steps=6,
99
  verbosity_level=1,
100
  grammar=None,