Skip to content

Commit 6586996

Browse files
authored
allow observe result dict in act (#134)
1 parent 2881428 commit 6586996

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stagehand/page.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async def goto(
104104
return result
105105

106106
async def act(
107-
self, action_or_result: Union[str, ObserveResult], **kwargs
107+
self, action_or_result: Union[str, ObserveResult, dict], **kwargs
108108
) -> ActResult:
109109
"""
110110
Execute an AI action or a pre-observed action via the Stagehand server.
@@ -136,6 +136,10 @@ async def act(
136136
payload = options.model_dump(exclude_none=True, by_alias=True)
137137
elif isinstance(action_or_result, ActOptions):
138138
payload = action_or_result.model_dump(exclude_none=True, by_alias=True)
139+
elif isinstance(action_or_result, dict):
140+
payload = ObserveResult(**action_or_result).model_dump(
141+
exclude_none=True, by_alias=True
142+
)
139143
else:
140144
raise TypeError(
141145
"Invalid arguments for 'act'. Expected str, ObserveResult, or ActOptions."

0 commit comments

Comments
 (0)