add new workflow block (#1228)
This commit is contained in:
@@ -10,7 +10,7 @@ from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
||||
from skyvern.config import settings
|
||||
from skyvern.exceptions import WorkflowParameterNotFound
|
||||
from skyvern.forge.sdk.artifact.models import Artifact, ArtifactType
|
||||
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
|
||||
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType, TaskPromptTemplate
|
||||
from skyvern.forge.sdk.db.exceptions import NotFoundError
|
||||
from skyvern.forge.sdk.db.models import (
|
||||
ActionModel,
|
||||
@@ -97,6 +97,8 @@ class AgentDB:
|
||||
self,
|
||||
url: str,
|
||||
title: str | None,
|
||||
complete_criterion: str | None,
|
||||
terminate_criterion: str | None,
|
||||
navigation_goal: str | None,
|
||||
data_extraction_goal: str | None,
|
||||
navigation_payload: dict[str, Any] | list | str | None,
|
||||
@@ -111,17 +113,21 @@ class AgentDB:
|
||||
retry: int | None = None,
|
||||
max_steps_per_run: int | None = None,
|
||||
error_code_mapping: dict[str, str] | None = None,
|
||||
prompt_template: str = TaskPromptTemplate.ExtractAction,
|
||||
) -> Task:
|
||||
try:
|
||||
async with self.Session() as session:
|
||||
new_task = TaskModel(
|
||||
status="created",
|
||||
prompt_template=prompt_template,
|
||||
url=url,
|
||||
title=title,
|
||||
webhook_callback_url=webhook_callback_url,
|
||||
totp_verification_url=totp_verification_url,
|
||||
totp_identifier=totp_identifier,
|
||||
navigation_goal=navigation_goal,
|
||||
complete_criterion=complete_criterion,
|
||||
terminate_criterion=terminate_criterion,
|
||||
data_extraction_goal=data_extraction_goal,
|
||||
navigation_payload=navigation_payload,
|
||||
organization_id=organization_id,
|
||||
|
||||
@@ -3,3 +3,19 @@ from enum import StrEnum
|
||||
|
||||
class OrganizationAuthTokenType(StrEnum):
|
||||
api = "api"
|
||||
|
||||
|
||||
class TaskPromptTemplate(StrEnum):
|
||||
ExtractAction = "extract-action"
|
||||
DecisiveCriterionValidate = "decisive-criterion-validate"
|
||||
SingleClickAction = "single-click-action"
|
||||
SingleInputAction = "single-input-action"
|
||||
SingleUploadAction = "single-upload-action"
|
||||
SingleSelectAction = "single-select-action"
|
||||
|
||||
|
||||
class ActionType(StrEnum):
|
||||
Click = "CLICK"
|
||||
InputText = "INPUT_TEXT"
|
||||
UploadFile = "UPLOAD_FILE"
|
||||
SelectOption = "SELECT_OPTION"
|
||||
|
||||
@@ -17,7 +17,7 @@ from sqlalchemy import (
|
||||
from sqlalchemy.ext.asyncio import AsyncAttrs
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
|
||||
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType, TaskPromptTemplate
|
||||
from skyvern.forge.sdk.db.id import (
|
||||
generate_action_id,
|
||||
generate_artifact_id,
|
||||
@@ -54,9 +54,12 @@ class TaskModel(Base):
|
||||
totp_verification_url = Column(String)
|
||||
totp_identifier = Column(String)
|
||||
title = Column(String)
|
||||
prompt_template = Column(String, default=TaskPromptTemplate.ExtractAction)
|
||||
url = Column(String)
|
||||
navigation_goal = Column(String)
|
||||
data_extraction_goal = Column(String)
|
||||
complete_criterion = Column(String)
|
||||
terminate_criterion = Column(String)
|
||||
navigation_payload = Column(JSON)
|
||||
extracted_information = Column(JSON)
|
||||
failure_reason = Column(String)
|
||||
|
||||
@@ -60,8 +60,11 @@ def convert_to_task(task_obj: TaskModel, debug_enabled: bool = False) -> Task:
|
||||
status=TaskStatus(task_obj.status),
|
||||
created_at=task_obj.created_at,
|
||||
modified_at=task_obj.modified_at,
|
||||
prompt_template=task_obj.prompt_template,
|
||||
title=task_obj.title,
|
||||
url=task_obj.url,
|
||||
complete_criterion=task_obj.complete_criterion,
|
||||
terminate_criterion=task_obj.terminate_criterion,
|
||||
webhook_callback_url=task_obj.webhook_callback_url,
|
||||
totp_verification_url=task_obj.totp_verification_url,
|
||||
totp_identifier=task_obj.totp_identifier,
|
||||
|
||||
Reference in New Issue
Block a user