SDK: more logs & small fixes (#3945)

This commit is contained in:
Stanislav Novosad
2025-11-10 15:53:39 -07:00
committed by GitHub
parent e3cd3eeae0
commit 6319847709
3 changed files with 37 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import asyncio
from typing import TYPE_CHECKING, Any
import structlog
from playwright.async_api import Page
from skyvern.client import GetRunResponse
@@ -15,6 +16,8 @@ if TYPE_CHECKING:
from skyvern.schemas.run_blocks import CredentialType
from skyvern.schemas.runs import RunEngine, RunStatus, TaskRunResponse
LOG = structlog.get_logger()
class SkyvernPageRun:
"""Provides methods to run Skyvern tasks and workflows in the context of a browser page.
@@ -66,6 +69,9 @@ class SkyvernPageRun:
"""
await self._browser.sdk.ensure_has_server()
LOG.info("AI run task", prompt=prompt)
task_run = await self._browser.client.run_task(
prompt=prompt,
engine=engine,
@@ -125,6 +131,9 @@ class SkyvernPageRun:
"""
await self._browser.sdk.ensure_has_server()
LOG.info("AI login", prompt=prompt)
workflow_run = await self._browser.client.login(
credential_type=credential_type,
url=url or self._get_page_url(),
@@ -173,6 +182,9 @@ class SkyvernPageRun:
"""
await self._browser.sdk.ensure_has_server()
LOG.info("AI run workflow", workflow_id=workflow_id)
workflow_run = await self._browser.client.run_workflow(
workflow_id=workflow_id,
parameters=parameters,

View File

@@ -1,5 +1,6 @@
from typing import TYPE_CHECKING, Any
import structlog
from playwright.async_api import Page
from skyvern.client import (
@@ -16,6 +17,8 @@ from skyvern.core.script_generations.skyvern_page_ai import SkyvernPageAi
if TYPE_CHECKING:
from skyvern.library.skyvern_browser import SkyvernBrowser
LOG = structlog.get_logger()
class SdkSkyvernPageAi(SkyvernPageAi):
"""Implementation of SkyvernPageAi that makes API calls to the server."""
@@ -38,6 +41,9 @@ class SdkSkyvernPageAi(SkyvernPageAi):
"""Click an element using AI via API call."""
await self._browser.sdk.ensure_has_server()
LOG.info("AI click", intention=intention, workflow_run_id=self._browser.workflow_run_id)
response = await self._browser.client.run_sdk_action(
url=self._page.url,
browser_session_id=self._browser.browser_session_id,
@@ -66,6 +72,9 @@ class SdkSkyvernPageAi(SkyvernPageAi):
"""Input text into an element using AI via API call."""
await self._browser.sdk.ensure_has_server()
LOG.info("AI input text", intention=intention, workflow_run_id=self._browser.workflow_run_id)
response = await self._browser.client.run_sdk_action(
url=self._page.url,
action=RunSdkActionRequestAction_AiInputText(
@@ -95,6 +104,9 @@ class SdkSkyvernPageAi(SkyvernPageAi):
"""Select an option from a dropdown using AI via API call."""
await self._browser.sdk.ensure_has_server()
LOG.info("AI select option", intention=intention, workflow_run_id=self._browser.workflow_run_id)
response = await self._browser.client.run_sdk_action(
url=self._page.url,
action=RunSdkActionRequestAction_AiSelectOption(
@@ -123,6 +135,9 @@ class SdkSkyvernPageAi(SkyvernPageAi):
"""Upload a file using AI via API call."""
await self._browser.sdk.ensure_has_server()
LOG.info("AI upload file", intention=intention, workflow_run_id=self._browser.workflow_run_id)
response = await self._browser.client.run_sdk_action(
url=self._page.url,
action=RunSdkActionRequestAction_AiUploadFile(
@@ -150,6 +165,9 @@ class SdkSkyvernPageAi(SkyvernPageAi):
"""Extract information from the page using AI via API call."""
await self._browser.sdk.ensure_has_server()
LOG.info("AI extract", prompt=prompt, workflow_run_id=self._browser.workflow_run_id)
response = await self._browser.client.run_sdk_action(
url=self._page.url,
action=RunSdkActionRequestAction_Extract(
@@ -173,6 +191,9 @@ class SdkSkyvernPageAi(SkyvernPageAi):
"""Perform an action on the page using AI via API call."""
await self._browser.sdk.ensure_has_server()
LOG.info("AI act", prompt=prompt, workflow_run_id=self._browser.workflow_run_id)
response = await self._browser.client.run_sdk_action(
url=self._page.url,
action=RunSdkActionRequestAction_AiAct(

View File

@@ -30,6 +30,10 @@ class LoginRequest(BaseModel):
description="ID of the browser session to use, which is prefixed by `pbs_` e.g. `pbs_123456`",
examples=["pbs_123456"],
)
browser_profile_id: str | None = Field(
default=None,
description="ID of a browser profile to reuse for this run",
)
browser_address: str | None = Field(
default=None,
description="The CDP address for the task.",