feat(tool): add serply search tool - #974
Open
googio wants to merge 1 commit into
Open
Conversation
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 type of PR is this?
feat
Check the PR title.
(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 atool.InvokableToolbuilt withutils.InferTool.What it adds over the existing search tools is vertical coverage behind one key:
Config.SearchTypeselects 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 asX-Api-Key),BaseURL,SearchType,Num(default 10, capped at 100, overridable per request),Headers(for exampleX-Proxy-Locationto localize results),Timeout(30s) andHttpClient. 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 anhttptestserver (no network) and cover config validation and defaults, the JSON schema descriptions, all three search types, per-requestnumoverride, non-200 responses, malformed bodies and cancelled contexts.go test -race -gcflags="all=-l -N" ./...passes with 94.6% coverage of the package;gofmtandgo vetare clean. I also ranexamples/main.goagainst 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.