Skip to content

Commit 2107d66

Browse files
author
Sentience Dev
committed
corrected snapshot
1 parent c452ba0 commit 2107d66

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,30 @@ with SentienceBrowser(headless=False) as browser:
172172
<details>
173173
<summary><h3>📸 Snapshot - Intelligent Page Analysis</h3></summary>
174174

175-
**`snapshot(browser, screenshot=True, show_overlay=False)`** - Capture page state with AI-ranked elements
175+
**`snapshot(browser, options=SnapshotOptions(screenshot=True, show_overlay=False, limit=None, goal=None))`** - Capture page state with AI-ranked elements
176176

177177
Features:
178178
- Returns semantic elements with roles, text, importance scores, and bounding boxes
179-
- Optional screenshot capture (PNG/JPEG)
180-
- Optional visual overlay to see what elements are detected
179+
- Optional screenshot capture (PNG/JPEG) - set `screenshot=True`
180+
- Optional visual overlay to see what elements are detected - set `show_overlay=True`
181181
- Pydantic models for type safety
182+
- Optional ML reranking when `goal` is provided
182183
- **`snapshot.save(filepath)`** - Export to JSON
183184

184185
**Example:**
185186
```python
186-
snap = snapshot(browser, screenshot=True, show_overlay=True)
187+
from sentience import snapshot, SnapshotOptions
188+
189+
# Basic snapshot with defaults (no screenshot, no overlay)
190+
snap = snapshot(browser)
191+
192+
# With screenshot and overlay
193+
snap = snapshot(browser, SnapshotOptions(
194+
screenshot=True,
195+
show_overlay=True,
196+
limit=100,
197+
goal="Click the login button" # Optional: enables ML reranking
198+
))
187199

188200
# Access structured data
189201
print(f"URL: {snap.url}")
@@ -193,6 +205,10 @@ print(f"Elements: {len(snap.elements)}")
193205
# Iterate over elements
194206
for element in snap.elements:
195207
print(f"{element.role}: {element.text} (importance: {element.importance})")
208+
209+
# Check ML reranking metadata (when goal is provided)
210+
if element.rerank_index is not None:
211+
print(f" ML rank: {element.rerank_index} (confidence: {element.ml_probability:.2%})")
196212
```
197213

198214
</details>
@@ -666,7 +682,7 @@ if result.url_changed:
666682
snap = snapshot(browser)
667683

668684
# Slower - with screenshot (for debugging/verification)
669-
snap = snapshot(browser, screenshot=True)
685+
snap = snapshot(browser, SnapshotOptions(screenshot=True))
670686
```
671687

672688
</details>

0 commit comments

Comments
 (0)