Pass screenshots from one block to another block (#4212)
This commit is contained in:
@@ -810,7 +810,21 @@ class BaseTaskBlock(Block):
|
||||
except asyncio.TimeoutError:
|
||||
LOG.warning("Timeout getting downloaded files", task_id=updated_task.task_id)
|
||||
|
||||
task_output = TaskOutput.from_task(updated_task, downloaded_files)
|
||||
task_screenshots = await app.WORKFLOW_SERVICE.get_recent_task_screenshot_urls(
|
||||
organization_id=workflow_run.organization_id,
|
||||
task_id=updated_task.task_id,
|
||||
)
|
||||
workflow_screenshots = await app.WORKFLOW_SERVICE.get_recent_workflow_screenshot_urls(
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=workflow_run.organization_id,
|
||||
)
|
||||
|
||||
task_output = TaskOutput.from_task(
|
||||
updated_task,
|
||||
downloaded_files,
|
||||
task_screenshots=task_screenshots,
|
||||
workflow_screenshots=workflow_screenshots,
|
||||
)
|
||||
output_parameter_value = task_output.model_dump()
|
||||
await self.record_output_parameter_value(workflow_run_context, workflow_run_id, output_parameter_value)
|
||||
return await self.build_block_result(
|
||||
@@ -871,7 +885,21 @@ class BaseTaskBlock(Block):
|
||||
except asyncio.TimeoutError:
|
||||
LOG.warning("Timeout getting downloaded files", task_id=updated_task.task_id)
|
||||
|
||||
task_output = TaskOutput.from_task(updated_task, downloaded_files)
|
||||
task_screenshots = await app.WORKFLOW_SERVICE.get_recent_task_screenshot_urls(
|
||||
organization_id=workflow_run.organization_id,
|
||||
task_id=updated_task.task_id,
|
||||
)
|
||||
workflow_screenshots = await app.WORKFLOW_SERVICE.get_recent_workflow_screenshot_urls(
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=workflow_run.organization_id,
|
||||
)
|
||||
|
||||
task_output = TaskOutput.from_task(
|
||||
updated_task,
|
||||
downloaded_files,
|
||||
task_screenshots=task_screenshots,
|
||||
workflow_screenshots=workflow_screenshots,
|
||||
)
|
||||
LOG.warning(
|
||||
f"Task failed with status {updated_task.status}{retry_message}",
|
||||
task_id=updated_task.task_id,
|
||||
@@ -3668,12 +3696,23 @@ class TaskV2Block(Block):
|
||||
|
||||
# If continue_on_failure is True, we treat the block as successful even if the task failed
|
||||
# This allows the workflow to continue execution despite this block's failure
|
||||
task_screenshots = await app.WORKFLOW_SERVICE.get_recent_task_screenshot_urls(
|
||||
organization_id=organization_id,
|
||||
task_v2_id=task_v2.observer_cruise_id,
|
||||
)
|
||||
workflow_screenshots = await app.WORKFLOW_SERVICE.get_recent_workflow_screenshot_urls(
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
|
||||
task_v2_output = {
|
||||
"task_id": task_v2.observer_cruise_id,
|
||||
"status": task_v2.status,
|
||||
"summary": task_v2.summary,
|
||||
"extracted_information": result_dict,
|
||||
"failure_reason": failure_reason,
|
||||
"task_screenshots": task_screenshots,
|
||||
"workflow_screenshots": workflow_screenshots,
|
||||
}
|
||||
await self.record_output_parameter_value(workflow_run_context, workflow_run_id, task_v2_output)
|
||||
return await self.build_block_result(
|
||||
|
||||
Reference in New Issue
Block a user