mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-09 07:16:04 +00:00
shit
This commit is contained in:
@@ -7,10 +7,15 @@ Node metadata (label, description, inputs, outputs, config) is loaded from:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from langbot_plugin.api.entities.builtin.workflow import ExecutionContext
|
||||
from langbot_plugin.api.entities.builtin.workflow.entities import ExecutionContext
|
||||
from ..node import WorkflowNode, workflow_node
|
||||
from .. import monitoring_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@workflow_node('message_trigger')
|
||||
class MessageTriggerNode(WorkflowNode):
|
||||
@@ -21,6 +26,20 @@ class MessageTriggerNode(WorkflowNode):
|
||||
async def execute(self, inputs: dict[str, Any], context: ExecutionContext) -> dict[str, Any]:
|
||||
msg_ctx = context.message_context
|
||||
|
||||
# Record trigger log
|
||||
try:
|
||||
if self.ap and context.query:
|
||||
workflow_id = context.workflow_id or ''
|
||||
workflow_name = context.variables.get('_workflow_name', 'Workflow')
|
||||
await monitoring_helper.WorkflowMonitoringHelper.record_trigger_log(
|
||||
ap=self.ap,
|
||||
query=context.query,
|
||||
workflow_id=workflow_id,
|
||||
workflow_name=workflow_name,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f'[MessageTrigger:{self.node_id}] Failed to record trigger log: {e}')
|
||||
|
||||
if msg_ctx:
|
||||
return {
|
||||
'message': msg_ctx.message_content,
|
||||
|
||||
Reference in New Issue
Block a user