add SKYVERN_APP_URL and a link to the run response (#2316)

This commit is contained in:
Shuchang Zheng
2025-05-10 00:40:54 -07:00
committed by GitHub
parent 0a447ac511
commit 54fba3a550
4 changed files with 11 additions and 0 deletions

View File

@@ -257,6 +257,7 @@ class Settings(BaseSettings):
TASK_BLOCKED_SITE_FALLBACK_URL: str = "https://www.google.com"
SKYVERN_APP_URL: str = "http://localhost:8080"
# SkyvernClient Settings
SKYVERN_BASE_URL: str = "https://api.skyvern.com"
SKYVERN_API_KEY: str = "PLACEHOLDER"

View File

@@ -1523,6 +1523,7 @@ async def run_task(
failure_reason=task_v1_response.failure_reason,
created_at=task_v1_response.created_at,
modified_at=task_v1_response.modified_at,
app_url=f"{settings.SKYVERN_APP_URL.rstrip('/')}/tasks/{task_v1_response.task_id}",
run_request=TaskRunRequest(
engine=run_request.engine,
prompt=task_v1_response.navigation_goal,
@@ -1566,6 +1567,10 @@ async def run_task(
max_steps_override=run_request.max_steps,
browser_session_id=run_request.browser_session_id,
)
refreshed_task_v2 = await app.DATABASE.get_task_v2(
task_v2_id=task_v2.observer_cruise_id, organization_id=current_org.organization_id
)
task_v2 = refreshed_task_v2 if refreshed_task_v2 else task_v2
return TaskRunResponse(
run_id=task_v2.observer_cruise_id,
run_type=RunType.task_v2,
@@ -1574,6 +1579,7 @@ async def run_task(
failure_reason=None,
created_at=task_v2.created_at,
modified_at=task_v2.modified_at,
app_url=f"{settings.SKYVERN_APP_URL.rstrip('/')}/{task_v2.workflow_permanent_id}/{task_v2.workflow_run_id}",
run_request=TaskRunRequest(
engine=RunEngine.skyvern_v2,
prompt=task_v2.prompt,

View File

@@ -286,6 +286,7 @@ class BaseRunResponse(BaseModel):
failure_reason: str | None = Field(default=None, description="Reason for failure if the run failed")
created_at: datetime = Field(description="Timestamp when this run was created")
modified_at: datetime = Field(description="Timestamp when this run was last modified")
app_url: str | None = Field(default=None, description="URL to the application UI where the run can be viewed")
class TaskRunResponse(BaseRunResponse):

View File

@@ -1,5 +1,6 @@
from fastapi import HTTPException, status
from skyvern.config import settings
from skyvern.exceptions import TaskNotFound, WorkflowRunNotFound
from skyvern.forge import app
from skyvern.forge.sdk.schemas.tasks import TaskStatus
@@ -35,6 +36,7 @@ async def get_run_response(run_id: str, organization_id: str | None = None) -> R
failure_reason=task_v1.failure_reason,
created_at=task_v1.created_at,
modified_at=task_v1.modified_at,
app_url=f"{settings.SKYVERN_APP_URL.rstrip('/')}/tasks/{task_v1.task_id}",
run_request=TaskRunRequest(
engine=run_engine,
prompt=task_v1.navigation_goal,
@@ -63,6 +65,7 @@ async def get_run_response(run_id: str, organization_id: str | None = None) -> R
failure_reason=workflow_run.failure_reason if workflow_run else None,
created_at=task_v2.created_at,
modified_at=task_v2.modified_at,
app_url=f"{settings.SKYVERN_APP_URL.rstrip('/')}/{task_v2.workflow_permanent_id}/{task_v2.workflow_run_id}",
run_request=TaskRunRequest(
engine=RunEngine.skyvern_v2,
prompt=task_v2.prompt,