feat: add Brave Search & Baidu Search integration with sub-source support#42
Open
YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
Open
feat: add Brave Search & Baidu Search integration with sub-source support#42YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
Conversation
- Add 'brave' and 'baidu' to WebSearchProviderId union type - Register providers in WEB_SEARCH_PROVIDERS with configs - Create brave.ts: HTML scraping provider (no API key required) - Create baidu.ts: Qianfan REST API provider (Bearer token auth) - Update API route for multi-provider dispatch via 'provider' param - Generalize resolveWebSearchApiKey for provider-agnostic key resolution - Add BRAVE_API_KEY and BAIDU_API_KEY to .env.example - Update settings store with default configs for new providers - Update i18n strings (zh-CN + en-US) to be provider-agnostic - Update web-search-settings UI with conditional API key display - Pass provider param in generation-preview page fetch call
- Fix snippet regex to match 'class=snippet svelte-...' (not exact 'class=snippet')
- Update title extraction to use 'search-snippet-title' class
- Extract descriptions from 'generic-snippet' div (current) with fallback to 'snippet-description' p (legacy)
- Handle relative date prefixes ('2 days ago -')
- Add provider icons (Brave, Baidu, Tavily)
- Update Baidu sub-source toggles to use Switch components
- Fix webSearchAvailable logic to enable search when any provider is available
- Make Brave API key optional in settings UI
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.
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)