Skip to content

Commit 2b647f0

Browse files
author
SentienceDEV
committed
include snapshot options in search
1 parent 1a37c27 commit 2b647f0

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

sentience/actions.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .browser import AsyncSentienceBrowser, SentienceBrowser
1111
from .browser_evaluator import BrowserEvaluator
1212
from .cursor_policy import CursorPolicy, build_human_cursor_path
13-
from .models import ActionResult, BBox, Snapshot
13+
from .models import ActionResult, BBox, Snapshot, SnapshotOptions
1414
from .sentience_methods import SentienceMethod
1515
from .snapshot import snapshot, snapshot_async
1616

@@ -809,9 +809,17 @@ def search(
809809
query: str,
810810
engine: str = "duckduckgo",
811811
take_snapshot: bool = False,
812+
snapshot_options: SnapshotOptions | None = None,
812813
) -> ActionResult:
813814
"""
814815
Navigate to a search results page for the given query.
816+
817+
Args:
818+
browser: SentienceBrowser instance
819+
query: Search query string
820+
engine: Search engine name (duckduckgo, google, google.com, bing)
821+
take_snapshot: Whether to take snapshot after navigation
822+
snapshot_options: Snapshot options passed to snapshot() when take_snapshot is True.
815823
"""
816824
if not browser.page:
817825
raise RuntimeError("Browser not started. Call browser.start() first.")
@@ -831,7 +839,7 @@ def search(
831839

832840
snapshot_after: Snapshot | None = None
833841
if take_snapshot:
834-
snapshot_after = snapshot(browser)
842+
snapshot_after = snapshot(browser, snapshot_options)
835843

836844
return ActionResult(
837845
success=True,
@@ -1877,9 +1885,17 @@ async def search_async(
18771885
query: str,
18781886
engine: str = "duckduckgo",
18791887
take_snapshot: bool = False,
1888+
snapshot_options: SnapshotOptions | None = None,
18801889
) -> ActionResult:
18811890
"""
18821891
Async version of search().
1892+
1893+
Args:
1894+
browser: AsyncSentienceBrowser instance
1895+
query: Search query string
1896+
engine: Search engine name (duckduckgo, google, google.com, bing)
1897+
take_snapshot: Whether to take snapshot after navigation
1898+
snapshot_options: Snapshot options passed to snapshot_async() when take_snapshot is True.
18831899
"""
18841900
if not browser.page:
18851901
raise RuntimeError("Browser not started. Call await browser.start() first.")
@@ -1899,7 +1915,7 @@ async def search_async(
18991915

19001916
snapshot_after: Snapshot | None = None
19011917
if take_snapshot:
1902-
snapshot_after = await snapshot_async(browser)
1918+
snapshot_after = await snapshot_async(browser, snapshot_options)
19031919

19041920
return ActionResult(
19051921
success=True,

0 commit comments

Comments
 (0)