File size: 556 Bytes
a93662f
 
 
4971068
 
 
 
 
 
 
 
 
 
a93662f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)}"