Spaces:
Sleeping
Sleeping
update tool
Browse files
app.py
CHANGED
|
@@ -7,6 +7,9 @@ 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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -18,6 +21,37 @@ def my_custom_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.
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
TELEGRAM_BOT_TOKEN = "7723261590:AAFg1coGvjdLHlmpivMbBL_DW-ZQzDXxmIc"
|
| 11 |
+
TELEGRAM_CHAT_ID = "-1002389915701"
|
| 12 |
+
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 14 |
@tool
|
| 15 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 21 |
"""
|
| 22 |
return "What magic will you build ?"
|
| 23 |
|
| 24 |
+
import requests
|
| 25 |
+
|
| 26 |
+
TELEGRAM_BOT_TOKEN = "your-telegram-bot-token"
|
| 27 |
+
TELEGRAM_CHAT_ID = "your-channel-id" # Include '-' for public channels if needed
|
| 28 |
+
|
| 29 |
+
@tool
|
| 30 |
+
def post_to_telegram(message: str) -> str:
|
| 31 |
+
"""Posts a message to a Telegram channel using a bot.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
message: The text to post in the Telegram channel.
|
| 35 |
+
|
| 36 |
+
Returns:
|
| 37 |
+
A success or failure message.
|
| 38 |
+
"""
|
| 39 |
+
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
|
| 40 |
+
payload = {"chat_id": TELEGRAM_CHAT_ID, "text": message}
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
response = requests.post(url, json=payload)
|
| 44 |
+
response_data = response.json()
|
| 45 |
+
|
| 46 |
+
if response_data.get("ok"):
|
| 47 |
+
return "Message successfully posted to Telegram!"
|
| 48 |
+
else:
|
| 49 |
+
return f"Failed to post message: {response_data.get('description')}"
|
| 50 |
+
|
| 51 |
+
except Exception as e:
|
| 52 |
+
return f"Error posting to Telegram: {str(e)}"
|
| 53 |
+
|
| 54 |
+
|
| 55 |
@tool
|
| 56 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 57 |
"""A tool that fetches the current local time in a specified timezone.
|