整合

Flowise

把 Thunderbit 包成 Flowise 的 Custom Tool,給 chain 與 agent 用

Flowise 是架在 LangChain 上的拖拉式建構器。用 Custom Tool 節點把 /distill 公開出來,畫布上任何 chain 或 agent 都能用。

建立 Custom Tool

Tools → Custom Tool → Add new

  • Tool name: read_url
  • Tool description: Fetch a URL and return clean Markdown for the agent to read.
  • Input schema(JSON):
{
  "type": "object",
  "required": ["url"],
  "properties": {
    "url":        { "type": "string" },
    "renderMode": { "type": "string", "enum": ["basic", "advanced"], "default": "basic" }
  }
}
  • JavaScript function:
const res = await fetch('https://openapi.thunderbit.com/openapi/v1/distill', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${$vars.THUNDERBIT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ url: $url, renderMode: $renderMode || 'basic' }),
});
const json = await res.json();
return json.data.markdown;

把 API Key 存在 Variables 下叫 THUNDERBIT_API_KEY,別寫死在程式碼裡。

接進 chain

read_url 工具拖到 AgentTool Agent 節點裡,放在你的 LLM(OpenAI、Anthropic、Ollama)旁邊。Agent 會自動認到。

小技巧

  • 做 RAG 入庫時,搭 Document Loader 家族 —— 在自訂節點裡呼叫 read_url,把 Markdown 餵進 Recursive Character Text Splitter,再進向量庫
  • 長頁面會把 agent 的 context 撐爆 —— 在 Custom Tool 裡先截到約 8k 字元再回傳

相關文件