Give it tools - Perplexity
Summary
Perplexity models can extend their capabilities beyond pre-trained knowledge by integrating external tools. This functionality is enabled by listing tools in the "tools" array, allowing the model to decide when to invoke them based on the prompt. Two primary types of tools are supported: built-in tools and function tools. Built-in tools, hosted by Perplexity, include "web_search", "fetch_url", "people_search", "finance_search", and a "sandbox" for code execution, each activated by its "type". Function tools allow agents to call user-controlled code, such as internal APIs or databases. These are defined with a "name", "description", and JSON Schema "parameters". When a function tool is called, the model pauses, providing arguments for the user to execute the function and return the result, which is then replayed to the model. Tool invocation can be controlled using "tool_choice" and "parallel_tool_calls" parameters. Tool outputs, like "search_results" or "function_call" items, are returned in the response's "output" array.
Key takeaway
For AI Engineers building agents that require real-time data or custom system interactions, you should integrate Perplexity's built-in or function tools. This allows your models to perform actions like live web searches or query internal APIs, significantly expanding their operational scope. Define function tool schemas carefully and manage external execution and result re-injection to ensure seamless agent functionality.
Key insights
Perplexity models integrate built-in and custom function tools to extend capabilities beyond internal knowledge.
Principles
- Models decide tool use based on prompt.
- Function tools require user execution.
- "call_id" correlates function calls and outputs.
Method
To integrate tools, add them to the "tools" array. For function tools, define schema, execute calls externally, and replay results with "function_call_output" using the "call_id".
In practice
- Use "web_search" for live web data.
- Integrate internal APIs via function tools.
- Run code in an isolated "sandbox".
Topics
- Perplexity API
- Tool Use
- Function Calling
- Web Search
- Code Sandbox
- Agent Development
- API Integration
Best for: AI Engineer, Machine Learning Engineer, Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by perplexity.ai via Google News.