File size: 637 Bytes
6ed4304 37bcd95 6ed4304 37bcd95 6ed4304 a6101d2 6ed4304 a6101d2 6ed4304 37bcd95 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from smolagents import Tool
import requests
class WebSearchTool(Tool):
name = "web_search"
description = "Performs a web search for a given query and returns top results."
inputs = {
"input_text": {
"type": "string",
"description": "The query to search for."
}
}
output_type = "string"
def forward(self, input_text: str) -> str:
response = requests.post(
"https://ankitaofficialdutta02--modal-web-search-fastapi-app.modal.run/search",
json={"query": input_text}
)
return response.json().get("result", "No results found.")
|