Recipes

Agent Read-URL 도구

LLM 에이전트 루프에 즉시 사용 가능한 "이 URL 읽기" 도구

에이전트에 어떤 URL이든 깔끔한 Markdown으로 변환해주는 단일 도구를 제공하세요. 에이전트는 페이지를 조사할 필요가 있을 때마다 이 도구를 호출합니다 — Thunderbit가 JS, anti-bot, 콘텐츠 정제를 처리하므로 에이전트의 컨텍스트는 신호 밀도를 유지합니다.

도구 정의 (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 예시

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"],
        },
    },
}]

모델이 read_url을 호출하면, 위 함수로 디스패치하고 결과를 도구 메시지로 다시 전달합니다.

  • 에이전트의 경우 renderModebasic으로 유지하세요 — 비용 / 커버리지 측면에서 좋은 기본값입니다
  • 모델에 전달하기 전에 반환된 Markdown 길이를 제한하세요 (예: 8k tokens)
  • 대량 조사의 경우 /batch/distill를 권장합니다 — RAG 지식 베이스 참고

관련 문서

이 레시피는 LangChain / LlamaIndex / CrewAI 변형으로 확장 중입니다 — 곧 업데이트됩니다.