integration with CUA (#2126)

This commit is contained in:
Shuchang Zheng
2025-04-11 11:18:53 -07:00
committed by GitHub
parent 2ac65c4a9b
commit f883b91180
13 changed files with 420 additions and 53 deletions

View File

@@ -10,6 +10,7 @@ from skyvern.forge.sdk.core.skyvern_context import SkyvernContext
from skyvern.forge.sdk.schemas.task_v2 import TaskV2Status
from skyvern.forge.sdk.schemas.tasks import TaskStatus
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRunStatus
from skyvern.schemas.runs import RunEngine, RunType
from skyvern.services import task_v2_service
LOG = structlog.get_logger()
@@ -91,6 +92,10 @@ class BackgroundTaskExecutor(AsyncExecutor):
status=TaskStatus.running,
organization_id=organization_id,
)
run_obj = await app.DATABASE.get_run(run_id=task_id, organization_id=organization_id)
engine = RunEngine.skyvern_v1
if run_obj and run_obj.task_run_type == RunType.openai_cua:
engine = RunEngine.openai_cua
context: SkyvernContext = skyvern_context.ensure_context()
context.task_id = task.task_id
@@ -106,6 +111,7 @@ class BackgroundTaskExecutor(AsyncExecutor):
api_key,
close_browser_on_completion=close_browser_on_completion,
browser_session_id=browser_session_id,
engine=engine,
)
async def execute_workflow(

View File

@@ -1465,7 +1465,7 @@ async def run_task(
analytics.capture("skyvern-oss-run-task", data={"url": run_request.url})
await PermissionCheckerFactory.get_instance().check(current_org, browser_session_id=run_request.browser_session_id)
if run_request.engine == RunEngine.skyvern_v1:
if run_request.engine in [RunEngine.skyvern_v1, RunEngine.openai_cua]:
# create task v1
# if there's no url, call task generation first to generate the url, data schema if any
url = run_request.url
@@ -1497,6 +1497,7 @@ async def run_task(
task_v1_response = await task_v1_service.run_task(
task=task_v1_request,
organization=current_org,
engine=run_request.engine,
x_max_steps_override=run_request.max_steps,
x_api_key=x_api_key,
request=request,
@@ -1577,6 +1578,8 @@ async def run_task(
publish_workflow=run_request.publish_workflow,
),
)
if run_request.engine == RunEngine.openai_cua:
pass
raise HTTPException(status_code=400, detail=f"Invalid agent engine: {run_request.engine}")