Update app.py
Browse files
app.py
CHANGED
|
@@ -6,17 +6,33 @@ import yaml
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +71,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
+
import os
|
| 10 |
+
from twilio.rest import Client
|
| 11 |
+
|
| 12 |
+
# Find your Account SID and Auth Token at twilio.com/console
|
| 13 |
+
# and set the environment variables. See http://twil.io/secure
|
| 14 |
+
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
|
| 15 |
+
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
|
| 16 |
+
my_number = os.environ["MY_NUMBER"]
|
| 17 |
+
client = Client(account_sid, auth_token)
|
| 18 |
|
|
|
|
| 19 |
@tool
|
| 20 |
+
def send_message(phone_number:str, text:str)-> None:
|
| 21 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 22 |
+
"""A tool that sends you a Whatsapp message at the number containing text
|
| 23 |
Args:
|
| 24 |
+
phone_number: The phone number, it should have the extension + and country code, without spaces
|
| 25 |
+
text: The text that will be sent to the whatsapp number
|
| 26 |
"""
|
| 27 |
+
try:
|
| 28 |
+
message = client.messages.create(
|
| 29 |
+
from_="whatsapp:"+my_number,
|
| 30 |
+
body=text,
|
| 31 |
+
to="whatsapp:"+number,
|
| 32 |
+
)
|
| 33 |
+
except Exception as e:
|
| 34 |
+
return "There was an error sending the message, please try using the QR first and try again."
|
| 35 |
+
return message.body
|
| 36 |
|
| 37 |
@tool
|
| 38 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 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,
|