Integrationen

LlamaIndex

Binde Thunderbit als Reader oder Tool in eine LlamaIndex-Pipeline ein

LlamaIndex nennt sie „Reader" statt Loader, das Muster ist aber identisch zu LangChain — Thunderbit erzeugt sauberes Markdown, LlamaIndex chunkt und indexiert es.

Installation

pip install llama-index-core httpx

Als Reader

from llama_index.core import Document
import httpx

API = "https://openapi.thunderbit.com/openapi/v1"
H = {"Authorization": "Bearer YOUR_API_KEY"}

class ThunderbitReader:
    def load_data(self, urls: list[str]) -> list[Document]:
        job = httpx.post(f"{API}/batch/distill",
                         headers=H,
                         json={"urls": urls,
                               "include": ["metadata"]}).json()
        # poll until COMPLETED — see Batch Job Lifecycle guide
        return [
            Document(text=r["markdown"],
                     metadata={"source": r["url"], **r.get("metadata", {})})
            for r in job["data"]["results"] if r["status"] == "SUCCEEDED"
        ]

docs = ThunderbitReader().load_data(["https://docs.example.com"])

Reiche das Ergebnis wie gewohnt an VectorStoreIndex.from_documents(docs) weiter.

Als Agent-Tool (FunctionTool)

from llama_index.core.tools import FunctionTool

def read_url(url: str) -> str:
    """Fetch a URL and return clean Markdown."""
    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"]

read_tool = FunctionTool.from_defaults(fn=read_url)

Verwandt

Diese Integration wird mit einem llama-index-readers-thunderbit-Paket erweitert — schau bald wieder vorbei.