WebConfig

Configure web search and fetch capabilities for agents

Enable agents to search the web and fetch page content for real-time information retrieval.

Diagram

Web Capabilities

❓ Query

🔍 Search

📄 Fetch

📊 Process

Quick Start

  1. 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
    )
  2. 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

python
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
)
ParameterTypeDefaultDescription
searchboolTrueEnable web search capability
fetchboolTrueEnable page content fetching
search_provider`str \WebSearchProvider`"duckduckgo"Search provider (duckduckgo, google, bing, tavily, serper)
max_resultsint5Maximum search results to return
search_config`Dict \None`NoneProvider-specific search settings
fetch_config`Dict \None`NonePage fetching configuration

Search Providers

ProviderAPI Key RequiredBest For
duckduckgoNoFree, privacy-focused
googleYesComprehensive results
bingYesMicrosoft ecosystem
tavilyYesAI-optimized search
serperYesGoogle results via API

Common Patterns

Pattern 1: Tavily for AI Search

python
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)

python
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.


Related