Web Search
Give agents access to web search
Enable agents to search the web for current information.
Quick Start
- Create Agent with Web Search Tool
rust use praisonai::{Agent, tool}; // Define web search tool #[tool(description = "Search the web for current information")] async fn web_search(query: String) -> String { // Use your preferred search API search_api::search(&query).await } // Create agent with web search capability let agent = Agent::new() .name("Researcher") .instructions("Search the web when asked about current events or news") .tool(web_search) .build()?; let response = agent.chat("What are today's top tech news?").await?; // Agent uses web_search tool and responds with current info - Using Multiple Search Tools
rust use praisonai::{Agent, tool}; #[tool(description = "Search news articles")] async fn news_search(query: String) -> String { news_api::search(&query).await } #[tool(description = "Search general web")] async fn general_search(query: String) -> String { google_api::search(&query).await } let agent = Agent::new() .name("Researcher") .instructions("Use news_search for news, general_search for other queries") .tool(news_search) .tool(general_search) .build()?;
How It Works
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
web_search | bool | false | Enable web search |
max_results | usize | 5 | Results to fetch |