PerplexitySearchTool
autogen.tools.experimental.perplexity.perplexity_search.PerplexitySearchTool #
Bases: Tool
Tool for interacting with the Perplexity AI search API.
This tool uses the Perplexity API to perform web search, news search, and conversational search, returning concise and precise responses.
ATTRIBUTE | DESCRIPTION |
---|---|
url | API endpoint URL. TYPE: |
model | Name of the model to be used. TYPE: |
api_key | API key for authenticating with the Perplexity API. TYPE: |
max_tokens | Maximum tokens allowed for the API response. TYPE: |
search_domain_filters | Optional list of domain filters for the search. |
Initializes a new instance of the PerplexitySearchTool.
PARAMETER | DESCRIPTION |
---|---|
model | The model to use. Defaults to "sonar". TYPE: |
api_key | API key for authentication. |
max_tokens | Maximum number of tokens for the response. Defaults to 1000. TYPE: |
search_domain_filter | list of domain filters to restrict search. |
RAISES | DESCRIPTION |
---|---|
ValueError | If the API key is missing, the model is empty, max_tokens is not positive, or if search_domain_filter is not a list when provided. |
Source code in autogen/tools/experimental/perplexity/perplexity_search.py
tool_schema property
#
Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.
function_schema property
#
Get the schema for the function.
This is the old way of handling function calls with OpenAI and compatible frameworks. It is provided for backward compatibility.
realtime_tool_schema property
#
Get the schema for the tool.
This is the preferred way of handling function calls with OpeaAI and compatible frameworks.
search #
Perform a search query using the Perplexity AI API.
Constructs the payload, executes the query, and parses the response to return a concise search result along with any provided citations.
PARAMETER | DESCRIPTION |
---|---|
query | The search query. TYPE: |
RETURNS | DESCRIPTION |
---|---|
SearchResponse | A model containing the search result content and citations. TYPE: |
RAISES | DESCRIPTION |
---|---|
ValueError | If the search query is invalid. |
RuntimeError | If there is an error during the search process. |
Source code in autogen/tools/experimental/perplexity/perplexity_search.py
register_for_llm #
Registers the tool for use with a ConversableAgent's language model (LLM).
This method registers the tool so that it can be invoked by the agent during interactions with the language model.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
register_for_execution #
Registers the tool for direct execution by a ConversableAgent.
This method registers the tool so that it can be executed by the agent, typically outside of the context of an LLM interaction.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |
Source code in autogen/tools/tool.py
register_tool #
Register a tool to be both proposed and executed by an agent.
Equivalent to calling both register_for_llm
and register_for_execution
with the same agent.
Note: This will not make the agent recommend and execute the call in the one step. If the agent recommends the tool, it will need to be the next agent to speak in order to execute the tool.
PARAMETER | DESCRIPTION |
---|---|
agent | The agent to which the tool will be registered. TYPE: |