pub struct WebSearchTool { /* private fields */ }Expand description
Builtin tool that performs web searches and returns ranked result snippets.
Delegates to one of four backends selected via SearchProvider; the default
Auto mode tries Exa → Tavily → Brave → DuckDuckGo in priority order based
on which API keys are present in the environment. DuckDuckGo requires no key
and is always available as a zero-config fallback. Results are returned as
title + URL + snippet text, capped at MAX_NUM_RESULTS = 50.
Implementations§
Source§impl WebSearchTool
impl WebSearchTool
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a WebSearchTool with automatic provider selection.
Panics if the HTTP client cannot be built (TLS initialisation failure).
Use WebSearchTool::try_new if you need to handle the error.
Sourcepub fn try_new() -> Result<Self, Error>
pub fn try_new() -> Result<Self, Error>
Create a WebSearchTool with automatic provider selection.
Returns Err if the underlying HTTP client cannot be constructed
(e.g., TLS initialisation failure).
Sourcepub fn with_provider(provider: SearchProvider) -> Self
pub fn with_provider(provider: SearchProvider) -> Self
Create a WebSearchTool that uses a specific search provider
instead of auto-detecting from environment variables.
Panics if the HTTP client cannot be built. Use WebSearchTool::try_with_provider
if you need to handle the error.
Sourcepub fn try_with_provider(provider: SearchProvider) -> Result<Self, Error>
pub fn try_with_provider(provider: SearchProvider) -> Result<Self, Error>
Create a WebSearchTool that uses a specific search provider.
Returns Err if the underlying HTTP client cannot be constructed.