SDK: validation action (#4203)
This commit is contained in:
committed by
GitHub
parent
7ef48c32e0
commit
4b99cd3f45
@@ -12,6 +12,7 @@ from skyvern.client import (
|
||||
RunSdkActionRequestAction_Extract,
|
||||
RunSdkActionRequestAction_LocateElement,
|
||||
RunSdkActionRequestAction_Prompt,
|
||||
RunSdkActionRequestAction_Validate,
|
||||
)
|
||||
from skyvern.config import settings
|
||||
from skyvern.core.script_generations.skyvern_page_ai import SkyvernPageAi
|
||||
@@ -176,6 +177,34 @@ class SdkSkyvernPageAi(SkyvernPageAi):
|
||||
self._browser.workflow_run_id = response.workflow_run_id
|
||||
return response.result if response.result else None
|
||||
|
||||
async def ai_validate(
|
||||
self,
|
||||
prompt: str,
|
||||
model: dict[str, Any] | None = None,
|
||||
) -> bool:
|
||||
"""Validate the current page state using AI via API call."""
|
||||
|
||||
LOG.info(
|
||||
"AI validate",
|
||||
prompt=prompt,
|
||||
model=model,
|
||||
workflow_run_id=self._browser.workflow_run_id,
|
||||
)
|
||||
|
||||
response = await self._browser.skyvern.run_sdk_action(
|
||||
url=self._page.url,
|
||||
action=RunSdkActionRequestAction_Validate(
|
||||
prompt=prompt,
|
||||
model=model,
|
||||
),
|
||||
browser_session_id=self._browser.browser_session_id,
|
||||
browser_address=self._browser.browser_address,
|
||||
workflow_run_id=self._browser.workflow_run_id,
|
||||
)
|
||||
self._browser.workflow_run_id = response.workflow_run_id
|
||||
|
||||
return bool(response.result) if response.result is not None else False
|
||||
|
||||
async def ai_act(
|
||||
self,
|
||||
prompt: str,
|
||||
|
||||
Reference in New Issue
Block a user