Initial commit: OpenClaw Skill Collection
6 custom skills (assign-task, dispatch-webhook, daily-briefing, task-capture, qmd-brain, tts-voice) with technical documentation. Compatible with Claude Code, OpenClaw, Codex CLI, and OpenCode.
This commit is contained in:
120
openclaw-knowhow-skill/我發現下載量是算token的,這樣成本太高,Skill_Seeker的Skill.md
Executable file
120
openclaw-knowhow-skill/我發現下載量是算token的,這樣成本太高,Skill_Seeker的Skill.md
Executable file
@@ -0,0 +1,120 @@
|
||||
我發現下載量是算token的,這樣成本太高,Skill_Seeker的Skill,應該要增加一個webfetch的python,妳只是呼叫它,而不用去管它的下載內容。
|
||||
|
||||
● 你說得對!這是個重要的效能問題。
|
||||
|
||||
目前問題
|
||||
Claude 呼叫 WebFetch → 內容回傳 API (計算 tokens) → Claude 再 Write 檔案
|
||||
每個頁面的內容都經過 API 兩次,token 成本很高。
|
||||
|
||||
建議的改進
|
||||
|
||||
Skill Seeker 應該新增一個 Python 直接抓取工具:
|
||||
|
||||
# 新的 MCP tool: fetch_and_save
|
||||
def fetch_and_save(url: str, output_path: str) -> dict:
|
||||
"""直接抓取網頁並存檔,不經過 Claude API"""
|
||||
response = requests.get(url)
|
||||
content = extract_markdown(response.text)
|
||||
|
||||
with open(output_path, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
return {"status": "ok", "bytes": len(content)} # 只回傳狀態
|
||||
|
||||
效益
|
||||
┌─────────────────────────┬────────────────────────────────┐
|
||||
│ 方式 │ Token 消耗 │
|
||||
├─────────────────────────┼────────────────────────────────┤
|
||||
│ 目前 (WebFetch + Write) │ ~2000 tokens/頁 │
|
||||
├─────────────────────────┼────────────────────────────────┤
|
||||
│ 改進 (fetch_and_save) │ ~50 tokens/頁 (只有呼叫和回應) │
|
||||
└─────────────────────────┴────────────────────────────────┘
|
||||
節省 97%+ 的 token 成本
|
||||
|
||||
要我幫你在 Skill Seeker 專案中實作這個功能嗎?
|
||||
|
||||
❯ 是的,請幫我在Skill Seeker實作這個功能。
|
||||
|
||||
● Explore(Explore Skill Seeker structure)
|
||||
⎿ Done (37 tool uses · 58.5k tokens · 3m 25s)
|
||||
|
||||
● 了解專案結構了。現在讓我讀取現有工具的實作方式,然後新增 fetch_and_save 工具。
|
||||
|
||||
● Read 3 files (ctrl+o to expand)
|
||||
● 現在我了解架構了。讓我檢查現有的 HTML 轉 Markdown 處理邏輯,然後實作新工具。
|
||||
|
||||
● Searched for 2 patterns, read 1 file (ctrl+o to expand)
|
||||
● 了解了。現在我來實作 fetch_and_save 工具。這個工具會直接抓取並存檔,不經過 Claude API。
|
||||
|
||||
|
||||
❯ 請問這個新工具,適用在其他抓取網頁的專案嗎?我需要在使用skill seeker時跟妳或其他使用skill seeker mcp的LLM說什麼嗎?比如加參數?--save without api?特別重要的是,妳開發這麼好的工具,我要怎麼移到別台電腦在claude code使用呢?
|
||||
|
||||
● 好問題!讓我逐一回答:
|
||||
|
||||
1. 這個工具適用於其他專案嗎?
|
||||
是的! fetch_and_save 是通用的網頁抓取工具,適用於:
|
||||
- 抓取文檔網站
|
||||
- 批次下載 markdown 檔案
|
||||
- 任何需要省 token 的網頁抓取任務
|
||||
|
||||
2. 如何告訴 LLM 使用這個工具?
|
||||
|
||||
使用 Skill Seeker MCP 的 LLM 可以直接呼叫:
|
||||
mcp__skill-seeker__fetch_and_save(
|
||||
url="https://example.com/doc.md",
|
||||
output="local/path/doc.md"
|
||||
)
|
||||
|
||||
你可以這樣提示 LLM:
|
||||
"請用 fetch_and_save 工具抓取網頁並存檔,不要用 WebFetch(那會消耗太多 token)"
|
||||
|
||||
3. ⚠️ 移植問題 - 重要!
|
||||
|
||||
目前的修改是直接改在 site-packages(pip 安裝的位置),這有幾個問題:
|
||||
┌───────────────────────────┬────────────────────┐
|
||||
│ 問題 │ 影響 │
|
||||
├───────────────────────────┼────────────────────┤
|
||||
│ pip upgrade skill-seekers │ ❌ 修改會被覆蓋 │
|
||||
├───────────────────────────┼────────────────────┤
|
||||
│ 換電腦 │ ❌ 需要重新修改 │
|
||||
├───────────────────────────┼────────────────────┤
|
||||
│ 版本控制 │ ❌ 不在 git 追蹤中 │
|
||||
└───────────────────────────┴────────────────────┘
|
||||
解決方案
|
||||
|
||||
讓我把修改提取成一個 patch 檔案,這樣你可以:
|
||||
1. 在任何電腦上 pip install skill-seekers
|
||||
2. 執行 patch 腳本新增 fetch_and_save 工具
|
||||
|
||||
完成!以下是在其他電腦使用的步驟
|
||||
📁 建立的檔案
|
||||
D:\openclaw\skills\openclaw\patches\
|
||||
├── add_fetch_and_save.py ← Patch 腳本
|
||||
└── README.md ← 使用說明
|
||||
|
||||
🖥️ 在新電腦使用
|
||||
|
||||
# 1. 安裝 skill-seekers
|
||||
pip install skill-seekers
|
||||
|
||||
# 2. 複製 patches 資料夾到新電腦,執行:
|
||||
python add_fetch_and_save.py
|
||||
|
||||
# 3. 重啟 Claude Code
|
||||
|
||||
💡 如何告訴 LLM 使用這個工具
|
||||
|
||||
你可以這樣說:
|
||||
"請用 fetch_and_save 工具抓取網頁,這樣比 WebFetch 省 token"
|
||||
|
||||
或者在 Claude Code 的 CLAUDE.md 中加入:
|
||||
## 抓取網頁時
|
||||
優先使用 `mcp__skill-seeker__fetch_and_save` 而非 WebFetch,
|
||||
因為它直接用 Python 下載存檔,不經過 API,節省 97% token。
|
||||
|
||||
🔄 更新 skill-seekers 後
|
||||
|
||||
每次 pip upgrade skill-seekers 後,需要重新執行:
|
||||
python add_fetch_and_save.py
|
||||
|
||||
(腳本會自動檢查,已 patch 就不會重複修改)
|
||||
Reference in New Issue
Block a user