WebConfig
Configure web search and fetch capabilities for agents
Enable agents to search the web and fetch page content for real-time information retrieval.
Quick Start
- Simple Enable
Enable web capabilities with defaults:
python from praisonaiagents import Agent agent = Agent( name="Web Agent", instructions="Search the web for information", web=True ) - With Configuration
Configure search provider and settings:
python from praisonaiagents import Agent from praisonaiagents.config import WebConfig agent = Agent( name="Web Agent", instructions="Search the web for information", web=WebConfig( search=True, fetch=True, search_provider="duckduckgo", max_results=5 ) )
Configuration Options
from praisonaiagents.config import WebConfig, WebSearchProvider
config = WebConfig(
# Enable web search
search=True,
# Enable web fetch (retrieve full page content)
fetch=True,
# Search provider
search_provider=WebSearchProvider.DUCKDUCKGO,
# Search settings
max_results=5,
# Provider-specific settings
search_config=None,
# Fetch config
fetch_config=None
)| Parameter | Type | Default | Description | |
|---|---|---|---|---|
search | bool | True | Enable web search capability | |
fetch | bool | True | Enable page content fetching | |
search_provider | `str \ | WebSearchProvider` | "duckduckgo" | Search provider (duckduckgo, google, bing, tavily, serper) |
max_results | int | 5 | Maximum search results to return | |
search_config | `Dict \ | None` | None | Provider-specific search settings |
fetch_config | `Dict \ | None` | None | Page fetching configuration |
Search Providers
| Provider | API Key Required | Best For |
|---|---|---|
duckduckgo | No | Free, privacy-focused |
google | Yes | Comprehensive results |
bing | Yes | Microsoft ecosystem |
tavily | Yes | AI-optimized search |
serper | Yes | Google results via API |
Common Patterns
Pattern 1: Tavily for AI Search
from praisonaiagents import Agent
from praisonaiagents.config import WebConfig
agent = Agent(
name="AI Search Agent",
instructions="Find accurate information",
web=WebConfig(
search_provider="tavily",
max_results=10,
search_config={"api_key": "your-tavily-key"}
)
)Pattern 2: Search Only (No Fetching)
from praisonaiagents import Agent
from praisonaiagents.config import WebConfig
agent = Agent(
name="Search Agent",
instructions="List search results",
web=WebConfig(
search=True,
fetch=False, # Don't fetch page content
max_results=10
)
)Best Practices
Use DuckDuckGo for Free Searches
DuckDuckGo requires no API key and is suitable for most use cases.
Use Tavily for AI-Optimized Results
Tavily is designed for AI agents and returns more relevant, concise results.
Limit Results for Speed
Fewer results means faster responses. Start with 5 and increase if needed.