feat(community): add Serper web search provider (#2630)

* feat(community): add Serper web search provider

Add a new community search provider backed by the Serper Google Search
API (https://serper.dev). Serper returns real-time Google results via a
simple JSON API and requires only an API key — no extra Python package.

Changes:
- backend/packages/harness/deerflow/community/serper/__init__.py
- backend/packages/harness/deerflow/community/serper/tools.py
  Implements web_search_tool using httpx (already a project dependency).
  API key is read from config.yaml `api_key` field or SERPER_API_KEY env var.
  Follows the same interface / output shape as the existing ddg_search provider.
  Exposes max_results parameter (default 5) with config override logic.
- backend/tests/test_serper_tools.py
  Unit tests covering API key resolution, config overrides, HTTP errors,
  empty results, and parameter passing.
- config.example.yaml: add commented-out Serper example alongside other providers
- .env.example: add SERPER_API_KEY placeholder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix the lint error

* Fix the lint error

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
wanxsb
2026-05-02 16:22:35 +08:00
committed by GitHub
parent e543bbf5d6
commit 44ab21fc44
5 changed files with 419 additions and 0 deletions
+10
View File
@@ -373,6 +373,16 @@ tools:
use: deerflow.community.ddg_search.tools:web_search_tool
max_results: 5
# Web search tool (uses Serper - Google Search API, requires SERPER_API_KEY)
# Serper provides real-time Google Search results. Sign up at https://serper.dev
# Note: set SERPER_API_KEY in your environment before starting the app, or
# uncomment and fill in api_key below (the $VAR syntax is resolved at startup).
# - name: web_search
# group: web
# use: deerflow.community.serper.tools:web_search_tool
# max_results: 5
# # api_key: $SERPER_API_KEY # Optional if SERPER_API_KEY env var is set
# Web search tool (requires Tavily API key)
# - name: web_search
# group: web