Skip to content

feat: add Tavily as configurable search provider alongside Brave#1

Open
tavily-integrations wants to merge 1 commit into
arshawnarbabi:mainfrom
Tavily-FDE:feat/tavily-migration/localnotch-brave-to-tavily-additive
Open

feat: add Tavily as configurable search provider alongside Brave#1
tavily-integrations wants to merge 1 commit into
arshawnarbabi:mainfrom
Tavily-FDE:feat/tavily-migration/localnotch-brave-to-tavily-additive

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

Adds Tavily as a selectable web search provider alongside the existing Brave Search integration. Users can choose between Brave, Tavily, or Auto (fallback) mode via a new segmented picker in Settings > Web Search.

Changes

New file

  • Sources/LocalNotch/TavilySearchService.swift — Tavily search service using URLSession POST to https://api.tavily.com/search, matching BraveSearchService's search(_ query:) async -> String? interface and output format.

Modified files

  • Sources/LocalNotch/AppSettings.swift — Added SearchProvider enum (brave/tavily/auto), tavilyAPIKey and searchProvider @published properties with UserDefaults persistence. Updated defaultSystemPrompt to use provider-neutral "web search" language instead of "Brave Search".
  • Sources/LocalNotch/SettingsView.swift — Replaced single Brave key field with a provider segmented picker and conditional key input fields for Brave and Tavily. Status text reflects the active provider.
  • Sources/LocalNotch/ChatState.swift — Updated system preamble to use "real-time web search" instead of "Brave Search API".
  • Sources/LocalNotch/ChatView.swift — Added performWebSearch() routing method that dispatches to BraveSearchService or TavilySearchService based on searchProvider setting, with fallback in auto mode. Updated decideSearchQuery to check for either API key. Made <source> tag provider-neutral.

Dependency changes

  • None — Tavily integration uses URLSession (same as Brave), no new Swift packages needed.

Environment / config changes

  • New UserDefaults keys: tavilyAPIKey, searchProvider
  • Users configure their Tavily API key in-app via Settings > Web Search (same UX as Brave key)

Notes for reviewers

  • Brave Search code is fully preserved — this is an additive change
  • Auto mode tries Brave first, falls back to Tavily if Brave returns nil
  • Default provider is brave to maintain existing behavior for current users

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The migration correctly adds Tavily as a configurable search provider alongside Brave in an additive fashion. TavilySearchService mirrors BraveSearchService's interface using URLSession POST to the correct Tavily REST API endpoint. AppSettings gains SearchProvider enum and tavilyAPIKey with proper UserDefaults persistence and backward-compatible defaults (.brave). The SettingsView UI is well-structured with conditional key fields per provider and accurate status text. Provider-neutral preamble changes in AppSettings and ChatState are correct. The implementation is functional with only minor issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant