Skip to content

feat: add WebRouter web searcher - #200

Open
yogev-nimble wants to merge 1 commit into
InternScience:mainfrom
yogev-nimble:feat/webrouter-web-searcher
Open

yogev-nimble wants to merge 1 commit into
InternScience:mainfrom
yogev-nimble:feat/webrouter-web-searcher

Conversation

@yogev-nimble

@yogev-nimble yogev-nimble commented Dec 5, 2026 •

Copy link
Copy Markdown

What

GoogleSearch calls the Custom Search JSON API, which Google has closed to new customers and discontinues on January 1, 2027 (Google's overview page). This adds WebRouterSearch, a web searcher next to GoogleSearch and BingSearch that works with no API key, so GraphGen keeps a web search option that needs no account. Related: #196.

  • graphgen/models/searcher/web/webrouter_search.py: same search(query, num_results) shape as GoogleSearch. It returns items with the title, link and snippet keys that Custom Search items have, so code that reads those keys keeps working.
  • graphgen/models/__init__.py: exports WebRouterSearch in the lazy import map.
  • tests/unit_tests/models/searcher/test_webrouter_search.py: 4 tests with a fake router, so they run without the package installed.
from graphgen.models import WebRouterSearch

results = WebRouterSearch().search("knowledge graph synthetic data", num_results=5)

Notes

  • WebRouter is an optional install (pip install "webrouter>=0.17"), imported only when search() runs, so requirements.txt is unchanged. Without it, search() raises an ImportError that says what to install.
  • By default it uses WebRouter's keyless backends and falls back between them. It never reads keys from environment variables (use_environment=False), so nothing is billed by surprise. To use a keyed backend, pass its name and key: WebRouterSearch(provider="brave", api_key=...). Backends and options are in the WebRouter documentation.
  • Engine errors raise HTTPException, as in the other two web searchers.

Testing

  • pytest tests/unit_tests: 55 passed.
  • pylint --rcfile=.pylintrc baselines/ graphgen/ webui/ (the CI command): 10.00/10.
  • Live call through WebRouterSearch().search(...) with no keys, an empty HOME and fake provider keys set in the environment: 3 results returned, and the environment keys were not used.

Disclosure: I'm Yogev, one of the maintainers of WebRouter. Happy to adjust names or placement to fit the project.

WebRouterSearch searches the web with no API key, so web search keeps
working without a Google Custom Search JSON API key (the API closes on
January 1, 2027, see InternScience#196). It has the same search(query, num_results)
shape as GoogleSearch and returns items with title, link and snippet.

Keys in environment variables are never read; a key can be passed with
a named backend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant