feat(web): add Gemini Google Search Grounding provider#26021
Conversation
|
Competing implementation of #13268 (Gemini web search backend). This PR is more comprehensive (plugin structure, tests, docs, setup wizard integration) but implements the same feature. One should be chosen and the other closed. |
this one also fetches the grounding urls and normalises them. it also implements extract. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new built-in web backend plugin (gemini) that uses the google-genai SDK to perform web search + extraction via Gemini Google Search Grounding, and wires it into backend auto-detection, configuration defaults, CLI setup messaging, tests, and user documentation.
Changes:
- Adds
GeminiWebSearchProviderunderplugins/web/gemini/and registers it as a bundled backend. - Extends backend selection/availability logic to support
geminiwhenGEMINI_API_KEYorGOOGLE_API_KEYis set, and adds aweb.gemini_modelconfig default. - Adds/updates tests and docs to include the new provider and configuration.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
plugins/web/gemini/provider.py |
Implements Gemini search/extract provider using google-genai with Google Search Grounding. |
plugins/web/gemini/__init__.py |
Registers the Gemini provider with the plugin context. |
plugins/web/gemini/plugin.yaml |
Declares the bundled backend plugin and provider name. |
tools/web_tools.py |
Adds gemini to backend detection, availability checks, and status output. |
tools/lazy_deps.py |
Adds a lazy-install mapping entry for google-genai. |
hermes_cli/config.py |
Adds default web.gemini_model config value. |
hermes_cli/setup.py |
Updates setup summary text to mention Gemini key(s). |
hermes_cli/nous_subscription.py |
Treats Gemini keys as direct web credentials for feature availability detection. |
tests/plugins/web/test_gemini_provider.py |
Adds unit tests for Gemini provider availability and unconfigured error handling. |
tests/plugins/web/test_web_search_provider_plugins.py |
Extends plugin registry/capability tests to include gemini. |
website/docs/user-guide/features/web-search.md |
Documents Gemini backend setup, env vars, and config examples. |
pyproject.toml |
Adds google-genai to the google extra dependencies. |
Comments suppressed due to low confidence (1)
tests/plugins/web/test_web_search_provider_plugins.py:89
- This test/docstring still says “seven” plugins, but the registry assertion now includes 8 providers (adds
gemini). Please update the test name/docstring to match the new expected count so failures and future refactors aren’t misleading.
class TestBundledPluginsRegister:
"""All seven bundled web plugins discover and register correctly."""
def test_all_seven_plugins_present_in_registry(self) -> None:
_ensure_plugins_loaded()
from agent.web_search_registry import list_providers
names = sorted(p.name for p in list_providers())
assert names == [
"brave-free",
"ddgs",
"exa",
"firecrawl",
"gemini",
"parallel",
"searxng",
"tavily",
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ed65963 to
dffd3a8
Compare
austinpickett
left a comment
There was a problem hiding this comment.
Please resolve comments from Copilot
will do! |
|
I have addressed the issues copilot mentioned. It seems to have encountered an error tho? I don't think i can re-trigger it. |
c56dc73 to
da87fb6
Compare
da87fb6 to
9057cc9
Compare
|
is there anything more needed from me on this? |
9057cc9 to
a0a504b
Compare
a0a504b to
08d4565
Compare
Resolve issues identified in NousResearch#26021 (review) * Removed Duplicate Tests: tests/plugins/web/test_web_search_provider_plugins.py - Removed the duplicated test_gemini_available_with_google_key definitions that were causing earlier tests to be overridden and losing coverage. * Updated Environment Setup Clearing: tests/plugins/web/test_web_search_provider_plugins.py - Added GEMINI_API_KEY and GOOGLE_API_KEY to the _clear_web_env method so every test starts from a clean web-provider environment without flakiness. * Improved Provider Setup Schema: plugins/web/gemini/provider.py - Updated get_setup_schema() to accept and explicitly list both GEMINI_API_KEY and GOOGLE_API_KEY options for authentication so users are better guided via the CLI picker. * Plugin Configuration Tag Update: plugins/web/gemini/plugin.yaml - Updated the description to mention that both GEMINI_API_KEY and GOOGLE_API_KEY are acceptable configurations. * Fixed Fallback URL Encoding: plugins/web/gemini/provider.py - Switched to using urllib.parse.quote_plus(query) for the Google Search fallback URL instead of query.replace(" ", "+") to properly handle non-ASCII characters and valid symbol queries. * Added Success Path Tests: tests/plugins/web/test_gemini_provider.py - Added test_search_success and test_extract_success tests that mock the Google GenAI client and its responses. This verifies the actual implementation logic for valid requests, which wasn't previously covered. * Included GOOGLE_API_KEY in Setup Summary: hermes_cli/setup.py - Mentioned GOOGLE_API_KEY next to GEMINI_API_KEY in the tool status summary help text to assure users who use a Google key that their setup is correctly detected. * Re-mapped Lazy Dependency Key: tools/lazy_deps.py & plugins/web/gemini/provider.py - Changed the lazy loading identifier from google.genai to search.gemini to align with the convention used by other search providers like search.exa, search.firecrawl, etc. * Parameterised Logging: plugins/web/gemini/provider.py - Replaced the eager f-string logic in logger.debug statements with standard parameterised logging (logger.debug("... %s", var)) for better performance and consistency. * Refined Documentation (.env): website/docs/user-guide/features/web-search.md - Explicitly commented a # GOOGLE_API_KEY=your-google-key-here alternative in the .env code block, and added GOOGLE_API_KEY to the Gemini entry in the provider table to remove any ambiguity.
|
I also would like to see this feature. |
its working well in my branch, you can feel free to merge this in to your tree if you wish to try. i'm not sure what more is needed from me to get it merged. |
- Implements a new `GeminiWebSearchProvider` plugin under `plugins/web/gemini/` to support web search and extraction using the `google-genai` SDK and Google Search Grounding. - Updates `tools/web_tools.py` backend detection logic and allows falling back to `gemini` if `GEMINI_API_KEY` or `GOOGLE_API_KEY` are provided. - Configures `web.gemini_model` mapping in `hermes_cli/config.py` with a default of `gemini-3.1-flash-lite`. - Integrates the Gemini backend into the interactive CLI setup wizard (`hermes_cli/setup.py`). - Adds comprehensive unit testing under `tests/plugins/web/test_gemini_provider.py` to cover both search and content extraction paths. - Updates documentation (`website/docs/user-guide/features/web-search.md`) to reflect the new capabilities, API key prerequisites, and configuration examples.
Resolve issues identified in NousResearch#26021 (review) * Removed Duplicate Tests: tests/plugins/web/test_web_search_provider_plugins.py - Removed the duplicated test_gemini_available_with_google_key definitions that were causing earlier tests to be overridden and losing coverage. * Updated Environment Setup Clearing: tests/plugins/web/test_web_search_provider_plugins.py - Added GEMINI_API_KEY and GOOGLE_API_KEY to the _clear_web_env method so every test starts from a clean web-provider environment without flakiness. * Improved Provider Setup Schema: plugins/web/gemini/provider.py - Updated get_setup_schema() to accept and explicitly list both GEMINI_API_KEY and GOOGLE_API_KEY options for authentication so users are better guided via the CLI picker. * Plugin Configuration Tag Update: plugins/web/gemini/plugin.yaml - Updated the description to mention that both GEMINI_API_KEY and GOOGLE_API_KEY are acceptable configurations. * Fixed Fallback URL Encoding: plugins/web/gemini/provider.py - Switched to using urllib.parse.quote_plus(query) for the Google Search fallback URL instead of query.replace(" ", "+") to properly handle non-ASCII characters and valid symbol queries. * Added Success Path Tests: tests/plugins/web/test_gemini_provider.py - Added test_search_success and test_extract_success tests that mock the Google GenAI client and its responses. This verifies the actual implementation logic for valid requests, which wasn't previously covered. * Included GOOGLE_API_KEY in Setup Summary: hermes_cli/setup.py - Mentioned GOOGLE_API_KEY next to GEMINI_API_KEY in the tool status summary help text to assure users who use a Google key that their setup is correctly detected. * Re-mapped Lazy Dependency Key: tools/lazy_deps.py & plugins/web/gemini/provider.py - Changed the lazy loading identifier from google.genai to search.gemini to align with the convention used by other search providers like search.exa, search.firecrawl, etc. * Parameterised Logging: plugins/web/gemini/provider.py - Replaced the eager f-string logic in logger.debug statements with standard parameterised logging (logger.debug("... %s", var)) for better performance and consistency. * Refined Documentation (.env): website/docs/user-guide/features/web-search.md - Explicitly commented a # GOOGLE_API_KEY=your-google-key-here alternative in the .env code block, and added GOOGLE_API_KEY to the Gemini entry in the provider table to remove any ambiguity.
Change from 'test seven plugins' to 'test plugins' in test doc/name
08d4565 to
01a18ae
Compare
What does this PR do?
<- Implements a new
GeminiWebSearchProviderplugin underplugins/web/gemini/to support web search and extraction using thegoogle-genaiSDK and Google Search Grounding.tools/web_tools.pybackend detection logic and allows falling back togeminiifGEMINI_API_KEYorGOOGLE_API_KEYare provided.web.gemini_modelmapping inhermes_cli/config.pywith a default ofgemini-3.1-flash-lite.hermes_cli/setup.py).tests/plugins/web/test_gemini_provider.pyto cover both search and content extraction paths.website/docs/user-guide/features/web-search.md) to reflect the new capabilities, API key prerequisites, and configuration examples.Related Issue
N/A
Fixes N/A
Type of Change
Changes Made
How to Test
in config.yaml:
web:
backend: gemini
gemini_model: gemini-3.1-flash-lite
search_backend: google_search
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A