WeKnora icon indicating copy to clipboard operation
WeKnora copied to clipboard

[Feature]: Add Serply as a web search provider

Open googio opened this issue 2 months ago • 1 comments

Affected Component

Backend Service & API

Problem Description

WeKnora ships 13 web search providers, but the only way to get Google results is Google Custom Search, which needs both an API key and a Programmable Search Engine ID and returns results scoped to that engine. Tenants who want plain Google SERP results have no option, and the only provider that honours the agent tool's per-call country / freshness filters today is Brave. Every other provider returns an error when those filters are set.

Proposed Solution

Add serply as a web search provider, following the Brave adapter (internal/infrastructure/web_search/brave.go) and the Bocha wiring (#3036):

  • Endpoint: GET https://api.serply.io/v1/search with an X-Api-Key header; official URL hardcoded (SSRF-safe), redirects refused so the key never leaves the official host, 4MB response cap, proxy support through NewSearchHTTPClient.
  • Response: results[] with title / link / description mapped to WebSearchResult. num is clamped to 10 because the API serves one Google results page per call; the caller's limit is applied client-side.
  • Filters: implements FilteredWebSearchProvider. country maps to Google's gl (omitted for ALL), freshness pd / pw / pm / py maps to tbs=qdr:d|w|m|y. Serply has no date-range filter, so the YYYY-MM-DDtoYYYY-MM-DD form returns a clear error instead of being dropped silently, consistent with the "never ignore requested filters" rule.
  • Wiring: type constant and metadata (RequiresAPIKey, SupportsProxy), registry factory, service validation, frontend provider union, swagger enum entries, docs table row. No extra_config fields are needed.
  • Tests mirror brave_test.go: request mapping, default and clamped num, ALL handling, date-range rejection, error paths that do not leak the upstream body.

Alternatives

Keep using Google Custom Search (engine ID required, scoped results), or self-host SearXNG with the Google engine enabled (unkeyed, but scrapes and needs its own host).

Impact

Additive. Nothing changes for tenants who do not create a Serply configuration.

Use Case

An agent that needs Google-quality results with region and recency control, for example web_search with country: "GB" and freshness: "pd" for today's UK coverage of a topic.

Additional Information

Disclosure: I work with Serply. I have the implementation with tests ready and verified against the live API (region and qdr freshness confirmed, date ranges confirmed unsupported). I will open the PR right after this issue, the same way #3035 led to #3036.

googio avatar Sep 16 '26 17:09 googio

PR opened: #3330

googio avatar Sep 16 '26 17:09 googio