CoolFace
Apppublic

anu151105/agentic-browser

sourceHugging Facemitupdated 1y agoView on Hugging Face
2likes
USAGE_GUIDE.md304 linesDownload Raw Back to root
1# Enhanced AI Agentic Browser Agent: User Guide2 3This guide provides practical examples of how to use the Enhanced AI Agentic Browser Agent for various automation tasks. No technical background required!4 5## What Can This Agent Do?6 7The Enhanced AI Agentic Browser Agent can help you:8 9- Research topics across multiple websites10- Fill out forms automatically11- Extract structured data from websites12- Monitor websites for changes13- Automate multi-step workflows14- Interact with web applications intelligently15 16## Getting Started: The Basics17 18### Setting Up19 201. **Install the agent**:21   ```bash22   # Clone the repository23   git clone https://github.com/your-org/agentic-browser.git24   cd agentic-browser25 26   # Install dependencies27   pip install -r requirements.txt28 29   # Set up environment variables30   cp .env.example .env31   # Edit .env with your API keys32   ```33 342. **Start the agent server**:35   ```bash36   python run_server.py37   ```38 393. **Access the web interface**: Open your browser and go to `http://localhost:8000`40 41### Your First Task42 43Let's start with a simple example: searching for information about climate change on Wikipedia.44 45#### Using the Web Interface46 471. Navigate to the Web Interface at `http://localhost:8000`482. Click "Create New Task"493. Fill out the task form:50   - **Task Description**: "Search for information about climate change on Wikipedia and summarize the key points."51   - **URLs**: `https://www.wikipedia.org`52   - **Human Assistance**: No (autonomous mode)534. Click "Submit Task"545. Monitor the progress in real-time556. View the results when complete56 57#### Using the API58 59```bash60curl -X POST http://localhost:8000/tasks \61  -H "Content-Type: application/json" \62  -d '{63    "task_description": "Search for information about climate change on Wikipedia and summarize the key points.",64    "urls": ["https://www.wikipedia.org"],65    "human_assisted": false66  }'67```68 69#### Using the Python Client70 71```python72import asyncio73from src.orchestrator import AgentOrchestrator74 75async def run_task():76    # Initialize the orchestrator77    orchestrator = await AgentOrchestrator.initialize()78    79    # Create a task80    task_id = await orchestrator.create_task({81        "task_description": "Search for information about climate change on Wikipedia and summarize the key points.",82        "urls": ["https://www.wikipedia.org"],83        "human_assisted": False84    })85    86    # Execute the task87    await orchestrator.execute_task(task_id)88    89    # Wait for completion and get results90    while True:91        status = await orchestrator.get_task_status(task_id)92        if status["status"] in ["completed", "failed"]:93            print(status)94            break95        await asyncio.sleep(2)96 97# Run the task98asyncio.run(run_task())99```100 101## Common Use Cases with Examples102 103### 1. Data Extraction from Websites104 105**Task**: Extract product information from an e-commerce site.106 107```python108task_config = {109    "task_description": "Extract product names, prices, and ratings from the first page of best-selling laptops on Amazon.",110    "urls": ["https://www.amazon.com/s?k=laptops"],111    "output_format": "table",  # Options: table, json, csv112    "human_assisted": False113}114```115 116**Result Example**:117```118| Product Name                      | Price    | Rating |119|-----------------------------------|----------|--------|120| Acer Aspire 5 Slim Laptop         | $549.99  | 4.5/5  |121| ASUS VivoBook 15 Thin and Light   | $399.99  | 4.3/5  |122| HP 15 Laptop, 11th Gen Intel Core | $645.00  | 4.4/5  |123```124 125### 2. Form Filling with Human Approval126 127**Task**: Fill out a contact form on a website.128 129```python130task_config = {131    "task_description": "Fill out the contact form on the company website with my information and submit it.",132    "urls": ["https://example.com/contact"],133    "human_assisted": True,134    "human_assist_mode": "approval",135    "form_data": {136        "name": "John Doe",137        "email": "john@example.com",138        "message": "I'm interested in your services and would like to schedule a demo."139    }140}141```142 143**Workflow**:1441. Agent navigates to the contact page1452. Identifies all form fields1463. Prepares the data to fill in each field1474. **Requests your approval** before submission1485. Submits the form after approval1496. Confirms successful submission150 151### 3. Multi-Site Research Project152 153**Task**: Research information about electric vehicles from multiple sources.154 155```python156task_config = {157    "task_description": "Research the latest developments in electric vehicles. Focus on battery technology, charging infrastructure, and market growth. Create a comprehensive summary with key points from each source.",158    "urls": [159        "https://en.wikipedia.org/wiki/Electric_vehicle",160        "https://www.caranddriver.com/electric-vehicles/",161        "https://www.energy.gov/eere/electricvehicles/electric-vehicles"162    ],163    "human_assisted": True,164    "human_assist_mode": "review"165}166```167 168**Workflow**:1691. Agent visits each website in sequence1702. Extracts relevant information on the specified topics1713. Compiles data from all sources1724. Organizes information by category1735. Generates a comprehensive summary1746. Presents the results for your review175 176### 4. API Integration Example177 178**Task**: Using direct API calls instead of browser automation.179 180```python181task_config = {182    "task_description": "Get current weather information for New York City and create a summary.",183    "preferred_approach": "api",184    "api_hint": "Use a weather API to get the current conditions",185    "parameters": {186        "location": "New York City",187        "units": "imperial"188    },189    "human_assisted": False190}191```192 193**Result Example**:194```195Current Weather in New York City:196Temperature: 72°F197Conditions: Partly Cloudy198Humidity: 65%199Wind: 8 mph NW200Forecast: Temperatures will remain steady through tomorrow with a 30% chance of rain in the evening.201```202 203### 5. Monitoring a Website for Changes204 205**Task**: Monitor a website for specific changes.206 207```python208task_config = {209    "task_description": "Monitor the company blog for new articles about AI. Check daily and notify me when new content is published.",210    "urls": ["https://company.com/blog"],211    "schedule": {212        "frequency": "daily",213        "time": "09:00"214    },215    "monitoring": {216        "type": "content_change",217        "selector": ".blog-articles",218        "keywords": ["artificial intelligence", "AI", "machine learning"]219    },220    "notifications": {221        "email": "user@example.com"222    }223}224```225 226**Workflow**:2271. Agent visits the blog at scheduled times2282. Captures the current content2293. Compares with previous visits2304. If new AI-related articles are found, sends a notification2315. Provides a summary of the changes232 233## Working with Human Assistance Modes234 235The agent supports four modes of human interaction:236 237### Autonomous Mode238Agent works completely independently with no human interaction.239```python240"human_assisted": False241```242 243### Review Mode244Agent works independently, then presents results for your review.245```python246"human_assisted": True,247"human_assist_mode": "review"248```249 250### Approval Mode251Agent asks for your approval before key actions.252```python253"human_assisted": True,254"human_assist_mode": "approval"255```256 257### Manual Mode258You provide specific instructions for each step.259```python260"human_assisted": True,261"human_assist_mode": "manual"262```263 264## Tips for Best Results265 2661. **Be specific in your task descriptions**: The more detail you provide, the better the agent can understand your goals.267 2682. **Start with URLs**: Always provide starting URLs for web tasks to help the agent begin in the right place.269 2703. **Use human assistance for complex tasks**: For critical or complex tasks, start with human-assisted modes until you're confident in the agent's performance.271 2724. **Check task status regularly**: Monitor long-running tasks to ensure they're progressing as expected.273 2745. **Provide feedback**: When using review mode, provide detailed feedback to help the agent learn and improve.275 276## Troubleshooting Common Issues277 278### Agent can't access a website279- Check if the website requires login credentials280- Verify the website doesn't have anti-bot protections281- Try using a different browser type in the configuration282 283### Form submission fails284- Ensure all required fields are properly identified285- Check if the form has CAPTCHA protection286- Try using approval mode to verify the form data before submission287 288### Results are incomplete289- Make the task description more specific290- Check if pagination is handled properly291- Consider using API mode if available292 293### Agent gets stuck294- Set appropriate timeouts in the task configuration295- Use more specific selectors in your task description296- Try breaking the task into smaller sub-tasks297 298## Need More Help?299 300- Check the detailed [Architecture Flow](ARCHITECTURE_FLOW.md) document301- View the [Visual Flow Guide](VISUAL_FLOW.md) for diagrams302- Explore the [example scripts](examples/) for more use cases303- Refer to the [API Documentation](API.md) for advanced usage304