Spaces:
Sleeping
Sleeping
Download tools/WebhookPostTool.py from Isaac454/First_agent_template3: direct link, hf CLI and curl.
- Browser
- Download file 556 Bytes
-
https://huggingface.co/spaces/Isaac454/First_agent_template3/resolve/main/tools/WebhookPostTool.py
- Command line
-
hf download hf://spaces/Isaac454/First_agent_template3/tools/WebhookPostTool.py
-
curl -L -o WebhookPostTool.py https://huggingface.co/spaces/Isaac454/First_agent_template3/resolve/main/tools/WebhookPostTool.py
556 Bytes
| from smolagents import Tool | |
| import requests # Required to send HTTP POST requests | |
| class WebhookPostTool(Tool): | |
| name = "webhook_post" | |
| description = "Send a JSON payload to a webhook URL and return the response as text." | |
| output_type = str # Must be one of SmolAgents authorized types | |
| def forward(self, webhook_url: str, payload: dict) -> str: | |
| try: | |
| response = requests.post(webhook_url, json=payload) | |
| return response.text | |
| except Exception as e: | |
| return f"Error sending request: {str(e)}" | |