feat: add conversation_id to invoke

This commit is contained in:
Yeuoly 2024-12-30 13:41:54 +08:00
parent 05a43e3e80
commit 63665a5ff1
2 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,7 @@ from core.agent.plugin_entities import AgentStrategyParameter
from core.plugin.manager.exc import PluginDaemonClientSideError from core.plugin.manager.exc import PluginDaemonClientSideError
from core.workflow.entities.node_entities import NodeRunResult from core.workflow.entities.node_entities import NodeRunResult
from core.workflow.entities.variable_pool import VariablePool from core.workflow.entities.variable_pool import VariablePool
from core.workflow.enums import SystemVariableKey
from core.workflow.nodes.agent.entities import AgentNodeData from core.workflow.nodes.agent.entities import AgentNodeData
from core.workflow.nodes.enums import NodeType from core.workflow.nodes.enums import NodeType
from core.workflow.nodes.event.event import RunCompletedEvent from core.workflow.nodes.event.event import RunCompletedEvent
@ -59,12 +60,15 @@ class AgentNode(ToolNode):
for_log=True, for_log=True,
) )
# get conversation id
conversation_id = self.graph_runtime_state.variable_pool.get(["sys", SystemVariableKey.CONVERSATION_ID])
try: try:
message_stream = strategy.invoke( message_stream = strategy.invoke(
params=parameters, params=parameters,
user_id=self.user_id, user_id=self.user_id,
app_id=self.app_id, app_id=self.app_id,
# TODO: conversation id and message id conversation_id=conversation_id.text if conversation_id else None,
) )
except Exception as e: except Exception as e:
yield RunCompletedEvent( yield RunCompletedEvent(

View File

@ -88,6 +88,9 @@ class ToolNode(BaseNode[ToolNodeData]):
for_log=True, for_log=True,
) )
# get conversation id
conversation_id = self.graph_runtime_state.variable_pool.get(["sys", SystemVariableKey.CONVERSATION_ID])
try: try:
message_stream = ToolEngine.generic_invoke( message_stream = ToolEngine.generic_invoke(
tool=tool_runtime, tool=tool_runtime,
@ -97,7 +100,7 @@ class ToolNode(BaseNode[ToolNodeData]):
workflow_call_depth=self.workflow_call_depth, workflow_call_depth=self.workflow_call_depth,
thread_pool_id=self.thread_pool_id, thread_pool_id=self.thread_pool_id,
app_id=self.app_id, app_id=self.app_id,
# TODO: conversation id and message id conversation_id=conversation_id.text if conversation_id else None,
) )
except ToolNodeError as e: except ToolNodeError as e:
yield RunCompletedEvent( yield RunCompletedEvent(