ExtractAction (#1632)
This commit is contained in:
@@ -2010,6 +2010,10 @@ class AgentDB:
|
||||
prompt: str | None = None,
|
||||
url: str | None = None,
|
||||
organization_id: str | None = None,
|
||||
proxy_location: ProxyLocation | None = None,
|
||||
totp_identifier: str | None = None,
|
||||
totp_verification_url: str | None = None,
|
||||
webhook_callback_url: str | None = None,
|
||||
) -> ObserverTask:
|
||||
async with self.Session() as session:
|
||||
new_observer_cruise = ObserverCruiseModel(
|
||||
@@ -2018,6 +2022,10 @@ class AgentDB:
|
||||
workflow_permanent_id=workflow_permanent_id,
|
||||
prompt=prompt,
|
||||
url=url,
|
||||
proxy_location=proxy_location,
|
||||
totp_identifier=totp_identifier,
|
||||
totp_verification_url=totp_verification_url,
|
||||
webhook_callback_url=webhook_callback_url,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
session.add(new_observer_cruise)
|
||||
|
||||
@@ -87,6 +87,9 @@ class Step(BaseModel):
|
||||
raise ValueError(f"cant_set_is_last_to_false({self.step_id})")
|
||||
|
||||
def is_goal_achieved(self) -> bool:
|
||||
# TODO: now we also consider a step has achieved the goal if the task doesn't have a navigation goal
|
||||
# and the data extraction is successful
|
||||
|
||||
if self.status != StepStatus.completed:
|
||||
return False
|
||||
# TODO (kerem): Remove this check once we have backfilled all the steps
|
||||
@@ -94,14 +97,14 @@ class Step(BaseModel):
|
||||
return False
|
||||
|
||||
# Check if there is a successful complete action
|
||||
for action, action_results in self.output.actions_and_results:
|
||||
if action.action_type != ActionType.COMPLETE:
|
||||
continue
|
||||
if not self.output.actions_and_results:
|
||||
return False
|
||||
|
||||
if any(action_result.success for action_result in action_results):
|
||||
return True
|
||||
last_action, last_action_results = self.output.actions_and_results[-1]
|
||||
if last_action.action_type not in [ActionType.COMPLETE, ActionType.EXTRACT]:
|
||||
return False
|
||||
|
||||
return False
|
||||
return any(action_result.success for action_result in last_action_results)
|
||||
|
||||
def is_success(self) -> bool:
|
||||
if self.status != StepStatus.completed:
|
||||
|
||||
@@ -1147,6 +1147,10 @@ async def observer_task(
|
||||
organization=organization,
|
||||
user_prompt=data.user_prompt,
|
||||
user_url=str(data.url) if data.url else None,
|
||||
totp_identifier=data.totp_identifier,
|
||||
totp_verification_url=data.totp_verification_url,
|
||||
webhook_callback_url=data.webhook_callback_url,
|
||||
proxy_location=data.proxy_location,
|
||||
)
|
||||
except LLMProviderError:
|
||||
LOG.error("LLM failure to initialize observer cruise", exc_info=True)
|
||||
|
||||
@@ -112,6 +112,7 @@ class ObserverTaskRequest(BaseModel):
|
||||
webhook_callback_url: str | None = None
|
||||
totp_verification_url: str | None = None
|
||||
totp_identifier: str | None = None
|
||||
proxy_location: ProxyLocation | None = None
|
||||
|
||||
@field_validator("url", "webhook_callback_url", "totp_verification_url")
|
||||
@classmethod
|
||||
|
||||
@@ -80,11 +80,21 @@ def _generate_data_extraction_schema_for_loop(loop_values_key: str) -> dict:
|
||||
|
||||
|
||||
async def initialize_observer_cruise(
|
||||
organization: Organization, user_prompt: str, user_url: str | None = None
|
||||
organization: Organization,
|
||||
user_prompt: str,
|
||||
user_url: str | None = None,
|
||||
proxy_location: ProxyLocation | None = None,
|
||||
totp_identifier: str | None = None,
|
||||
totp_verification_url: str | None = None,
|
||||
webhook_callback_url: str | None = None,
|
||||
) -> ObserverTask:
|
||||
observer_cruise = await app.DATABASE.create_observer_cruise(
|
||||
prompt=user_prompt,
|
||||
organization_id=organization.organization_id,
|
||||
totp_verification_url=totp_verification_url,
|
||||
totp_identifier=totp_identifier,
|
||||
webhook_callback_url=webhook_callback_url,
|
||||
proxy_location=proxy_location,
|
||||
)
|
||||
# set observer cruise id in context
|
||||
context = skyvern_context.current()
|
||||
@@ -117,7 +127,9 @@ async def initialize_observer_cruise(
|
||||
# create workflow and workflow run
|
||||
max_steps_override = 10
|
||||
try:
|
||||
new_workflow = await app.WORKFLOW_SERVICE.create_empty_workflow(organization, metadata.workflow_title)
|
||||
new_workflow = await app.WORKFLOW_SERVICE.create_empty_workflow(
|
||||
organization, metadata.workflow_title, proxy_location=proxy_location
|
||||
)
|
||||
workflow_run = await app.WORKFLOW_SERVICE.setup_workflow_run(
|
||||
request_id=None,
|
||||
workflow_request=WorkflowRequestBody(),
|
||||
|
||||
@@ -1693,7 +1693,9 @@ class WorkflowService:
|
||||
|
||||
raise ValueError(f"Invalid block type {block_yaml.block_type}")
|
||||
|
||||
async def create_empty_workflow(self, organization: Organization, title: str) -> Workflow:
|
||||
async def create_empty_workflow(
|
||||
self, organization: Organization, title: str, proxy_location: ProxyLocation | None = None
|
||||
) -> Workflow:
|
||||
"""
|
||||
Create a blank workflow with no blocks
|
||||
"""
|
||||
@@ -1704,6 +1706,7 @@ class WorkflowService:
|
||||
parameters=[],
|
||||
blocks=[],
|
||||
),
|
||||
proxy_location=proxy_location,
|
||||
)
|
||||
return await app.WORKFLOW_SERVICE.create_workflow_from_request(
|
||||
organization=organization,
|
||||
|
||||
Reference in New Issue
Block a user