datarobot_genai.drtools.core.clients.perplexity
perplexity
PerplexityError
PerplexityThinkResult
Bases: BaseModel
Source code in datarobot_genai/drtools/core/clients/perplexity.py
from_perplexity_sdk
classmethod
Create a PerplexityThinkResult from perplexity sdk response data.
Source code in datarobot_genai/drtools/core/clients/perplexity.py
PerplexitySearchResult
Bases: BaseModel
Source code in datarobot_genai/drtools/core/clients/perplexity.py
from_perplexity_sdk
classmethod
Create a PerplexitySearchResult from perplexity sdk response data.
PerplexityClient
Client for interacting with Perplexity API. Its simple wrapper around perplexity python sdk.
Source code in datarobot_genai/drtools/core/clients/perplexity.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
search
async
search(query: str | list[str], search_domain_filter: list[str] | None = None, recency: Literal['hour', 'day', 'week', 'month', 'year'] | None = None, max_results: int = MAX_RESULTS_DEFAULT, max_tokens_per_page: int = MAX_TOKENS_PER_PAGE_DEFAULT) -> list[PerplexitySearchResult]
Search using Perplexity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | list[str]
|
Query to filter results. |
required |
search_domain_filter
|
list[str] | None
|
Up to 20 domains/URLs to allowlist or denylist. |
None
|
recency
|
Literal['hour', 'day', 'week', 'month', 'year'] | None
|
Filter results by time period. |
None
|
max_results
|
int
|
Number of ranked results to return. |
MAX_RESULTS_DEFAULT
|
max_tokens_per_page
|
int
|
Context extraction cap per page. |
MAX_TOKENS_PER_PAGE_DEFAULT
|
Returns
List of Perplexity search results.
Source code in datarobot_genai/drtools/core/clients/perplexity.py
think
async
think(prompt: str, model: Literal['sonar', 'sonar-reasoning-pro', 'sonar-deep-research'], json_schema: dict | None = None) -> PerplexityThinkResult
Think using Perplexity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
The research prompt or instruction. |
required |
model
|
Literal['sonar', 'sonar-reasoning-pro', 'sonar-deep-research']
|
Select capability: - 'sonar' (fast ask), - 'sonar-reasoning-pro' (complex logic) - 'sonar-deep-research' (comprehensive reports). |
required |
json_schema
|
dict | None
|
Optional JSON Schema to enforce structured output for data extraction. |
None
|
Returns
Perplexity think result.
Source code in datarobot_genai/drtools/core/clients/perplexity.py
__aenter__
async
__aexit__
async
get_perplexity_access_token
async
Get Perplexity API key from HTTP headers.
At the moment of creating this fn. Perplexity does not support OAuth. It allows only API-KEY authorized flow.
Returns
Access token string on success, ToolError on failure