Spaces:
Paused
Paused
Replace README with app manifest frontmatter
Browse files
README.md
CHANGED
|
@@ -1,231 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
## Tech Stack
|
| 12 |
-
|
| 13 |
-
- **Agent**: [smolagents](https://huggingface.co/docs/smolagents/examples/web_browser) with a vision-language model
|
| 14 |
-
- **Backend**: FastAPI (async via `anyio.to_thread`)
|
| 15 |
-
- **Database**: DuckDB (persists all task results)
|
| 16 |
-
- **Browser**: Selenium + Helium (headless Chrome)
|
| 17 |
-
- **Python**: 3.11+
|
| 18 |
-
|
| 19 |
-
## Project Structure
|
| 20 |
-
|
| 21 |
-
```
|
| 22 |
-
app/
|
| 23 |
-
├── main.py # FastAPI app with lifespan (DB init/cleanup)
|
| 24 |
-
├── agent/
|
| 25 |
-
│ ├── browser.py # Agent setup, Chrome driver, async task runner
|
| 26 |
-
│ ├── tools.py # Browser tools (search, go_back, close_popups)
|
| 27 |
-
│ └── prompts.py # Agent instructions and prompt templates
|
| 28 |
-
├── api/
|
| 29 |
-
│ └── routes.py # POST /api/browse, GET /api/results, dashboard endpoints
|
| 30 |
-
└── core/
|
| 31 |
-
├── config.py # Settings from .env (pydantic-settings)
|
| 32 |
-
├── db.py # DuckDB connection and queries
|
| 33 |
-
├── models.py # Pydantic request/response models
|
| 34 |
-
└── scoring.py # Scoring formulas and weights
|
| 35 |
-
frontend/
|
| 36 |
-
└── index.html # Single-file dashboard UI
|
| 37 |
-
tests/
|
| 38 |
-
├── conftest.py # TestClient fixture with in-memory DB
|
| 39 |
-
└── test_api.py # API endpoint tests
|
| 40 |
-
```
|
| 41 |
-
|
| 42 |
-
## Setup
|
| 43 |
-
|
| 44 |
-
### Prerequisites
|
| 45 |
-
|
| 46 |
-
- Python 3.11+
|
| 47 |
-
- [uv](https://docs.astral.sh/uv/) package manager
|
| 48 |
-
- Chrome/Chromium installed
|
| 49 |
-
- An OpenAI-compatible VLM endpoint (or HuggingFace Inference API)
|
| 50 |
-
|
| 51 |
-
### Install
|
| 52 |
-
|
| 53 |
-
```bash
|
| 54 |
-
uv sync
|
| 55 |
-
```
|
| 56 |
-
|
| 57 |
-
### Configure
|
| 58 |
-
|
| 59 |
-
Create a `.env` file in the project root:
|
| 60 |
-
|
| 61 |
-
```env
|
| 62 |
-
MODEL_ID=google/gemma-4-31B-it
|
| 63 |
-
MODEL_API_KEY=your_api_key
|
| 64 |
-
MODEL_BASE_URL=https://your-model-endpoint/v1
|
| 65 |
-
|
| 66 |
-
DEBUG=true
|
| 67 |
-
DATABASE_PATH=data/browser.duckdb
|
| 68 |
-
AGENT_MAX_STEPS=20
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
### Run
|
| 72 |
-
|
| 73 |
-
```bash
|
| 74 |
-
uv run uvicorn app.main:app --reload
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
Then open [http://localhost:8000](http://localhost:8000) to access the dashboard.
|
| 78 |
-
|
| 79 |
-
## API
|
| 80 |
-
|
| 81 |
-
### `POST /api/browse`
|
| 82 |
-
|
| 83 |
-
Submit a URL and a list of tasks for the agent to perform. Returns immediately with a `job_id` — tasks run asynchronously in the background.
|
| 84 |
-
|
| 85 |
-
**Request:**
|
| 86 |
-
```json
|
| 87 |
-
{
|
| 88 |
-
"url": "https://www.netflix.com",
|
| 89 |
-
"tasks": ["Find the available subscription plans and their prices"]
|
| 90 |
-
}
|
| 91 |
-
```
|
| 92 |
-
|
| 93 |
-
**Response:**
|
| 94 |
-
```json
|
| 95 |
-
{
|
| 96 |
-
"job_id": "a1b2c3d4e5f6",
|
| 97 |
-
"status": "running"
|
| 98 |
-
}
|
| 99 |
-
```
|
| 100 |
-
|
| 101 |
-
### `GET /api/jobs/{job_id}`
|
| 102 |
-
|
| 103 |
-
Poll for job status and results.
|
| 104 |
-
|
| 105 |
-
### `GET /api/jobs`
|
| 106 |
-
|
| 107 |
-
List all jobs, newest first.
|
| 108 |
-
|
| 109 |
-
### `GET /api/results`
|
| 110 |
-
|
| 111 |
-
Query stored results. Optionally filter by URL.
|
| 112 |
-
|
| 113 |
-
```
|
| 114 |
-
GET /api/results?url=https://www.netflix.com/&limit=10
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
### `GET /api/dashboard`
|
| 118 |
-
|
| 119 |
-
Aggregated stats across all runs: average scores, per-URL breakdown, top issues, and recommendations.
|
| 120 |
-
|
| 121 |
-
### `GET /api/performance?url=...`
|
| 122 |
-
|
| 123 |
-
Detailed performance breakdown for a single URL, including all individual runs.
|
| 124 |
-
|
| 125 |
-
### `GET /api/urls`
|
| 126 |
-
|
| 127 |
-
List all distinct URLs that have been tested.
|
| 128 |
-
|
| 129 |
-
### `GET /health`
|
| 130 |
-
|
| 131 |
-
Health check endpoint.
|
| 132 |
-
|
| 133 |
-
## Scoring
|
| 134 |
-
|
| 135 |
-
Each agent run produces an **Agent Readiness Score** — a composite metric reflecting how well an agent can navigate and extract information from the target site. The score is computed across five dimensions, each rated 0.0–1.0, then combined via weighted average.
|
| 136 |
-
|
| 137 |
-
### Dimensions
|
| 138 |
-
|
| 139 |
-
| Dimension | Weight | Formula |
|
| 140 |
-
|---|---|---|
|
| 141 |
-
| **Completeness** | 30% | `1.0` if the information was found, `0.0` otherwise. |
|
| 142 |
-
| **Confidence** | 25% | The agent's self-reported certainty (0.0–1.0), clamped to that range. |
|
| 143 |
-
| **Efficiency** | 15% | `1.0 - (steps_taken - 1) / (max_steps - 1)`. 1 step = perfect, max steps = 0. |
|
| 144 |
-
| **Speed** | 10% | `1.0` if under 60s. Above 60s, scales linearly to `0.0` at 300s. |
|
| 145 |
-
| **Reliability** | 20% | `1.0 - (errors * 0.25)`. Each code execution error costs 0.25. Capped at 0.5 if the task failed. |
|
| 146 |
-
|
| 147 |
-
**Overall Score** = `0.30 * completeness + 0.25 * confidence + 0.20 * reliability + 0.15 * efficiency + 0.10 * speed`
|
| 148 |
-
|
| 149 |
-
### Confidence Scoring
|
| 150 |
-
|
| 151 |
-
The confidence score is self-reported by the LLM. The agent is prompted to rate its certainty based on how clearly the information was visible on the page:
|
| 152 |
-
|
| 153 |
-
| Range | Meaning |
|
| 154 |
-
|---|---|
|
| 155 |
-
| 0.9–1.0 | Information clearly visible, directly matches the task |
|
| 156 |
-
| 0.7–0.8 | Information found but may be incomplete or partially inferred |
|
| 157 |
-
| 0.4–0.6 | Information is ambiguous, possibly outdated, or required guessing |
|
| 158 |
-
| 0.1–0.3 | Very uncertain, could not verify the information |
|
| 159 |
-
|
| 160 |
-
If the agent cannot find the information at all, it returns `NOT_FOUND` with a reason, and the run scores 0 for both completeness and confidence.
|
| 161 |
-
|
| 162 |
-
### Dashboard Insights
|
| 163 |
-
|
| 164 |
-
The dashboard automatically analyzes run data to surface:
|
| 165 |
-
|
| 166 |
-
- **Overall Agent Readiness Score**: The composite weighted score across all runs.
|
| 167 |
-
- **Top Issues Identified**: Key friction points like high failure rates, low confidence, excessive steps, slow runs, or frequent code errors — ranked by severity (high/medium/low).
|
| 168 |
-
- **Recommendations for Improvement**: Actionable suggestions based on the identified issues, such as improving task prompts, testing on simpler pages first, or addressing agent-unfriendly page patterns.
|
| 169 |
-
- **Per-URL Performance**: Select any tested URL to see its score breakdown, radar chart, and individual run details with expandable step-by-step agent reasoning.
|
| 170 |
-
|
| 171 |
-
### Step-Level Traceability
|
| 172 |
-
|
| 173 |
-
Each run stores per-step details: the agent's reasoning, the code it executed, its observations, and any errors. This enables debugging why a particular run failed or scored low.
|
| 174 |
-
|
| 175 |
-
## Concurrency & Safety
|
| 176 |
-
|
| 177 |
-
- **Browser lock**: Only one agent task runs at a time. Concurrent requests queue with a 5-minute timeout to prevent resource conflicts on the shared headless Chrome instance.
|
| 178 |
-
- **Request validation**: Maximum 10 tasks per request, no empty tasks allowed.
|
| 179 |
-
- **Timeout**: Agent tasks are bounded by `AGENT_MAX_STEPS` (default 20) and a 300-second wall-clock limit.
|
| 180 |
-
- **Browser crash recovery**: The browser is always killed in a `finally` block, with exception handling to prevent cleanup failures from propagating.
|
| 181 |
-
|
| 182 |
-
## Limitations
|
| 183 |
-
|
| 184 |
-
### CAPTCHAs and Bot Detection
|
| 185 |
-
|
| 186 |
-
The agent runs in a headless Chrome browser and **cannot solve CAPTCHAs** (reCAPTCHA, hCaptcha, Cloudflare Turnstile, etc.). Sites that gate content behind CAPTCHAs will cause the agent to fail or return `NOT_FOUND`. Similarly, aggressive bot-detection mechanisms (browser fingerprinting, Cloudflare "checking your browser" interstitials) may block the agent before it can interact with the page at all.
|
| 187 |
-
|
| 188 |
-
### Login-Protected Content
|
| 189 |
-
|
| 190 |
-
The agent is explicitly instructed not to log in to websites. Any content behind authentication walls — account dashboards, gated pricing pages, members-only documentation — is inaccessible.
|
| 191 |
-
|
| 192 |
-
### Dynamic and JavaScript-Heavy Pages
|
| 193 |
-
|
| 194 |
-
While the agent uses a full browser and can handle JavaScript rendering, heavily dynamic pages (single-page apps with complex client-side routing, infinite scroll, lazy-loaded content) may reduce confidence and efficiency. The agent relies on screenshots and visible text, so content that requires specific user interactions to reveal (hover menus, accordion panels) may be missed.
|
| 195 |
-
|
| 196 |
-
### Single-Browser Bottleneck
|
| 197 |
-
|
| 198 |
-
Only one agent task runs at a time due to the shared headless Chrome instance. Submitting many tasks or URLs will result in serial execution. Tasks queued for more than 5 minutes will time out.
|
| 199 |
-
|
| 200 |
-
### Confidence Is Self-Reported
|
| 201 |
-
|
| 202 |
-
The confidence score comes from the LLM's own assessment, not from an independent verification. The agent may be overconfident about incorrect answers or underconfident about correct ones.
|
| 203 |
-
|
| 204 |
-
## Deployment
|
| 205 |
-
|
| 206 |
-
### Docker
|
| 207 |
-
|
| 208 |
-
```bash
|
| 209 |
-
docker build -t agentic-web-browser .
|
| 210 |
-
docker run -p 7860:7860 \
|
| 211 |
-
-e MODEL_ID=google/gemma-4-31B-it \
|
| 212 |
-
-e MODEL_API_KEY=your_api_key \
|
| 213 |
-
-e MODEL_BASE_URL=https://your-model-endpoint/v1 \
|
| 214 |
-
agentic-web-browser
|
| 215 |
-
```
|
| 216 |
-
|
| 217 |
-
To persist DuckDB data across restarts, mount the data directory:
|
| 218 |
-
|
| 219 |
-
```bash
|
| 220 |
-
docker run -p 7860:7860 -v $(pwd)/data:/app/data \
|
| 221 |
-
-e MODEL_ID=... -e MODEL_API_KEY=... -e MODEL_BASE_URL=... \
|
| 222 |
-
agentic-web-browser
|
| 223 |
-
```
|
| 224 |
-
|
| 225 |
-
## Testing
|
| 226 |
-
|
| 227 |
-
```bash
|
| 228 |
-
uv run pytest tests/ -v
|
| 229 |
-
```
|
| 230 |
-
|
| 231 |
-
Tests use an in-memory DuckDB and mock the agent, so no Chrome or model endpoint is needed.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Agentic Web Browser
|
| 3 |
+
emoji: 🌐
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: cyan
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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