388c193ae7
對應 .agents/specs/llm-interface/ Milestone 3.1 + 3.3。
registry/examples/ — 10 個可直接 push 的 workflow 範本:
starter: webhook-to-http
common: cron-watcher, llm-classify, rag-search-answer, daily-digest
external: email-summary (gmail+claude+telegram), pdf-to-blocks,
github-issue-bot
advanced: parallel-fanout (trigger_workflow fan-out),
error-retry (try_catch+wait pattern)
每個含:workflow.yaml(可直接 push)+ description.md(解決什麼問題 /
改成你自己的 / 學到什麼)+ tags.json(搜尋用)
registry/skills/ — 5 個 AI playbook(markdown):
build_watcher_workflow — cron + filter + trigger 模式
debug_paused_workflow — claude_api callback paused 怎麼追
migrate_http_to_trigger_workflow — 從 self-fetch 換 trigger_workflow
rag_with_arcrun — KBDB + claude_api 組裝 RAG
add_new_wasm_component — TinyGo 寫 + 部署全流程
兩者差異:
examples = 可直接拿來改的 YAML
skills = 面對 X 問題該怎麼想 + 該用哪個 example
兩者後續:CI 自動同步進 KBDB(type=workflow-example / type=agent-skill),
MCP arcrun_search_examples / arcrun_list_skills 走 KBDB semantic search。
(CI sync 是 M3.4 工作)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
37 lines
1.6 KiB
Markdown
37 lines
1.6 KiB
Markdown
# rag-search-answer
|
||
|
||
## 解決什麼問題
|
||
最經典 RAG:用戶問問題 → KBDB semantic search 找相關 blocks → 餵 claude 回答。
|
||
比直接問 claude 強:claude 有了實際 context,不會編、可引用、回答跟你的資料一致。
|
||
|
||
## 怎麼觸發
|
||
```bash
|
||
curl -X POST https://cypher.arcrun.dev/webhooks/named/rag_search_answer/trigger \
|
||
-H "X-Arcrun-API-Key: ak_xxx" \
|
||
-d '{
|
||
"api_key":"ak_xxx",
|
||
"question":"如何避免 CF self-fetch 死鎖?",
|
||
"user_id":"inkstone_mira_tools"
|
||
}'
|
||
```
|
||
|
||
## 改成你自己的
|
||
- `search_kbdb.topK` 改 N(取多少 context,3-10 常見)
|
||
- `search_kbdb.user_id` 改為 query 該用戶下的 blocks,或拿掉撈全庫
|
||
- prompt 改為你的 domain(客服 / 法律 / 醫療 / 技術文件)
|
||
- 進階:加 `_recipe_output_format: json` 讓 claude 回結構化 {answer, citations[]}
|
||
|
||
## 為什麼這 pattern 重要
|
||
RAG 是 LLM 真正派上用場的場景。沒 RAG,LLM 在你私有資料上的回答是猜的。
|
||
|
||
## 變體
|
||
- **多輪 RAG**:先 claude 改寫 question → KBDB search → claude 答(query rewriting)
|
||
- **多源**:KBDB + web search + DB query → merge → claude
|
||
- **filter**:claude 先判斷 "需要 RAG 嗎?" → 不需要直接回(省 search latency)
|
||
- **followup**:把 claude 答案 + 用戶 question 一起存 KBDB,下次同問題直接 cache hit
|
||
|
||
## 學到什麼
|
||
- `kbdb_search` 走 semantic(embedding),不是字面比對 — query 不用打對關鍵字
|
||
- `{{search_kbdb.results}}` 自動展開為 markdown 列表(component contract)
|
||
- claude prompt 內注入 context 是 RAG 的核心,不需要 vector DB 之外的額外組件
|