From 8accd36f9e650165cc2eaff01896da1b2c7ac5af Mon Sep 17 00:00:00 2001 From: mengyonghao <1533512157@qq.com> Date: Thu, 25 Dec 2025 14:41:41 +0800 Subject: [PATCH] feat(workflow): support variables wrapped with {{}} in assignment nodes, add input config example --- api/app/core/workflow/nodes/assigner/config.py | 15 +++++++++++++++ api/app/core/workflow/nodes/assigner/node.py | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/api/app/core/workflow/nodes/assigner/config.py b/api/app/core/workflow/nodes/assigner/config.py index 03302af4..d9721e99 100644 --- a/api/app/core/workflow/nodes/assigner/config.py +++ b/api/app/core/workflow/nodes/assigner/config.py @@ -30,3 +30,18 @@ class AssignerNodeConfig(BaseNodeConfig): ..., description="List of variable assignment definitions", ) + + class Config: + json_schema_extra = { + "examples": [ + { + "assignments": [ + { + "variable_selector": "{{ conv.test1 }}", + "operation": "add", + "value": "3" + } + ] + } + ] + } diff --git a/api/app/core/workflow/nodes/assigner/node.py b/api/app/core/workflow/nodes/assigner/node.py index b8b7c1f4..c174f52a 100644 --- a/api/app/core/workflow/nodes/assigner/node.py +++ b/api/app/core/workflow/nodes/assigner/node.py @@ -1,4 +1,5 @@ import logging +import re from typing import Any from app.core.workflow.expression_evaluator import ExpressionEvaluator @@ -34,7 +35,9 @@ class AssignerNode(BaseNode): variable_selector = assignment.variable_selector if isinstance(variable_selector, str): # Support dot-separated string paths, e.g., "conv.test" -> ["conv", "test"] - variable_selector = variable_selector.split('.') + pattern = r"\{\{\s*(.*?)\s*\}\}" + expression = re.sub(pattern, r"\1", variable_selector).strip() + variable_selector = expression.split('.') # Only conversation variables ('conv') are allowed if variable_selector[0] != 'conv': # TODO: Loop node variable support (Feature)