A very basic Perplexity search script - simple as possible for use with agents.
Uses the new Search API only i.e. treat this as you would a programmatic Google keyword search (rather than expecting LLM-style answer to a question - for this, use Sonar etc.)
I added this script as a custom tool for my Letta agents for example (the schema shown was auto-generated by Letta)
- Implemented a default of 5 results (rather then 10 as per the API defaults) as more results are likely too long to fit comfortably in context of subsequent LLM agent use.
- Implemented docstring instructions around use of the country code that are specific to me and not honed:
- Amend "GB" to your most relavant country code, or amend entirely if this advice to calling LLMs is not desired
- Evolve wording (i.e. this is prompt engineering) if your agent goes off the rails e.g. it makes non-geographic searches country specific
Don't forget to add your Perplexity API key via whatever method is relevant to your use