Recipes
Agent Read-URL Tool
Drop-in "lees deze URL"-tool voor een LLM-agent-loop
Geef je agent een enkele tool die elke URL omzet in schone Markdown. De agent roept hem aan wanneer hij een pagina moet onderzoeken — Thunderbit handelt JS, anti-bot en content-cleaning af, zodat de context van de agent informatiedicht blijft.
Tool-definitie (Python)
import httpx
API = "https://openapi.thunderbit.com/openapi/v1"
H = {"Authorization": "Bearer YOUR_API_KEY"}
def read_url(url: str) -> str:
"""Fetch a URL and return clean Markdown.
Use for any web research task: docs, articles, search results, product pages.
Returns the page as Markdown with metadata stripped.
"""
resp = httpx.post(f"{API}/distill",
headers=H,
json={"url": url, "renderMode": "basic"},
timeout=60.0)
resp.raise_for_status()
return resp.json()["data"]["markdown"]OpenAI function-calling-voorbeeld
tools = [{
"type": "function",
"function": {
"name": "read_url",
"description": "Fetch a URL and return clean Markdown for the agent to read.",
"parameters": {
"type": "object",
"properties": {
"url": {"type": "string", "description": "The URL to fetch"}
},
"required": ["url"],
},
},
}]Wanneer het model read_url aanroept, dispatch je naar de bovenstaande functie en geef je het resultaat terug als een tool-bericht.
Tips
- Houd
renderModeopbasicvoor de agent — dat is een goede standaard voor kosten / dekking - Beperk de teruggegeven Markdown-lengte (bv. 8k tokens) voordat je hem aan het model voert
- Voor onderzoek in bulk heeft
/batch/distillde voorkeur — zie RAG Knowledge Base
Gerelateerd
Dit recept wordt uitgebreid met LangChain / LlamaIndex / CrewAI-varianten — kom binnenkort terug.