WebCanvas Framework

repository·main·Indexed 42 days ago

https://github.com/imeanai/webcanvas

An open-source framework for building, training, and evaluating web agents in live, dynamic web environments. It features a modular base agent architecture (Planning, Observation, Memory, Reward, Action Execution, and Evaluation), a 'key-node' based trajectory system for granular assessment, and the Mind2Web-Live dataset. Supports integration with OpenAI, Claude, Gemini, and Together AI models, as well as Browserbase for cloud browser execution.

Tokens
2.3K
Snippets
9
Records
14
Agent score
53%

What's inside WebCanvas

  1. Overview of WebCanvas

    main

    WebCanvas is an open-source framework designed for the online development, training, and evaluation of web agents. Unlike static or offline frameworks, WebCanvas focuses on real-time, dynamic web environments to address challenges like error handling, CAPTCHA solving, and agent efficiency.

    Key components include:

    • Base Agent Framework: A plug-and-play architecture with modules for Planning, Observation, Memory, Reward, Action Execution, and Evaluation.
    • Key Nodes Annotation: A granular, phase-based assessment system that uses "key nodes" to provide in-progress feedback during web trajectories.
    • Mind2Web-Live Dataset: A refined version of the Mind2Web dataset containing 542 tasks and 2439 intermediate evaluation states.
    • Live Environment Interaction: Real-time assessment in dynamic web environments using toolkits for observation capture and action space definition.
  2. WebCanvas Core Agent Modules

    main

    The WebCanvas base agent framework is designed to be modular and plug-and-play. Developers can iterate on LLM-based web agents by implementing or swapping the following key modules:

    • Planning: Logic for determining the next steps in a task.
    • Observation: Capturing the current state of the web environment.
    • Memory: Storing historical context and observations.
    • Reward: Providing feedback based on agent actions.
    • Action Execution: Performing actions within the web environment.
    • Evaluation: Assessing the agent's performance against task goals.
  3. Understand Mind2web-live Leaderboard metrics

    main

    The Mind2web-live leaderboard evaluates web agents based on two primary performance metrics:

    • Completion rate: The success rate of the model in completing the assigned tasks.
    • Task success rate: The success rate of the model in performing the specific steps or actions required by the tasks.

    Agents marked with a star (★) indicate that the model or the underlying code has been open-sourced and verified.

  4. Calculate token consumption and USD efficiency

    main

    WebCanvas automatically calculates token consumption for the planning and global reward modules using tiktoken. Results are saved in the token_results folder as JSON.

    Custom Pricing: To calculate monetary expenditure for models not listed in the default token_pricing in configs/setting.toml:

    1. Add the full model name (e.g., gpt-4o-2024-05-13) to the pricing_models list.
    2. Define the unit prices using the format: {model_name}_input_price = <price> and {model_name}_output_price = <price>.
  5. Configure Gemini API keys

    main

    To use Gemini models within WebCanvas, set the GOOGLE_API_KEY environment variable. Replace your-api-key-here with your actual key from Google.

    # MacOS/Linux
    export GOOGLE_API_KEY='your-api-key-here'
    
    # Windows
    setx GOOGLE_API_KEY "your-api-key-here"
  6. Run web agent evaluations

    main

    Execute the evaluation script using evaluate.py. You can customize the reward mode, the data index, the specific task, and the models used for planning and reward reasoning.

    Configuration: The task_mode (batch vs. single) and the path to your test file are controlled via configs/setting.toml.

    python evaluate.py \
        --global_reward_mode dom_reward \
        --index -1 \
        --single_task_name "Find Dota 2 game and add all DLC to cart in steam." \
        --planning_text_model gpt-4o-mini \
        --global_reward_text_model gpt-4o-mini
  7. Set up the WebCanvas environment

    main

    To prepare your environment for evaluating web agents, follow these steps to install Python and Node.js dependencies:

    1. Python Environment: Create and activate a Conda environment with Python 3.11 and install the required packages.
    2. Node.js Dependencies: Initialize npm and install axios.
    3. API Keys: Ensure you have set up required LLM API keys (refer to agent/LLM/README.md) and Google Search credentials to prevent GUI agent blocking.

    Recommended Environment for Mind2Web-Live: For optimal performance, use a Windows server with Chrome or Firefox, preferably located in the United States.

    # Python setup
    conda create -n webcanvas python=3.11
    conda activate webcanvas
    pip install -r requirements.txt
    
    # Node.js setup
    npm init -y
    npm install axios
    
    # Google Search API setup
    export GOOGLE_API_KEY=your_api_key
    export GOOGLE_CX=your_custom_search_engine_id
  8. Upload evaluation results to a challenge

    main

    To participate in a challenge, you must upload your generated out.json file using the dataset_io.py utility.

    python data/dataset_io.py upload \
        --file-path /path/to/your/file \
        --challenge-id your_challenge_id \
        --name your_agent_name \
        --base-model your_agent_base_model
  9. Configure Browserbase for cloud browser execution

    main

    You can leverage Browserbase to run headless browsers at scale. To configure it:

    1. Get your API Key from the Browserbase Dashboard Settings.
    2. Add the key to your .env file as BROWSERBASE_API_KEY.

    Alternatively, you can set it as an environment variable for a single command: BROWSERBASE_API_KEY=<your_api_key> <command>

    export BROWSERBASE_API_KEY=your_api_key
  10. Configure OpenAI API keys

    main

    To use OpenAI models within WebCanvas, set the OPENAI_API_KEY environment variable. Replace your-api-key-here with your actual key from the OpenAI platform.

    # MacOS/Linux
    export OPENAI_API_KEY='your-api-key-here'
    
    # Windows
    setx OPENAI_API_KEY "your-api-key-here"
  11. Configure Together AI API keys

    main

    To use Together AI models within WebCanvas, set the TOGETHER_API_KEY environment variable. Replace your-api-key-here with your actual key from Together AI.

    # MacOS/Linux
    export TOGETHER_API_KEY='your-api-key-here'
    
    # Windows
    setx TOGETHER_API_KEY "your-api-key-here"
  12. Configure Claude API keys

    main

    To use Claude models within WebCanvas, set the ANTHROPIC_API_KEY environment variable. Replace your-api-key-here with your actual key from Anthropic.

    # MacOS/Linux
    export ANTHROPIC_API_KEY='your-api-key-here'
    
    # Windows
    setx ANTHROPIC_API_KEY "your-api-key-here"