https://www.hackster.io/shahizat/building-a-local-router-ai-agent-with-n8n-and-llama-cpp-5080d8
這個專案的核心,是透過 n8n 工作流 + llama.cpp 模型伺服器 + Tailscale Funnel,建立一個能夠「智慧分流」查詢的 Router AI-Agent。安裝過程其實分成三個部分:
在 RTX 5090 與 Jetson AGX Thor 分別編譯:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j $(nproc)
完成後,會得到 ./build/bin/llama-server
,之後就可以用它來跑不同大小的模型。
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
sudo tailscale funnel 5678
這樣就能得到一個安全的 HTTPS URL,外部(例如 Telegram bot)就能安全存取內部的 n8n。
建立 compose.yaml
:
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: always
ports:
- "5678:5678"
environment:
- N8N_HOST=<你的 LAN IP>
- N8N_PORT=5678
- N8N_PROTOCOL=http
- WEBHOOK_URL=https://your-machine-name.tailnet-hash.ts.net
volumes:
- n8n_data:/home/node/.n8n
- ./local-files:/files
volumes:
n8n_data:
啟動:
sudo docker compose up -d
這個專案的亮點是 Router Agent:
[Telegram Trigger]
│
▼
[Routing Agent (Gemma 4B)] → 輸出 JSON: { prompt, model }
│
▼
[Switch]
┌───────────┬────────────┐
▼ ▼ ▼
[Gemma 12B] [GPT-OSS-120B] [其他工具: Wikipedia, Calculator]
│
▼
[Telegram Response]
{
"prompt": "What’s the capital of France?",
"model": "gemma-3-12b-it-qat-GGUF"
}
或是遇到複雜問題:
{
"prompt": "Compare transformer architectures in LLMs and explain trade-offs for edge deployment.",
"model": "openai_gpt-oss-120b"
}
這樣的設計讓系統 自動決定「誰來回答」,不必所有問題都砸給龐大模型處理,節省硬體資源,也加快回應速度。
看完這個專案,我的感覺可以用一句話概括:
「不需要所有問題都用大炮打蚊子。」
Router Agent 的出現,就是讓系統自己學會「分流」。它其實就是一個 AI Traffic Police:站在十字路口,判斷你要走快車道(小模型)還是高速公路(大模型)。
對我個人來說,最有共鳴的地方是 「分工」:
這讓我想起日常工作:我們也應該把腦力用在最該用的地方,而不是每天重複機械式的任務。
結論:這篇專案讓我意識到,AI 的未來不在單一巨獸,而在於如何編排大小模型的合作。就像一個團隊不是靠一個超人,而是靠正確的調度與分工。