Skip to content

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

Open
tavily-integrations wants to merge 1 commit into
kbennett2000:mainfrom
Tavily-FDE:feat/tavily-migration/sourced-add-tavily-provider
Open

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

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

Adds Tavily Search as a third selectable retrieval endpoint alongside Brave Web Search and LLM Context. Brave remains the default; Tavily activates when a TAVILY_API_KEY is configured.

What changed

  • lib/tavily.ts (new): Tavily search module using @tavily/core SDK. Exports tavilySearch() returning the shared RetrievalResult interface, and TavilyError for error handling. Mirrors the shape of lib/brave.ts.
  • lib/types.ts: Extended Endpoint type and AnswerRequestSchema to include "tavily".
  • lib/env.ts: Added optional TAVILY_API_KEY to the Zod env schema.
  • app/api/answer/route.ts: Added tavily branch to retrieval logic with TavilyError handling.
  • components/EndpointToggle.tsx: Added third "Tavily" toggle option, updated grid to 3 columns.
  • .env.example: Documented TAVILY_API_KEY variable.
  • tests/tavily.test.ts (new): Unit tests covering success path, empty results, URL filtering, missing API key, and upstream errors.
  • tests/setup.ts: Added test TAVILY_API_KEY default.
  • package.json: Added @tavily/core dependency.

Dependency changes

  • Added @tavily/core (^0.6.1) to dependencies

Environment variable changes

  • Added TAVILY_API_KEY (optional — only required when using the Tavily endpoint)

Notes for reviewers

  • Brave endpoints are completely untouched — this is a purely additive change.
  • Run pnpm install after checkout to fetch the new @tavily/core dependency.
  • The Tavily module creates a new client per request (lightweight); can be optimized to a singleton if needed later.

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily provider migration is correct, complete, and non-breaking. All files called out in the plan are present and the implementation faithfully mirrors the shape of lib/brave.ts. The @tavily/core SDK is used correctly (tavily({ apiKey }), client.search with maxResults/searchDepth options), the Endpoint union and AnswerRequestSchema are extended consistently, error handling integrates cleanly into the existing catch-chain, and the UI toggle correctly shifts to a 3-column grid. The only issues are minor: dead/confused code in one test case and a stale JSDoc comment.

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