Repository navigation
feat: add WebRouter web searcher - #200
Open
yogev-nimble wants to merge 1 commit into
Open
yogev-nimble wants to merge 1 commit into
yogev-nimble wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GoogleSearchcalls the Custom Search JSON API, which Google has closed to new customers and discontinues on January 1, 2027 (Google's overview page). This addsWebRouterSearch, a web searcher next toGoogleSearchandBingSearchthat 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: samesearch(query, num_results)shape asGoogleSearch. It returns items with thetitle,linkandsnippetkeys that Custom Search items have, so code that reads those keys keeps working.graphgen/models/__init__.py: exportsWebRouterSearchin 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.Notes
pip install "webrouter>=0.17"), imported only whensearch()runs, sorequirements.txtis unchanged. Without it,search()raises anImportErrorthat says what to install.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.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.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.