mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2026-07-09 16:09:13 +00:00
feat: default /v1/run/tasks engine to v1 (SKY-8566) (#5403)
Co-authored-by: Suchintan Singh <suchintan@skyvern.com>
This commit is contained in:
parent
a63473161b
commit
b727a22c45
5 changed files with 43 additions and 6 deletions
|
|
@ -275,7 +275,7 @@ class Skyvern(AsyncSkyvern):
|
||||||
async def run_task(
|
async def run_task(
|
||||||
self,
|
self,
|
||||||
prompt: str,
|
prompt: str,
|
||||||
engine: RunEngine = RunEngine.skyvern_v2,
|
engine: RunEngine = RunEngine.skyvern_v1,
|
||||||
model: dict[str, Any] | None = None,
|
model: dict[str, Any] | None = None,
|
||||||
url: str | None = None,
|
url: str | None = None,
|
||||||
webhook_url: str | None = None,
|
webhook_url: str | None = None,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class SkyvernBrowserPageAgent:
|
||||||
async def run_task(
|
async def run_task(
|
||||||
self,
|
self,
|
||||||
prompt: str,
|
prompt: str,
|
||||||
engine: RunEngine = RunEngine.skyvern_v2,
|
engine: RunEngine = RunEngine.skyvern_v1,
|
||||||
model: dict[str, Any] | None = None,
|
model: dict[str, Any] | None = None,
|
||||||
url: str | None = None,
|
url: str | None = None,
|
||||||
webhook_url: str | None = None,
|
webhook_url: str | None = None,
|
||||||
|
|
@ -53,7 +53,7 @@ class SkyvernBrowserPageAgent:
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
prompt: Natural language description of the task to perform.
|
prompt: Natural language description of the task to perform.
|
||||||
engine: The execution engine to use. Defaults to skyvern_v2.
|
engine: The execution engine to use. Defaults to skyvern_v1.
|
||||||
model: LLM model configuration options.
|
model: LLM model configuration options.
|
||||||
url: URL to navigate to. If not provided, uses the current page URL.
|
url: URL to navigate to. If not provided, uses the current page URL.
|
||||||
webhook_url: URL to receive webhook notifications about task progress.
|
webhook_url: URL to receive webhook notifications about task progress.
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ The starting URL for the task. If not provided, Skyvern will attempt to determin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
TASK_ENGINE_DOC_STRING = """
|
TASK_ENGINE_DOC_STRING = """
|
||||||
The engine that powers the agent task. The default value is `skyvern-2.0`, the latest Skyvern agent that performs pretty well with complex and multi-step tasks. `skyvern-1.0` is good for simple tasks like filling a form, or searching for information on Google. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
|
The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PROXY_LOCATION_DOC_STRING = """
|
PROXY_LOCATION_DOC_STRING = """
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from enum import StrEnum
|
||||||
from typing import Annotated, Any, Literal, Union
|
from typing import Annotated, Any, Literal, Union
|
||||||
from zoneinfo import ZoneInfo
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||||
|
|
||||||
from skyvern.forge.sdk.schemas.files import FileInfo
|
from skyvern.forge.sdk.schemas.files import FileInfo
|
||||||
from skyvern.forge.sdk.workflow.models.validators import normalize_run_with
|
from skyvern.forge.sdk.workflow.models.validators import normalize_run_with
|
||||||
|
|
@ -382,7 +382,7 @@ class TaskRunRequest(BaseModel):
|
||||||
examples=TASK_URL_EXAMPLES,
|
examples=TASK_URL_EXAMPLES,
|
||||||
)
|
)
|
||||||
engine: RunEngine = Field(
|
engine: RunEngine = Field(
|
||||||
default=RunEngine.skyvern_v2,
|
default=RunEngine.skyvern_v1,
|
||||||
description=TASK_ENGINE_DOC_STRING,
|
description=TASK_ENGINE_DOC_STRING,
|
||||||
)
|
)
|
||||||
title: str | None = Field(
|
title: str | None = Field(
|
||||||
|
|
@ -482,6 +482,12 @@ class TaskRunRequest(BaseModel):
|
||||||
|
|
||||||
return validate_url(url)
|
return validate_url(url)
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def _force_v2_for_publish_workflow(self) -> TaskRunRequest:
|
||||||
|
if self.publish_workflow and self.engine != RunEngine.skyvern_v2:
|
||||||
|
self.engine = RunEngine.skyvern_v2
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class WorkflowRunRequest(BaseModel):
|
class WorkflowRunRequest(BaseModel):
|
||||||
workflow_id: str = Field(
|
workflow_id: str = Field(
|
||||||
|
|
|
||||||
|
|
@ -73,3 +73,34 @@ class TestServiceDefault:
|
||||||
|
|
||||||
sig = inspect.signature(WorkflowService.create_workflow_from_prompt)
|
sig = inspect.signature(WorkflowService.create_workflow_from_prompt)
|
||||||
assert sig.parameters["task_version"].default == "v1"
|
assert sig.parameters["task_version"].default == "v1"
|
||||||
|
|
||||||
|
|
||||||
|
class TestTaskRunRequestEngine:
|
||||||
|
def test_default_engine_is_v1(self) -> None:
|
||||||
|
"""TaskRunRequest.engine must default to skyvern_v1 (skyvern-1.0)."""
|
||||||
|
from skyvern.schemas.runs import RunEngine, TaskRunRequest
|
||||||
|
|
||||||
|
req = TaskRunRequest(prompt="hello")
|
||||||
|
assert req.engine == RunEngine.skyvern_v1
|
||||||
|
|
||||||
|
def test_explicit_v2_engine_preserved(self) -> None:
|
||||||
|
"""Explicitly passing skyvern_v2 should be preserved."""
|
||||||
|
from skyvern.schemas.runs import RunEngine, TaskRunRequest
|
||||||
|
|
||||||
|
req = TaskRunRequest(prompt="hello", engine=RunEngine.skyvern_v2)
|
||||||
|
assert req.engine == RunEngine.skyvern_v2
|
||||||
|
|
||||||
|
def test_publish_workflow_forces_v2(self) -> None:
|
||||||
|
"""publish_workflow=True must force engine to v2, since v1 doesn't support it."""
|
||||||
|
from skyvern.schemas.runs import RunEngine, TaskRunRequest
|
||||||
|
|
||||||
|
req = TaskRunRequest(prompt="hello", publish_workflow=True)
|
||||||
|
assert req.engine == RunEngine.skyvern_v2
|
||||||
|
|
||||||
|
def test_publish_workflow_false_keeps_v1(self) -> None:
|
||||||
|
"""publish_workflow=False (default) should keep the v1 default."""
|
||||||
|
from skyvern.schemas.runs import RunEngine, TaskRunRequest
|
||||||
|
|
||||||
|
req = TaskRunRequest(prompt="hello")
|
||||||
|
assert req.engine == RunEngine.skyvern_v1
|
||||||
|
assert req.publish_workflow is False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue