feat(websearch): add Serply as a web search provider - #9838
Open
googio wants to merge 1 commit into
Open
Conversation
4 tasks
Contributor
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. When Serply is selected, user search queries and configured API keys are sent to a new external service, so a provider or endpoint mistake could expose data that cannot be recalled by reverting. Reverting stops future requests, but it does not undo requests already sent to Serply.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Motivation / 动机
This PR adds Serply as a new web search provider. Serply returns live Google search results (title, URL, snippet) behind a single API key, which none of the six existing providers offer: Tavily, Exa and Brave serve their own indexes, BoCha and Baidu AI Search are China-focused, and Firecrawl is a crawler first. Serply also exposes the Google News and Google Scholar verticals, so the same tool can answer "what is the latest news about X" and "find papers on Y" with results from those Google surfaces.
Disclosure: I work with Serply. The integration follows the existing provider pattern exactly (Exa in #8973, Brave) and stays fully opt-in behind
websearch_provider.Related issue: #9837
Modifications / 改动点
Backend (
astrbot/core/tools/web_search_tools.py)SerplyWebSearchTool(web_search_serply):GET https://api.serply.io/v1/search/(or/v1/news/,/v1/scholar/via the optionalsearch_typeparameter) with the key in anX-Api-Keyheader. Parameters:query,num_results(1-100, default 10),search_type(web|news|scholar, defaultweb),gl,hl._serply_search()mirrors_brave_search(): same_KeyRotatorround-robin overwebsearch_serply_key, same failover on_RETRYABLE_HTTP_STATUSES(Serply answers401for an invalid key), sameSearchResultnormalization and_search_result_payload()output._SERPLY_KEY_ROTATOR,_SERPLY_WEB_SEARCH_TOOL_CONFIG,web_search_serplyinWEB_SEARCH_TOOL_NAMES,websearch_serply_keyinnormalize_legacy_web_search_config()(string to list migration).Dispatch & config
astrbot/core/astr_main_agent.py:elif provider == "serply"in_apply_web_search_tools();web_search_serplyadded toWEB_SEARCH_CITATION_TOOL_NAMESso citations render like the other providers.astrbot/core/config/default.py:websearch_serply_key: []default,"serply"in thewebsearch_provideroptions, and asecretlist schema entry shown only when Serply is selected.i18n / docs
dashboard/src/i18n/locales/{en-US,zh-CN,ru-RU}/features/config-metadata.json:websearch_serply_keydescription and hint.docs/en/use/websearch.md,docs/zh/use/websearch.md: provider count 6 -> 7 and a short Serply section linking to https://serply.io and the API docs at https://serply.io/docs.Tests (
tests/unit/test_web_search_tools.py): 8 new tests covering the legacy key migration, tool argument mapping and clamping (num_results, unknownsearch_typefalls back toweb), the "no key configured" message, the raw GET request (URL, params, headers,trust_env=True, entries without a link dropped), the news vertical mapping, key failover on401, and no failover on500._SERPLY_KEY_ROTATORis reset in the autouse fixture.No new dependencies (
aiohttpis already used by every provider). Behavior is unchanged for anyone who does not selectserply.Screenshots or Test Results / 运行截图或测试结果
Unit tests
Live test against the Serply API (real key in
websearch_serply_key, callingSerplyWebSearchTool.call()directly; key redacted):The dashboard change is a schema-driven
listfield identical to the existing Exa key field (shown only whenwebsearch_providerisserply), so no custom UI code was added.Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
Summary by Sourcery
Add Serply as a configurable web search provider for live Google web, news, and scholarly results.
New Features:
Enhancements:
Documentation:
Tests: