Evogoatml's picture
fix: backend now regular folder, not submodule
65464fc
raw
history blame contribute delete
636 Bytes
# app/tools/http.py
import httpx, asyncio
from .base import Tool, ToolSpec
class HttpGet(Tool):
spec = ToolSpec(
name="http_get",
description="Fetch JSON/HTML from a URL.",
schema={
"type":"object","properties":{"url":{"type":"string","format":"uri"}}, "required":["url"]
}
)
async def run(self, url:str) -> dict:
async with httpx.AsyncClient(timeout=10) as s:
r = await s.get(url)
r.raise_for_status()
ctype = r.headers.get("content-type","")
return {"status": r.status_code, "content_type": ctype, "text": r.text[:200000]}