File size: 9,030 Bytes
24a7f55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# Enhanced AI Agentic Browser Agent: User Guide

This guide provides practical examples of how to use the Enhanced AI Agentic Browser Agent for various automation tasks. No technical background required!

## What Can This Agent Do?

The Enhanced AI Agentic Browser Agent can help you:

- Research topics across multiple websites
- Fill out forms automatically
- Extract structured data from websites
- Monitor websites for changes
- Automate multi-step workflows
- Interact with web applications intelligently

## Getting Started: The Basics

### Setting Up

1. **Install the agent**:
   ```bash
   # Clone the repository
   git clone https://github.com/your-org/agentic-browser.git
   cd agentic-browser

   # Install dependencies
   pip install -r requirements.txt

   # Set up environment variables
   cp .env.example .env
   # Edit .env with your API keys
   ```

2. **Start the agent server**:
   ```bash
   python run_server.py
   ```

3. **Access the web interface**: Open your browser and go to `http://localhost:8000`

### Your First Task

Let's start with a simple example: searching for information about climate change on Wikipedia.

#### Using the Web Interface

1. Navigate to the Web Interface at `http://localhost:8000`
2. Click "Create New Task"
3. Fill out the task form:
   - **Task Description**: "Search for information about climate change on Wikipedia and summarize the key points."
   - **URLs**: `https://www.wikipedia.org`
   - **Human Assistance**: No (autonomous mode)
4. Click "Submit Task"
5. Monitor the progress in real-time
6. View the results when complete

#### Using the API

```bash
curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "task_description": "Search for information about climate change on Wikipedia and summarize the key points.",
    "urls": ["https://www.wikipedia.org"],
    "human_assisted": false
  }'
```

#### Using the Python Client

```python
import asyncio
from src.orchestrator import AgentOrchestrator

async def run_task():
    # Initialize the orchestrator
    orchestrator = await AgentOrchestrator.initialize()
    
    # Create a task
    task_id = await orchestrator.create_task({
        "task_description": "Search for information about climate change on Wikipedia and summarize the key points.",
        "urls": ["https://www.wikipedia.org"],
        "human_assisted": False
    })
    
    # Execute the task
    await orchestrator.execute_task(task_id)
    
    # Wait for completion and get results
    while True:
        status = await orchestrator.get_task_status(task_id)
        if status["status"] in ["completed", "failed"]:
            print(status)
            break
        await asyncio.sleep(2)

# Run the task
asyncio.run(run_task())
```

## Common Use Cases with Examples

### 1. Data Extraction from Websites

**Task**: Extract product information from an e-commerce site.

```python
task_config = {
    "task_description": "Extract product names, prices, and ratings from the first page of best-selling laptops on Amazon.",
    "urls": ["https://www.amazon.com/s?k=laptops"],
    "output_format": "table",  # Options: table, json, csv
    "human_assisted": False
}
```

**Result Example**:
```
| Product Name                      | Price    | Rating |
|-----------------------------------|----------|--------|
| Acer Aspire 5 Slim Laptop         | $549.99  | 4.5/5  |
| ASUS VivoBook 15 Thin and Light   | $399.99  | 4.3/5  |
| HP 15 Laptop, 11th Gen Intel Core | $645.00  | 4.4/5  |
```

### 2. Form Filling with Human Approval

**Task**: Fill out a contact form on a website.

```python
task_config = {
    "task_description": "Fill out the contact form on the company website with my information and submit it.",
    "urls": ["https://example.com/contact"],
    "human_assisted": True,
    "human_assist_mode": "approval",
    "form_data": {
        "name": "John Doe",
        "email": "john@example.com",
        "message": "I'm interested in your services and would like to schedule a demo."
    }
}
```

**Workflow**:
1. Agent navigates to the contact page
2. Identifies all form fields
3. Prepares the data to fill in each field
4. **Requests your approval** before submission
5. Submits the form after approval
6. Confirms successful submission

