WeKnora/internal/infrastructure/web_search
Fei.Chen 15727591a7
feat(web-search): add Bocha AI Search provider (#3036)
* feat(web-search): add Bocha AI Search provider

Add a Bocha (bochaai.com) web search provider following the Metaso
adapter pattern: hardcoded official endpoint (SSRF-safe), Bearer auth,
4MB response cap, error-detail extraction, and RFC3339 date parsing
(datePublished preferred, dateLastCrawled fallback).

Tenant-facing config fields:
- freshness: noLimit/oneDay/oneWeek/oneMonth/oneYear (default noLimit)
- summary: request long text summaries, preferred as snippets (default on)

Wiring: registry factory in container, provider type enum + /types
metadata (dynamic form fields), frontend provider union type, and
swagger docs enum entries.

* fix(web-search): match Bocha's real wire format for codes and error messages

Live endpoint probing showed errors return {"message": .., "code": "401"}
(string code, message field) instead of the documented {msg, code:int}.
Parse the code tolerantly (string or number) and extract the detail from
message/msg so auth and rate-limit failures surface their reason.

* fix(web-search): allow Bocha in provider CRUD validation

In-service integration testing caught a fourth wiring point the adapter,
registry, /types metadata and frontend covered but CRUD did not: the
service-layer whitelist (isValidProviderType) and parameter validation
switches rejected provider type 'bocha', so providers could be tested
via POST /web-search-providers/test but never created or updated.

Add Bocha to both switches (delegating to ValidateBochaParameters like
Metaso/Zhipu) with service-level test coverage.

* fix(web-search): correct Bocha legacy timestamp timezone

---------

Co-authored-by: vicfei <vicfei@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-07 20:06:26 +08:00
..
baidu.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
bing.go feat: search engine adds proxy addresses and adds SSRF verification. 2026-04-17 16:38:02 +08:00
bocha.go feat(web-search): add Bocha AI Search provider (#3036) 2026-09-07 20:06:26 +08:00
bocha_test.go feat(web-search): add Bocha AI Search provider (#3036) 2026-09-07 20:06:26 +08:00
duckduckgo.go feat: search engine adds proxy addresses and adds SSRF verification. 2026-04-17 16:38:02 +08:00
exa.go feat: add Exa WebSearch (#2617) 2026-08-11 17:05:52 +08:00
exa_test.go feat: add Exa WebSearch (#2617) 2026-08-11 17:05:52 +08:00
google.go feat: search engine adds proxy addresses and adds SSRF verification. 2026-04-17 16:38:02 +08:00
keenable.go fix(web-search): polish Keenable provider integration after #1946 2026-07-07 17:14:39 +08:00
keenable_test.go fix(web-search): polish Keenable provider integration after #1946 2026-07-07 17:14:39 +08:00
metaso.go feat: add Metaso web search provider 2026-08-10 13:33:55 +08:00
metaso_test.go feat: add Metaso web search provider 2026-08-10 13:33:55 +08:00
ollama.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
proxy.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
proxy_test.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
registry.go feat(web-search): refactor web search provider 2026-03-31 20:22:34 +08:00
searxng.go fix(web-search): improve SearXNG test connection error messages 2026-06-24 14:28:49 +08:00
searxng_test.go fix(web-search): improve SearXNG test connection error messages 2026-06-24 14:28:49 +08:00
tavily.go feat: search engine adds proxy addresses and adds SSRF verification. 2026-04-17 16:38:02 +08:00
test_errors.go feat: add Exa WebSearch (#2617) 2026-08-11 17:05:52 +08:00
test_errors_test.go feat: add Exa WebSearch (#2617) 2026-08-11 17:05:52 +08:00
zhipu.go feat(web-search): add Zhipu AI web search provider support 2026-07-20 12:15:35 +08:00
zhipu_test.go feat(web-search): add Zhipu AI web search provider support 2026-07-20 12:15:35 +08:00