tools / search.py
Anonymous web search via DuckDuckGo + Tor, with reformulated fallbacks and multi-source synthesis.
Tools
| Tool | Purpose |
|---|---|
web_search | DDG search via ddgs with Tor SOCKS proxy. 3 retries on transient errors. request_new_tor_identity() is called on 401/403/503 to rotate Tor circuits. |
deep_research | Searches multiple reformulations and synthesises results via the LLM. Falls back to web_search when synthesis fails. |
fact_check | Verifies a claim by calling deep_research as a sub-process. |
Reformulation strategy
- Drop years / version numbers / numbers from the query (broaden).
- Convert to a question form (
"how to X"). - Append
tutorial/guide/example.
Output cleaning
_clean_for_cpp preserves valid JSON but strips control characters and structural braces from non-JSON text. This prevents the C++ JSON parser inside llama.cpp from crashing on stray {…} in scraped page bodies.