### 3. Multi-Site Research Project

**Task**: Research information about electric vehicles from multiple sources.

```python
task_config = {
    "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.",
    "urls": [
        "https://en.wikipedia.org/wiki/Electric_vehicle",
        "https://www.caranddriver.com/electric-vehicles/",
        "https://www.energy.gov/eere/electricvehicles/electric-vehicles"
    ],
    "human_assisted": True,
    "human_assist_mode": "review"
}
```

**Workflow**:
1. Agent visits each website in sequence
2. Extracts relevant information on the specified topics
3. Compiles data from all sources
4. Organizes information by category
5. Generates a comprehensive summary
6. Presents the results for your review

### 4. API Integration Example

**Task**: Using direct API calls instead of browser automation.

```python
task_config = {
    "task_description": "Get current weather information for New York City and create a summary.",
    "preferred_approach": "api",
    "api_hint": "Use a weather API to get the current conditions",
    "parameters": {
        "location": "New York City",
        "units": "imperial"
    },
    "human_assisted": False
}
```

**Result Example**:
```
Current Weather in New York City:
Temperature: 72°F
Conditions: Partly Cloudy
Humidity: 65%
Wind: 8 mph NW
Forecast: Temperatures will remain steady through tomorrow with a 30% chance of rain in the evening.
```

### 5. Monitoring a Website for Changes

**Task**: Monitor a website for specific changes.

```python
task_config = {
    "task_description": "Monitor the company blog for new articles about AI. Check daily and notify me when new content is published.",
    "urls": ["https://company.com/blog"],
    "schedule": {
        "frequency": "daily",
        "time": "09:00"
    },
    "monitoring": {
        "type": "content_change",
        "selector": ".blog-articles",
        "keywords": ["artificial intelligence", "AI", "machine learning"]
    },
    "notifications": {
        "email": "user@example.com"
    }
}
```

**Workflow**:
1. Agent visits the blog at scheduled times
2. Captures the current content
3. Compares with previous visits
4. If new AI-related articles are found, sends a notification
5. Provides a summary of the changes

## Working with Human Assistance Modes

The agent supports four modes of human interaction:

### Autonomous Mode
Agent works completely independently with no human interaction.
```python
"human_assisted": False
```

### Review Mode
Agent works independently, then presents results for your review.
```python
"human_assisted": True,
"human_assist_mode": "review"
```

### Approval Mode
Agent asks for your approval before key actions.
```python
"human_assisted": True,
"human_assist_mode": "approval"
```

### Manual Mode
You provide specific instructions for each step.
```python
"human_assisted": True,
"human_assist_mode": "manual"
```

## Tips for Best Results

1. **Be specific in your task descriptions**: The more detail you provide, the better the agent can understand your goals.

2. **Start with URLs**: Always provide starting URLs for web tasks to help the agent begin in the right place.

3. **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.

4. **Check task status regularly**: Monitor long-running tasks to ensure they're progressing as expected.

5. **Provide feedback**: When using review mode, provide detailed feedback to help the agent learn and improve.

## Troubleshooting Common Issues

### Agent can't access a website
- Check if the website requires login credentials
- Verify the website doesn't have anti-bot protections
- Try using a different browser type in the configuration

### Form submission fails
- Ensure all required fields are properly identified
- Check if the form has CAPTCHA protection
- Try using approval mode to verify the form data before submission

### Results are incomplete
- Make the task description more specific
- Check if pagination is handled properly
- Consider using API mode if available

### Agent gets stuck
- Set appropriate timeouts in the task configuration
- Use more specific selectors in your task description
- Try breaking the task into smaller sub-tasks

## Need More Help?

- Check the detailed [Architecture Flow](ARCHITECTURE_FLOW.md) document
- View the [Visual Flow Guide](VISUAL_FLOW.md) for diagrams
- Explore the [example scripts](examples/) for more use cases
- Refer to the [API Documentation](API.md) for advanced usage