Merge branch 'fix/chore-fix' into dev/plugin-deploy

This commit is contained in:
Yeuoly
2024-12-12 23:46:58 +08:00
11 changed files with 181 additions and 13 deletions

View File

@ -17,6 +17,7 @@ class NodeRunMetadataKey(StrEnum):
TOTAL_PRICE = "total_price"
CURRENCY = "currency"
TOOL_INFO = "tool_info"
AGENT_LOG = "agent_log"
ITERATION_ID = "iteration_id"
ITERATION_INDEX = "iteration_index"
PARALLEL_ID = "parallel_id"

View File

@ -170,4 +170,22 @@ class IterationRunFailedEvent(BaseIterationEvent):
error: str = Field(..., description="failed reason")
InNodeEvent = BaseNodeEvent | BaseParallelBranchEvent | BaseIterationEvent
###########################################
# Agent Events
###########################################
class BaseAgentEvent(GraphEngineEvent):
pass
class AgentLogEvent(BaseAgentEvent):
id: str = Field(..., description="id")
node_execution_id: str = Field(..., description="node execution id")
parent_id: str | None = Field(..., description="parent id")
error: str | None = Field(..., description="error")
status: str = Field(..., description="status")
data: Mapping[str, Any] = Field(..., description="data")
InNodeEvent = BaseNodeEvent | BaseParallelBranchEvent | BaseIterationEvent | BaseAgentEvent

View File

@ -152,7 +152,7 @@ class GraphEngine:
elif isinstance(item, NodeRunSucceededEvent):
if item.node_type == NodeType.END:
self.graph_runtime_state.outputs = (
item.route_node_state.node_run_result.outputs
dict(item.route_node_state.node_run_result.outputs)
if item.route_node_state.node_run_result
and item.route_node_state.node_run_result.outputs
else {}

View File

@ -16,6 +16,7 @@ from core.variables.variables import ArrayAnyVariable
from core.workflow.entities.node_entities import NodeRunMetadataKey, NodeRunResult
from core.workflow.entities.variable_pool import VariablePool
from core.workflow.enums import SystemVariableKey
from core.workflow.graph_engine.entities.event import AgentLogEvent
from core.workflow.nodes.base import BaseNode
from core.workflow.nodes.enums import NodeType
from core.workflow.nodes.event import RunCompletedEvent, RunStreamChunkEvent
@ -55,6 +56,17 @@ class ToolNode(BaseNode[ToolNodeData]):
"plugin_unique_identifier": node_data.plugin_unique_identifier,
}
yield AgentLogEvent(
id=self.node_id,
node_execution_id=self.id,
parent_id=None,
error=None,
status="running",
data={
"tool_info": tool_info,
},
)
# get tool runtime
try:
tool_runtime = ToolManager.get_workflow_tool_runtime(