feat: add PerplexitySearch tool#283
Conversation
Adds a PerplexitySearch tool to @kaibanjs/tools that wraps POST https://api.perplexity.ai/search and returns structured { title, url, snippet, date? } results suitable for grounding agents in fresh web content. - Reads API key from constructor or PERPLEXITY_API_KEY / PPLX_API_KEY env - Configurable maxResults, searchDomainFilter, searchRecencyFilter - Registered in main exports, package.json subpath, and rollup config - Tests cover defaults, filters, env-var auth, parse/HTTP/network errors - README and Storybook story added Reference: https://docs.perplexity.ai/api-reference/search-post
|
Hi @darielnoel — once this PR lands, would you consider making I pushed a small follow-up commit on this branch (docs-only, ~20 lines) that:
Rationale for picking it as the default:
Happy to revert the docs nudge or split it into a follow-up PR if you'd rather keep this one focused on the tool itself — whichever you prefer. Either way, thanks for reviewing! |
|
Friendly bump — happy to address any feedback. Recent commit added a docs callout proposing PerplexitySearch as the recommended default web search tool; let me know if you'd prefer to keep it as one of several or position it differently. |
|
Added the Perplexity attribution header as Validated in
🤖 Comment from PSI |
Summary
Adds a
PerplexitySearchtool to@kaibanjs/toolsthat wrapsPOST https://api.perplexity.ai/searchand returns structured{ title, url, snippet, date? }results, modeled after the existing Tavily / Exa / Serper search tools.What's new
packages/tools/src/perplexity-search/(TS + JS implementations matching the existing tool pattern)apiKeydirectly, or falls back to thePERPLEXITY_API_KEY/PPLX_API_KEYenvironment variablemaxResults,searchDomainFilter(allow- or deny-list — leading-for deny),searchRecencyFilter(hour | day | week | month | year)src/index.tsexports,package.jsonsubpath exports, androllup.config.mjsbuild targetsTests
10 Jest tests in
src/perplexity-search/tool.test.jscovering:maxResults,searchDomainFilter,searchRecencyFilterPERPLEXITY_API_KEYandPPLX_API_KEYenv varsdist/perplexity-search/index.cjs.jsanddist/index.cjs.jsRun:
cd packages/tools npm install npm run build npx jest src/perplexity-search/tool.test.jsAll 10 tests pass locally.
Reference