feat: improve workflow run observability
This commit is contained in:
@@ -211,6 +211,14 @@ def _resolve_handoff_target(
|
||||
return next_nodes[0] if next_nodes else None
|
||||
|
||||
|
||||
def _execution_log_event_type(status: Optional[str]) -> str:
|
||||
if status == 'waiting':
|
||||
return 'waiting_input'
|
||||
if status == 'failed':
|
||||
return 'error'
|
||||
return 'node_complete'
|
||||
|
||||
|
||||
def _make_execution_log_entry(
|
||||
node_map: Dict[str, Any],
|
||||
node_id: str,
|
||||
@@ -219,6 +227,7 @@ def _make_execution_log_entry(
|
||||
) -> dict:
|
||||
extra.setdefault('timestamp', datetime.now().isoformat())
|
||||
metadata = dict(extra.pop('metadata', {}) or {})
|
||||
event_type = _execution_log_event_type(extra.get('status'))
|
||||
collaboration = _node_collaboration_metadata(node_map, node_id, node_type)
|
||||
branch_id = extra.get('branch') or extra.get('branch_id')
|
||||
branch_label = extra.get('branch_label')
|
||||
@@ -231,7 +240,7 @@ def _make_execution_log_entry(
|
||||
node_map,
|
||||
node_id,
|
||||
node_type,
|
||||
event_type='node_complete',
|
||||
event_type=event_type,
|
||||
status=extra.get('status'),
|
||||
branch_id=branch_id,
|
||||
branch_label=branch_label,
|
||||
@@ -2508,6 +2517,13 @@ class AIWorkflowService:
|
||||
start_time = time.time()
|
||||
result = await node_instance.execute_async(context)
|
||||
elapsed = int((time.time() - start_time) * 1000)
|
||||
target_node_id = _resolve_handoff_target(
|
||||
current_node_id,
|
||||
result,
|
||||
edge_map,
|
||||
parallel_edge_map,
|
||||
node_map,
|
||||
)
|
||||
|
||||
# 处理节点事件
|
||||
if result.events:
|
||||
|
||||
Reference in New Issue
Block a user