Struct WebSearchTool
pub struct WebSearchTool { /* private fields */ }Expand description
Web search tool for searching the internet. Supports multiple model_providers: DuckDuckGo (free), Brave (requires API key), Tavily (requires API key), SearXNG (self-hosted, requires instance URL), Jina AI (requires API key), Bocha AI (requires API key, Chinese-friendly).
API keys are resolved lazily at execution time: if the boot-time key
is missing or still encrypted, the tool re-reads config.toml, decrypts the
corresponding [web_search] field, and uses the result. This ensures that
keys set or rotated after boot, and encrypted keys, are correctly picked up.
The Bocha key has no boot-time snapshot at all — it is always resolved from
config.toml at use time (see resolve_bocha_api_key), so the
canonical [web_search] bocha_api_key field stays the single source of
truth and rotation/removal takes effect without a restart.
Implementations§
Source§impl WebSearchTool
impl WebSearchTool
pub fn new( model_provider: String, brave_api_key: Option<String>, jina_api_key: Option<String>, max_results: usize, timeout_secs: u64, ) -> WebSearchTool
pub fn new_with_config( model_provider: String, brave_api_key: Option<String>, tavily_api_key: Option<String>, jina_api_key: Option<String>, searxng_instance_url: Option<String>, max_results: usize, timeout_secs: u64, config_path: PathBuf, secrets_encrypt: bool, ) -> WebSearchTool
Trait Implementations§
Source§impl Attributable for WebSearchTool
impl Attributable for WebSearchTool
Source§impl Tool for WebSearchTool
impl Tool for WebSearchTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
WebSearchTool: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
WebSearchTool: 'async_trait,
Source§fn output_schema(&self) -> Option<Value>
fn output_schema(&self) -> Option<Value>
ToolOutput::data, when it declares one. None means the tool
emits display text only; authoring surfaces fall back to
sample-derived shapes from captured runs.Source§fn param_domains(&self) -> Vec<(&'static str, OptionDomain)>
fn param_domains(&self) -> Vec<(&'static str, OptionDomain)>
fn spec(&self) -> ToolSpec
Auto Trait Implementations§
impl Freeze for WebSearchTool
impl RefUnwindSafe for WebSearchTool
impl Send for WebSearchTool
impl Sync for WebSearchTool
impl Unpin for WebSearchTool
impl UnsafeUnpin for WebSearchTool
impl UnwindSafe for WebSearchTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more