Skip to content

Usage

Minimal example

This example navigates to the HuggingFace docs and follows the PEFT quick-tour link -- the canonical LaVague demo from the official quick-tour guide.

python
from lavague.core import WorldModel, ActionEngine
from lavague.core.agents import WebAgent
from lavague.drivers.selenium import SeleniumDriver

# Open a Selenium-backed browser (headless=False shows the browser window)
driver = SeleniumDriver(headless=False)

# Build the three core components
world_model = WorldModel()
action_engine = ActionEngine(driver)

# Compose them into a WebAgent
agent = WebAgent(world_model, action_engine)

# Navigate to the starting URL
agent.get("https://huggingface.co/docs")

# Run the objective -- the agent loops until done or it gives up
agent.run("Go on the quicktour of PEFT")

Interactive demo mode

To launch the Gradio interface where you can step through each action and approve or reject it before it executes:

python
agent.demo("Go on the quicktour of PEFT")

This opens a local web UI at http://127.0.0.1:7860 where you can watch the agent reason, see what action it plans, and either confirm or stop it.


Environment variables

VariableRequiredPurpose
OPENAI_API_KEYYes (default LLM)Powers the WorldModel and ActionEngine
LAVAGUE_TELEMETRYNoSet to NONE to opt out of usage data collection

Notes

  • headless=False is required when the target site has bot detection, CAPTCHAs, or login requirements -- these cannot be handled in a headless session without additional setup.
  • The agent operates a real browser session. Do not point it at live production accounts without careful review of the objective.
  • LaVague does not bundle its own LLM; it delegates to the configured provider (OpenAI by default). Costs accrue at the provider's token rates.