Skip to content

Commit 89e58f8

Browse files
author
SentienceDEV
committed
fix bad code
1 parent ad6c8ba commit 89e58f8

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

examples/show_grid_examples.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def main():
1616
# Get API key from environment variable (optional - uses free tier if not set)
1717
api_key = os.environ.get("SENTIENCE_API_KEY")
18-
18+
1919
# Use VPS IP directly if domain is not configured
2020
# Replace with your actual domain once DNS is set up: api_url="https://api.sentienceapi.com"
2121
api_url = os.environ.get("SENTIENCE_API_URL", "http://15.204.243.91:9000")
@@ -43,18 +43,23 @@ def main():
4343
if grids:
4444
print(f"✅ Found {len(grids)} grids:")
4545
for grid in grids:
46-
print(f" Grid {grid.grid_id}: {grid.item_count} items, "
47-
f"{grid.row_count}x{grid.col_count} rows/cols, "
48-
f"label: {grid.label or 'none'}")
49-
46+
print(
47+
f" Grid {grid.grid_id}: {grid.item_count} items, "
48+
f"{grid.row_count}x{grid.col_count} rows/cols, "
49+
f"label: {grid.label or 'none'}"
50+
)
51+
5052
# Highlight the first grid in red
5153
if len(grids) > 0:
5254
target_grid_id = grids[0].grid_id
5355
print(f"\n Highlighting Grid {target_grid_id} in red...")
54-
snap = snapshot(browser, SnapshotOptions(
55-
show_grid=True,
56-
grid_id=target_grid_id # This grid will be highlighted in red
57-
))
56+
snap = snapshot(
57+
browser,
58+
SnapshotOptions(
59+
show_grid=True,
60+
grid_id=target_grid_id, # This grid will be highlighted in red
61+
),
62+
)
5863
time.sleep(6) # Wait to see the overlay
5964
else:
6065
print(" ⚠️ No grids detected on this page")
@@ -65,17 +70,20 @@ def main():
6570
# Find and highlight the dominant grid
6671
grids = snap.get_grid_bounds()
6772
dominant_grid = next((g for g in grids if g.is_dominant), None)
68-
73+
6974
if dominant_grid:
7075
print(f"✅ Dominant group detected: Grid {dominant_grid.grid_id}")
7176
print(f" Label: {dominant_grid.label or 'none'}")
7277
print(f" Items: {dominant_grid.item_count}")
7378
print(f" Size: {dominant_grid.row_count}x{dominant_grid.col_count}")
7479
print(f"\n Highlighting dominant grid in red...")
75-
snap = snapshot(browser, SnapshotOptions(
76-
show_grid=True,
77-
grid_id=dominant_grid.grid_id # Highlight dominant grid in red
78-
))
80+
snap = snapshot(
81+
browser,
82+
SnapshotOptions(
83+
show_grid=True,
84+
grid_id=dominant_grid.grid_id, # Highlight dominant grid in red
85+
),
86+
)
7987
time.sleep(6) # Wait to see the overlay
8088
else:
8189
print(" ⚠️ No dominant group detected")
@@ -84,10 +92,13 @@ def main():
8492
print("Example 4: Combine element overlay and grid overlay")
8593
print("=" * 60)
8694
# Show both element borders and grid borders simultaneously
87-
snap = snapshot(browser, SnapshotOptions(
88-
show_overlay=True, # Show element borders (green/blue/red)
89-
show_grid=True # Show grid borders (purple/orange/red)
90-
))
95+
snap = snapshot(
96+
browser,
97+
SnapshotOptions(
98+
show_overlay=True, # Show element borders (green/blue/red)
99+
show_grid=True, # Show grid borders (purple/orange/red)
100+
),
101+
)
91102
print("✅ Both overlays are now visible:")
92103
print(" - Element borders: Green (regular), Blue (primary), Red (target)")
93104
print(" - Grid borders: Purple (regular), Orange (dominant), Red (target)")
@@ -105,15 +116,18 @@ def main():
105116
print(f" Label: {grid.label or 'none'}")
106117
print(f" Items: {grid.item_count}")
107118
print(f" Size: {grid.row_count} rows × {grid.col_count} cols")
108-
print(f" BBox: ({grid.bbox.x:.0f}, {grid.bbox.y:.0f}) "
109-
f"{grid.bbox.width:.0f}×{grid.bbox.height:.0f}")
119+
print(
120+
f" BBox: ({grid.bbox.x:.0f}, {grid.bbox.y:.0f}) "
121+
f"{grid.bbox.width:.0f}×{grid.bbox.height:.0f}"
122+
)
110123
print(f" Confidence: {grid.confidence}")
111124

112125
print("\n✅ All examples completed!")
113126

114127
except Exception as e:
115128
print(f"❌ Error: {e}")
116129
import traceback
130+
117131
traceback.print_exc()
118132

119133

sentience/agent_runtime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ def assert_done(
343343
True if task is complete (assertion passed), False otherwise
344344
"""
345345
ok = self.assertTrue(predicate, label=label, required=True)
346-
347346
if ok:
348347
self._task_done = True
349348
self._task_done_label = label

0 commit comments

Comments
 (0)