mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
7 个按厂商命名的搜索工具收敛为 2 个统一工具,schema 与提示词不再暴露 provider 概念:web_search 由当前主模型按内置规则在 Tavily/Exa/Keenable 间路由(会话内 LRU 缓存,失败按可用性降级),web_fetch 固定走 Exa 并 静默降级。三家均改为纯 fetch 直连——Exa 直接对 mcp.exa.ai 发 JSON-RPC 并缓存会话,彻底移除 pi-mcp-adapter、@tavily/pi-extension 与 @keenable/pi-search 依赖。 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1.7 KiB
1.7 KiB
pi-web-search
Unified web search and fetch for Pi. The main model only ever sees two tools —
web_search and web_fetch — provider selection happens inside the extension.
web_search(query, max_results?, site?, published_after?, published_before?, depth?)routes each query to Tavily, Exa, or Keenable using the session's current main model (ctx.model+ctx.modelRegistry.complete), guided by per-provider rules. Results includedetails.provider/details.routedByfor debugging.web_fetch(urls, max_characters?)always reads pages via Exa (web_fetch_exa), degrading silently to Keenable then Tavily.
Providers (clients/)
Plain fetch calls — no MCP adapter, no upstream extension wrappers:
clients/tavily.ts—POST api.tavily.com/search|extract, Bearer key. RequiresTAVILY_API_KEY.clients/keenable.ts—api.keenable.ai, keyless/publicendpoints by default,KEENABLE_API_KEYraises rate limits. Adapted from@keenable/pi-search.clients/exa.ts— JSON-RPC overmcp.exa.ai/mcp(Streamable HTTP):initializeonce, cachemcp-session-id,tools/callper request, re-init on session expiry.EXA_API_KEYoptional (x-api-keyheader).
Keys are loaded from ~/.config/my-pi/search.env by extensions/search-config.ts
(written by search_config.sh); explicit environment variables win.
Routing
router.ts asks the current model to answer with exactly one provider name,
given a prompt containing the per-provider strengths and the query's requested
filters. Decisions are cached per session (LRU, 32 entries). Failure paths are
deterministic: an unroutable answer or a dead provider falls back across the
remaining available providers — never a heuristic choice over the model.