Enforce navigation_goal in NavigationBlock and data_extraction_goal in ExtractionBlock (#1257)

This commit is contained in:
Shuchang Zheng
2024-11-25 11:19:35 -08:00
committed by GitHub
parent d52025472f
commit f28a3bc497
3 changed files with 7 additions and 3 deletions

View File

@@ -1372,10 +1372,14 @@ class ActionBlock(BaseTaskBlock):
class NavigationBlock(BaseTaskBlock):
block_type: Literal[BlockType.NAVIGATION] = BlockType.NAVIGATION
navigation_goal: str
class ExtractionBlock(BaseTaskBlock):
block_type: Literal[BlockType.EXTRACTION] = BlockType.EXTRACTION
data_extraction_goal: str
class LoginBlock(BaseTaskBlock):
block_type: Literal[BlockType.LOGIN] = BlockType.LOGIN

View File

@@ -253,9 +253,9 @@ class NavigationBlockYAML(BlockYAML):
class ExtractionBlockYAML(BlockYAML):
block_type: Literal[BlockType.EXTRACTION] = BlockType.EXTRACTION # type: ignore
data_extraction_goal: str
url: str | None = None
title: str = ""
data_extraction_goal: str | None = None
data_schema: dict[str, Any] | list | None = None
max_retries: int = 0
max_steps_per_run: int | None = None

View File

@@ -1207,7 +1207,7 @@ class WorkflowService:
raise e
@staticmethod
async def _create_output_parameter_for_block(workflow_id: str, block_yaml: BLOCK_YAML_TYPES) -> OutputParameter:
async def create_output_parameter_for_block(workflow_id: str, block_yaml: BLOCK_YAML_TYPES) -> OutputParameter:
output_parameter_key = f"{block_yaml.label}_output"
return await app.DATABASE.create_output_parameter(
workflow_id=workflow_id,
@@ -1221,7 +1221,7 @@ class WorkflowService:
) -> dict[str, OutputParameter]:
output_parameters = {}
for block_yaml in block_yamls:
output_parameter = await WorkflowService._create_output_parameter_for_block(
output_parameter = await WorkflowService.create_output_parameter_for_block(
workflow_id=workflow_id, block_yaml=block_yaml
)
output_parameters[block_yaml.label] = output_parameter