datarobot_genai.drtools.core.clients.tavily
tavily
Tavily API Client and utilities for API key authentication.
TavilySearchResults
Bases: BaseModel
Source code in datarobot_genai/drtools/core/clients/tavily.py
from_tavily_sdk
classmethod
Create a TavilySearchResult from Tavily SDK response data.
Source code in datarobot_genai/drtools/core/clients/tavily.py
as_flat_dict
Return a flat dictionary representation of the search result.
Source code in datarobot_genai/drtools/core/clients/tavily.py
TavilyExtractResults
Bases: BaseModel
Source code in datarobot_genai/drtools/core/clients/tavily.py
from_tavily_sdk
classmethod
Create a TavilyExtractResults from Tavily SDK response data.
Source code in datarobot_genai/drtools/core/clients/tavily.py
as_flat_dict
Return a flat dictionary representation of the extract result.
Source code in datarobot_genai/drtools/core/clients/tavily.py
TavilyMapResults
Bases: BaseModel
Source code in datarobot_genai/drtools/core/clients/tavily.py
from_tavily_sdk
classmethod
Create a TavilyMapResults from Tavily SDK response data.
Source code in datarobot_genai/drtools/core/clients/tavily.py
as_flat_dict
Return a flat dictionary representation of the map result.
Source code in datarobot_genai/drtools/core/clients/tavily.py
TavilyCrawlResults
Bases: BaseModel
Results from Tavily Crawl API.
Source code in datarobot_genai/drtools/core/clients/tavily.py
from_tavily_sdk
classmethod
Create a TavilyCrawlResults from Tavily SDK response data.
Source code in datarobot_genai/drtools/core/clients/tavily.py
as_flat_dict
Return a flat dictionary representation of the crawl result.
Source code in datarobot_genai/drtools/core/clients/tavily.py
TavilyClient
Client for interacting with Tavily API.
This is a wrapper around the official tavily-python SDK.
Source code in datarobot_genai/drtools/core/clients/tavily.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
search
async
search(query: str, *, topic: Literal['general', 'news', 'finance'] = 'general', search_depth: Literal['basic', 'advanced'] = 'basic', max_results: int = MAX_RESULTS_DEFAULT, time_range: Literal['day', 'week', 'month', 'year'] | None = None, include_images: bool = False, include_image_descriptions: bool = False, chunks_per_source: int = CHUNKS_PER_SOURCE_DEFAULT, include_answer: bool = False) -> TavilySearchResults
Perform a web search using Tavily API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query to execute. |
required |
topic
|
Literal['general', 'news', 'finance']
|
The category of search ("general", "news", or "finance"). |
'general'
|
search_depth
|
Literal['basic', 'advanced']
|
The depth of search ("basic" or "advanced"). |
'basic'
|
max_results
|
int
|
Maximum number of results to return (1-20). |
MAX_RESULTS_DEFAULT
|
time_range
|
Literal['day', 'week', 'month', 'year'] | None
|
Time range filter ("day", "week", "month", "year"). |
None
|
include_images
|
bool
|
Whether to include images in results. |
False
|
include_image_descriptions
|
bool
|
Whether to include image descriptions. |
False
|
chunks_per_source
|
int
|
Maximum content snippets per URL (1-3). |
CHUNKS_PER_SOURCE_DEFAULT
|
include_answer
|
bool
|
Whether to include an AI-generated answer. |
False
|
Returns
TavilySearchResults
Raises
ValueError: If validation fails.
TavilyInvalidAPIKeyError: If the API key is invalid.
TavilyUsageLimitExceededError: If usage limit is exceeded.
TavilyForbiddenError: If access is forbidden.
TavilyBadRequestError: If the request is malformed.
Source code in datarobot_genai/drtools/core/clients/tavily.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
extract
async
extract(urls: str | list[str], *, query: str | None = None, chunks_per_source: int = 3, extract_depth: Literal['basic', 'advanced'] = 'basic', format: Literal['markdown', 'text'] = 'markdown', include_images: bool = False, include_favicon: bool = False, timeout: float = 30.0) -> TavilyExtractResults
Extract content from URLs using Tavily Extract API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urls
|
str | list[str]
|
The URL or list of URLs to extract content from (max 20). |
required |
query
|
str | None
|
User intent for reranking extracted content chunks based on relevance. |
None
|
chunks_per_source
|
int
|
Maximum number of 500-char snippets per URL (1-5, default 3). |
3
|
extract_depth
|
Literal['basic', 'advanced']
|
Depth of extraction ("basic" or "advanced"). |
'basic'
|
format
|
Literal['markdown', 'text']
|
Format of extracted content ("markdown" or "text"). |
'markdown'
|
include_images
|
bool
|
Whether to include images in results. |
False
|
include_favicon
|
bool
|
Whether to include favicon in results. |
False
|
timeout
|
float
|
Request timeout in seconds (1.0-60.0, default 30.0). |
30.0
|
Returns
TavilyExtractResults
Raises
ValueError: If validation fails.
TavilyInvalidAPIKeyError: If the API key is invalid.
TavilyUsageLimitExceededError: If usage limit is exceeded.
TavilyForbiddenError: If access is forbidden.
TavilyBadRequestError: If the request is malformed.
Source code in datarobot_genai/drtools/core/clients/tavily.py
map_
async
map_(url: str, instructions: str | None = None, limit: int = 50, include_usage: bool = False) -> TavilyMapResults
Generate a structured map of a website to discover relevant sub-pages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The root URL to begin mapping. |
required |
instructions
|
str | None
|
Instructions to guide the mapper toward specific paths. |
None
|
limit
|
int
|
Total links to process. |
50
|
include_usage
|
bool
|
Whether to include credit usage information in the response. |
False
|
Returns
TavilyMapResults
Raises
ValueError: If validation fails.
TavilyInvalidAPIKeyError: If the API key is invalid.
TavilyUsageLimitExceededError: If usage limit is exceeded.
TavilyForbiddenError: If access is forbidden.
TavilyBadRequestError: If the request is malformed.
Source code in datarobot_genai/drtools/core/clients/tavily.py
crawl
async
crawl(url: str, *, instructions: str | None = None, limit: int = 20, max_depth: int = 1, exclude_paths: list[str] | None = None, include_images: bool = False) -> TavilyCrawlResults
Crawl a website using Tavily Crawl API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The root URL to begin the traversal. |
required |
instructions
|
str | None
|
Natural language instructions for the crawler to filter relevant content. |
None
|
limit
|
int
|
Total number of links to process (1-500, default 20). |
20
|
max_depth
|
int
|
Maximum depth from base URL (1-5, default 1). |
1
|
exclude_paths
|
list[str] | None
|
Regex patterns to exclude URL paths. |
None
|
include_images
|
bool
|
Whether to include images found during crawl. |
False
|
Returns
TavilyCrawlResults
Raises
ValueError: If validation fails.
TavilyInvalidAPIKeyError: If the API key is invalid.
TavilyUsageLimitExceededError: If usage limit is exceeded.
TavilyForbiddenError: If access is forbidden.
TavilyBadRequestError: If the request is malformed.
Source code in datarobot_genai/drtools/core/clients/tavily.py
__aenter__
async
__aexit__
async
Async context manager exit.
Source code in datarobot_genai/drtools/core/clients/tavily.py
get_tavily_access_token
async
Get Tavily API key from HTTP headers.
Returns
API key string
Raises
ToolError: If API key is not found in headers