Skip to content

feat(tool): add serply search tool - #974

Open
googio wants to merge 1 commit into
cloudwego:mainfrom
googio:feat/serply-search
Open

feat(tool): add serply search tool#974
googio wants to merge 1 commit into
cloudwego:mainfrom
googio:feat/serply-search

Conversation

@googio

@googio googio commented Aug 27, 2026

Copy link
Copy Markdown

What type of PR is this?

feat

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

feat(tool): 新增 Serply 搜索工具

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
Adds components/tool/serply, a search tool backed by the Serply API (https://serply.io/docs). It follows the wikipedia and bingsearch tools: NewTool(ctx, &serply.Config{...}) returns a tool.InvokableTool built with utils.InferTool.

What it adds over the existing search tools is vertical coverage behind one key: Config.SearchType selects Google web (default), Google News or Google Scholar. Results are normalized to title, link and description, with source and publish time for news and authors and citation count for scholar, so an agent can be given a news or literature search tool without extra parsing.

Config: APIKey (required, sent as X-Api-Key), BaseURL, SearchType, Num (default 10, capped at 100, overridable per request), Headers (for example X-Proxy-Location to localize results), Timeout (30s) and HttpClient. Error messages never include the query. The tool is opt-in and touches no other module.

Files: serply.go, serply_test.go, go.mod, go.sum, README.md, README_zh.md, examples/main.go. Tests use an httptest server (no network) and cover config validation and defaults, the JSON schema descriptions, all three search types, per-request num override, non-200 responses, malformed bodies and cancelled contexts. go test -race -gcflags="all=-l -N" ./... passes with 94.6% coverage of the package; gofmt and go vet are clean. I also ran examples/main.go against the live API.

Disclosure: I work with Serply.

zh(optional):
新增 components/tool/serply,基于 Serply API 的搜索工具,实现方式与 wikipedia、bingsearch 工具一致。通过 Config.SearchType 可在 Google 网页、Google News 和 Google Scholar 搜索之间切换,结果统一为标题、链接、摘要(新闻附带来源和发布时间,学术附带作者和引用数)。测试使用 httptest,不访问网络。

(Optional) Which issue(s) this PR fixes:

Fixes #973

(optional) The PR that updates user documentation:

Happy to open a follow-up PR adding Serply to the tool index in cloudwego.github.io once this one is accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] add serply search tool

1 participant