Skip to main content

Surfing the web in wisdom

Project description

WizAgent

CI PyPI version

WizAgent is a powerful, intelligent web automation and research framework that combines multi-engine web search, deep research capabilities, browser automation, and structured data extraction with advanced LLM support.

Features

  • 🔍 Multi-Engine Web Search - Simultaneous search across multiple engines (Tavily, DuckDuckGo, Google AI, SearXNG, Brave, Baidu, WeChat)
  • 📚 Deep Research Agent - Autonomous research with iterative query refinement and source aggregation
  • 🌐 Browser Automation - Intelligent browser control with natural language instructions powered by cogents-browser-use
  • 📊 Structured Data Extraction - Extract structured data from websites using Pydantic models
  • 🎯 YAML-Based Schema Parser - Define data models declaratively with the Gem Parser
  • 🤖 Multi-LLM Support - Works with OpenAI (compatible), Ollama, and OpenRouter
  • 🔄 LangGraph Workflows - Advanced agent orchestration with state management

Quick Start

Installation

pip install -U wizagent

Basic Usage

import asyncio
from wizagent import WizAgent

async def main():
    # Initialize the agent
    agent = WizAgent()
    
    # Web search
    search_result = await agent.search(
        query="artificial intelligence trends 2025",
        max_results_per_engine=5
    )
    print(search_result)
    
    # Deep research
    research_output = await agent.research(
        instruction="What are the latest developments in quantum computing?"
    )
    print(research_output.content)
    
    # Browser automation
    result = await agent.use_browser(
        instruction="Go to Wikipedia and find information about Python programming"
    )
    print(result)

asyncio.run(main())

Core Components

1. Search Agent

Intelligent web search with query polishing, content crawling, and result reranking:

from wizagent import SearchAgent

agent = SearchAgent(
    polish_query=True,           # LLM-powered query optimization
    rerank_results=True,          # Relevance-based reranking
    crawl_content=True,           # Crawl page content
    search_engines=["tavily", "duckduckgo"],
    max_results_per_engine=5
)

result = await agent.run("latest AI developments")
print(result)

2. Deep Research Agent

Multi-loop research with autonomous knowledge gap detection:

from wizagent import DeepResearchAgent

researcher = DeepResearchAgent(
    max_research_loops=3,
    number_of_initial_queries=3,
    search_engines=["tavily", "duckduckgo"]
)

result = await researcher.research(
    user_message="Compare renewable energy adoption in US vs Europe"
)

print(result.content)  # Comprehensive research report
print(f"Sources: {len(result.sources)}")

3. Browser Automation & Data Extraction

Navigate websites and extract structured data:

from pydantic import BaseModel, Field
from typing import List

class StockMetric(BaseModel):
    metric_name: str = Field(description="Metric name")
    value: str = Field(description="Metric value")
    
class StockData(BaseModel):
    stock_name: str
    key_metrics: List[StockMetric]

agent = WizAgent()

# Extract structured data
data = await agent.navigate_and_extract(
    url="https://example.com/stocks",
    instruction="Extract key financial metrics",
    schema=StockData,
    use_vision=True
)

print(data.stock_name)
print(data.key_metrics)

4. Gem Parser - YAML Schema Definition

Define complex Pydantic models using YAML for cleaner configuration:

# snowman_balance.yml
task: StructuredExtraction
metadata:
  name: Stock Financial Metrics
data_models:
  - name: StockMetric
    fields:
    - name: metric_name
      type: str
      desc: Metric name
    - name: value
      type: str
      desc: Metric value
  - name: StockData
    fields:
    - name: stock_name
      type: str
      desc: Stock name
    - name: metrics
      type: List[StockMetric]
      desc: Key metrics
output_model: StockData
instruction: Extract financial metrics from the page

Load and use the schema:

from wizagent.gems import parse_yaml_file

# Parse YAML to Pydantic models
result = parse_yaml_file("snowman_balance.yml")
StockData = result.target_model

# Use with WizAgent
agent = WizAgent()
data = await agent.navigate_and_extract(
    url="https://example.com",
    instruction=result.instruction,
    schema=StockData
)

Advanced Examples

See the examples/ directory for more use cases:

  • examples/agent/search_agent_demo.py - Web search with crawling and reranking
  • examples/agent/deep_research_demo.py - Autonomous research workflow
  • examples/agent/snowman_balance.py - Structured data extraction from websites
  • examples/agent/visit_wikipedia.py - Browser navigation and interaction
  • examples/gems/snowman_gem.py - YAML-based schema parsing

Architecture

WizAgent is built on top of:

  • cogents-core - Core LLM abstractions and agent framework
  • cogents-browser-use - Browser automation with intelligent control
  • wizsearch - Multi-engine web search orchestration
  • LangGraph - Workflow orchestration and state management
  • Pydantic - Data validation and structured outputs

Configuration

Set environment variables for LLM configuration. The configuration is provider-specific:

OpenAI-compatible

export COGENTS_LLM_PROVIDER=openai
export OPENAI_API_KEY=your-api-key
export OPENAI_CHAT_MODEL=gpt-4  # optional, default: gpt-3.5-turbo
export OPENAI_BASE_URL=https://api.openai.com/v1  # optional

Other Providers

Ollama (local):

export COGENTS_LLM_PROVIDER=ollama
export OLLAMA_BASE_URL=http://localhost:11434
export OLLAMA_CHAT_MODEL=llama2  # optional

OpenRouter:

export COGENTS_LLM_PROVIDER=openrouter
export OPENROUTER_API_KEY=your-api-key
export OPENROUTER_CHAT_MODEL=anthropic/claude-3-haiku  # optional

Search Engine Configuration

For specific search engines, you may need additional API keys:

# Tavily (recommended)
export TAVILY_API_KEY=your-tavily-key

# Google AI Search
export GOOGLE_API_KEY=your-google-key

# Brave Search
export BRAVE_API_KEY=your-brave-key

See env.example for complete configuration reference.

Development

# Install development dependencies
make install

# Run tests
make test

# Format code
make format

# Run quality checks
make quality

# Full development check
make dev-check

License

MIT License - see LICENSE file for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wizagent-0.0.1.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wizagent-0.0.1-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file wizagent-0.0.1.tar.gz.

File metadata

  • Download URL: wizagent-0.0.1.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for wizagent-0.0.1.tar.gz
Algorithm Hash digest
SHA256 871c0aee76904b4a7f853777bca791fe24e3d156116592470f426f726f081a22
MD5 2349d3683d9d451b37603f9345fe1065
BLAKE2b-256 7fa860b5e92fdbece8b32a93057789116118b5acffc0efc690a77c672e713e73

See more details on using hashes here.

File details

Details for the file wizagent-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: wizagent-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for wizagent-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c9f1a100c89d1e8ef6969aca1ec9b75b7509b2620330eba1fd77bab3452127a
MD5 21fb788616003a8aa224cd940e636636
BLAKE2b-256 09c2b4553b642f38af3e22ec24442ef34191955d40b2871a83482664d772263f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page