Perplexity
Overview
The PerplexityLLMService integrates Perplexity's online LLMs, which are specialized for real-time information retrieval and search. It handles Perplexity's unique incremental token usage reporting.
Installation
pip install piopiy-ai
Prerequisites
- A Perplexity API key (Get yours here).
- Set your API key in your environment:
export PERPLEXITY_API_KEY="your_api_key_here"
Configuration
PerplexityLLMService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Perplexity API key. |
model | str | "sonar" | Model identifier. |
base_url | str | "https://api.perplexity.ai" | API endpoint. |
Usage
Basic Setup
import os
from piopiy.services.perplexity.llm import PerplexityLLMService
llm = PerplexityLLMService(
api_key=os.getenv("PERPLEXITY_API_KEY"),
model="sonar"
)
Notes
- Real-time Search: Perplexity models are distinct for their ability to search the web during inference.
- Limited Parameters: Note that Perplexity supports a subset of OpenAI parameters (no tools/function calling).