diff --git a/tools-src/web-search/src/lib.rs b/tools-src/web-search/src/lib.rs index f42cf167..1e040efb 100644 --- a/tools-src/web-search/src/lib.rs +++ b/tools-src/web-search/src/lib.rs @@ -42,10 +42,10 @@ impl exports::near::agent::tool::Guest for WebSearchTool { } fn description() -> String { - "Search the web using Brave Search. Returns titles, URLs, descriptions, and \ - publication dates for matching web pages. Supports filtering by country, \ - language, and freshness. Authentication is handled via the 'brave_api_key' \ - secret injected by the host." + "Search the web using Brave Search. Returns titles, URLs, descriptions, \ + publication dates, and thumbnail images for matching web pages. Supports \ + filtering by country, language, and freshness. Authentication is handled \ + via the 'brave_api_key' secret injected by the host." .to_string() } } @@ -76,6 +76,12 @@ struct BraveSearchResult { url: Option, description: Option, age: Option, + thumbnail: Option, +} + +#[derive(Debug, Deserialize)] +struct BraveThumbnail { + src: Option, } fn execute_inner(params: &str) -> Result { @@ -198,6 +204,9 @@ fn execute_inner(params: &str) -> Result { if let Some(age) = r.age { entry["published"] = serde_json::json!(age); } + if let Some(thumb) = r.thumbnail.and_then(|t| t.src) { + entry["thumbnail"] = serde_json::json!(thumb); + } // Extract hostname for site_name. if let Some(host) = extract_hostname(&url) { entry["site_name"] = serde_json::json!(host);