feat: add Brave Search & Baidu Search integration with sub-source support#42
Conversation
edff981 to
6cc35da
Compare
|
Thanks for the contribution, and sorry for the long delay on my side. This PR is now quite far behind If you’re still interested in maintaining this PR, please rebase it onto the latest |
|
Got it! I'll rebase this onto main and update the code to fit the current architecture in a couple of days when I have some bandwidth. |
4e08f30 to
463e5ec
Compare
463e5ec to
be0a610
Compare
|
Reviewed PR #42 and tested the new web search providers locally. Overall this looks good for Brave and for Baidu Web/Baike. Brave official API mode worked in a real generation flow with Gemini 3 Flash, and Baidu Web/Baike also return usable results with the configured key. A few issues I’d fix before merge:
One note on Scholar availability: the URL itself appears correct. Opening it without auth returns Baidu’s Tested:
|
be0a610 to
29f62e5
Compare
|
Thanks so much for the thorough review!! All points are confirmed — working on it 👍 |
29f62e5 to
5b61acf
Compare
…through - Brave Search now supports dual mode: official JSON API (with key) or HTML scraping fallback (without key) - Fix API key always being discarded for optional-key providers in both route.ts and resolveClassroomWebSearchConfig - Add BRAVE to WEB_SEARCH_ENV_MAP for server-side key resolution - Add api.search.brave.com to SSRF whitelist - Update i18n: clarify API key is optional for scrapable providers - Update settings UI placeholder for optional-key providers - Remove stale 'no API key' env hint for Brave
5b61acf to
5d88c72
Compare
|
All 4 items addressed in 1. Baidu Scholar response parsing
2. Scholar parameter name
3.
4. Tests should clear Brave env vars
Bonus: Scholar authorization UX
|


Summary
Adds Brave Search and Baidu Search as web search providers, with Baidu sub-source configuration (Web Search, Baike, Scholar).
Changes
New Search Providers
Provider Icons
public/icons/brave.png), Baidu (public/icons/baidu.png), and Tavily (public/icons/tavily.jpg)UI Improvements
Switchcomponents (consistent with rest of the UI)Technical Details
lib/web-search/brave.ts: Regex-based HTML parser for Brave's current Svelte-rendered page structurelib/web-search/baidu.ts: AcceptssubSourcesparameter, queries enabled sources in parallellib/store/settings.ts: AddedbaiduSubSourcesstate with per-source togglesapp/api/web-search/route.ts: Brave bypasses API key check; Baidu passes sub-source configcomponents/generation/generation-toolbar.tsx: FixedwebSearchAvailablelogicFiles Changed
lib/web-search/brave.tslib/web-search/baidu.tslib/web-search/types.tsBaiduSubSourcesinterfacelib/web-search/constants.tslib/store/settings.tsapp/api/web-search/route.tsapp/generation-preview/page.tsxcomponents/settings/web-search-settings.tsxcomponents/generation/generation-toolbar.tsxpublic/icons/*Testing
pnpm buildexit code 0)