Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(workflow): move variables package into core.workflow (#32750)
-LAN-1f0fca89a8d3
diff --git a/api/.importlinter b/api/.importlinterindex c180f8d76be..c30007aafb2 100644--- a/api/.importlinter+++ b/api/.importlinter@@ -140,8 +140,6 @@ ignore_imports =core.workflow.nodes.llm.llm_utils -> core.entities.provider_entitiescore.workflow.nodes.parameter_extractor.parameter_extractor_node -> core.model_managercore.workflow.nodes.question_classifier.question_classifier_node -> core.model_manager- core.workflow.nodes.llm.llm_utils -> core.variables.segments- core.workflow.nodes.loop.entities -> core.variables.typescore.workflow.nodes.tool.tool_node -> core.tools.utils.message_transformercore.workflow.nodes.tool.tool_node -> modelscore.workflow.nodes.agent.agent_node -> models.model@@ -178,54 +176,6 @@ ignore_imports =core.workflow.nodes.llm.file_saver -> core.tools.signaturecore.workflow.nodes.llm.file_saver -> core.tools.tool_file_managercore.workflow.nodes.tool.tool_node -> core.tools.errors- core.workflow.conversation_variable_updater -> core.variables- core.workflow.graph_engine.entities.commands -> core.variables.variables- core.workflow.nodes.agent.agent_node -> core.variables.segments- core.workflow.nodes.answer.answer_node -> core.variables- core.workflow.nodes.code.code_node -> core.variables.segments- core.workflow.nodes.code.code_node -> core.variables.types- core.workflow.nodes.code.entities -> core.variables.types- core.workflow.nodes.document_extractor.node -> core.variables- core.workflow.nodes.document_extractor.node -> core.variables.segments- core.workflow.nodes.http_request.executor -> core.variables.segments- core.workflow.nodes.http_request.node -> core.variables.segments- core.workflow.nodes.human_input.entities -> core.variables.consts- core.workflow.nodes.iteration.iteration_node -> core.variables- core.workflow.nodes.iteration.iteration_node -> core.variables.segments- core.workflow.nodes.iteration.iteration_node -> core.variables.variables- core.workflow.nodes.knowledge_retrieval.knowledge_retrieval_node -> core.variables- core.workflow.nodes.knowledge_retrieval.knowledge_retrieval_node -> core.variables.segments- core.workflow.nodes.list_operator.node -> core.variables- core.workflow.nodes.list_operator.node -> core.variables.segments- core.workflow.nodes.llm.node -> core.variables- core.workflow.nodes.loop.loop_node -> core.variables- core.workflow.nodes.parameter_extractor.entities -> core.variables.types- core.workflow.nodes.parameter_extractor.exc -> core.variables.types- core.workflow.nodes.parameter_extractor.parameter_extractor_node -> core.variables.types- core.workflow.nodes.tool.tool_node -> core.variables.segments- core.workflow.nodes.tool.tool_node -> core.variables.variables- core.workflow.nodes.trigger_webhook.node -> core.variables.types- core.workflow.nodes.trigger_webhook.node -> core.variables.variables- core.workflow.nodes.variable_aggregator.entities -> core.variables.types- core.workflow.nodes.variable_aggregator.variable_aggregator_node -> core.variables.segments- core.workflow.nodes.variable_assigner.common.helpers -> core.variables- core.workflow.nodes.variable_assigner.common.helpers -> core.variables.consts- core.workflow.nodes.variable_assigner.common.helpers -> core.variables.types- core.workflow.nodes.variable_assigner.v1.node -> core.variables- core.workflow.nodes.variable_assigner.v2.helpers -> core.variables- core.workflow.nodes.variable_assigner.v2.node -> core.variables- core.workflow.nodes.variable_assigner.v2.node -> core.variables.consts- core.workflow.runtime.graph_runtime_state_protocol -> core.variables.segments- core.workflow.runtime.read_only_wrappers -> core.variables.segments- core.workflow.runtime.variable_pool -> core.variables- core.workflow.runtime.variable_pool -> core.variables.consts- core.workflow.runtime.variable_pool -> core.variables.segments- core.workflow.runtime.variable_pool -> core.variables.variables- core.workflow.utils.condition.processor -> core.variables- core.workflow.utils.condition.processor -> core.variables.segments- core.workflow.variable_loader -> core.variables- core.workflow.variable_loader -> core.variables.consts- core.workflow.workflow_type_encoder -> core.variablescore.workflow.nodes.agent.agent_node -> extensions.ext_databasecore.workflow.nodes.knowledge_index.knowledge_index_node -> extensions.ext_databasecore.workflow.nodes.llm.file_saver -> extensions.ext_databasediff --git a/api/controllers/console/app/workflow_draft_variable.py b/api/controllers/console/app/workflow_draft_variable.pyindex 619b80ff281..f37598fb314 100644--- a/api/controllers/console/app/workflow_draft_variable.py+++ b/api/controllers/console/app/workflow_draft_variable.py@@ -15,11 +15,11 @@ from controllers.console.app.error import (from controllers.console.app.wraps import get_app_modelfrom controllers.console.wraps import account_initialization_required, edit_permission_required, setup_requiredfrom controllers.web.error import InvalidArgumentError, NotFoundError-from core.variables.segment_group import SegmentGroup-from core.variables.segments import ArrayFileSegment, FileSegment, Segment-from core.variables.types import SegmentTypefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_IDfrom core.workflow.file import helpers as file_helpers+from core.workflow.variables.segment_group import SegmentGroup+from core.workflow.variables.segments import ArrayFileSegment, FileSegment, Segment+from core.workflow.variables.types import SegmentTypefrom extensions.ext_database import dbfrom factories.file_factory import build_from_mapping, build_from_mappingsfrom factories.variable_factory import build_segment_with_typediff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.pyindex 2911b1cf18c..7e285c8da90 100644--- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py+++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py@@ -21,8 +21,8 @@ from controllers.console.app.workflow_draft_variable import (from controllers.console.datasets.wraps import get_rag_pipelinefrom controllers.console.wraps import account_initialization_required, setup_requiredfrom controllers.web.error import InvalidArgumentError, NotFoundError-from core.variables.types import SegmentTypefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID+from core.workflow.variables.types import SegmentTypefrom extensions.ext_database import dbfrom factories.file_factory import build_from_mapping, build_from_mappingsfrom factories.variable_factory import build_segment_with_typediff --git a/api/core/app/apps/advanced_chat/app_runner.py b/api/core/app/apps/advanced_chat/app_runner.pyindex 8b20442eabc..18ae75a0878 100644--- a/api/core/app/apps/advanced_chat/app_runner.py+++ b/api/core/app/apps/advanced_chat/app_runner.py@@ -25,7 +25,6 @@ from core.app.workflow.layers.persistence import PersistenceWorkflowInfo, Workflfrom core.db.session_factory import session_factoryfrom core.moderation.base import ModerationErrorfrom core.moderation.input_moderation import InputModeration-from core.variables.variables import Variablefrom core.workflow.enums import WorkflowTypefrom core.workflow.graph_engine.command_channels.redis_channel import RedisChannelfrom core.workflow.graph_engine.layers.base import GraphEngineLayer@@ -34,6 +33,7 @@ from core.workflow.repositories.workflow_node_execution_repository import Workflfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariablefrom core.workflow.variable_loader import VariableLoader+from core.workflow.variables.variables import Variablefrom core.workflow.workflow_entry import WorkflowEntryfrom extensions.ext_database import dbfrom extensions.ext_redis import redis_clientdiff --git a/api/core/app/apps/common/workflow_response_converter.py b/api/core/app/apps/common/workflow_response_converter.pyindex 510abdc1d0b..d4e801de13a 100644--- a/api/core/app/apps/common/workflow_response_converter.py+++ b/api/core/app/apps/common/workflow_response_converter.py@@ -49,7 +49,6 @@ from core.plugin.impl.datasource import PluginDatasourceManagerfrom core.tools.entities.tool_entities import ToolProviderTypefrom core.tools.tool_manager import ToolManagerfrom core.trigger.trigger_manager import TriggerManager-from core.variables.segments import ArrayFileSegment, FileSegment, Segmentfrom core.workflow.entities.pause_reason import HumanInputRequiredfrom core.workflow.entities.workflow_start_reason import WorkflowStartReasonfrom core.workflow.enums import (@@ -62,6 +61,7 @@ from core.workflow.enums import (from core.workflow.file import FILE_MODEL_IDENTITY, Filefrom core.workflow.runtime import GraphRuntimeStatefrom core.workflow.system_variable import SystemVariable+from core.workflow.variables.segments import ArrayFileSegment, FileSegment, Segmentfrom core.workflow.workflow_entry import WorkflowEntryfrom core.workflow.workflow_type_encoder import WorkflowRuntimeTypeConverterfrom extensions.ext_database import dbdiff --git a/api/core/app/apps/pipeline/pipeline_runner.py b/api/core/app/apps/pipeline/pipeline_runner.pyindex 8ea34344b27..02caf8f5115 100644--- a/api/core/app/apps/pipeline/pipeline_runner.py+++ b/api/core/app/apps/pipeline/pipeline_runner.py@@ -11,7 +11,6 @@ from core.app.entities.app_invoke_entities import ()from core.app.workflow.layers.persistence import PersistenceWorkflowInfo, WorkflowPersistenceLayerfrom core.app.workflow.node_factory import DifyNodeFactory-from core.variables.variables import RAGPipelineVariable, RAGPipelineVariableInputfrom core.workflow.entities.graph_init_params import GraphInitParamsfrom core.workflow.enums import WorkflowTypefrom core.workflow.graph import Graph@@ -21,6 +20,7 @@ from core.workflow.repositories.workflow_node_execution_repository import Workflfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariablefrom core.workflow.variable_loader import VariableLoader+from core.workflow.variables.variables import RAGPipelineVariable, RAGPipelineVariableInputfrom core.workflow.workflow_entry import WorkflowEntryfrom extensions.ext_database import dbfrom models.dataset import Document, Pipelinediff --git a/api/core/app/layers/conversation_variable_persist_layer.py b/api/core/app/layers/conversation_variable_persist_layer.pyindex c070845b73c..a748d903870 100644--- a/api/core/app/layers/conversation_variable_persist_layer.py+++ b/api/core/app/layers/conversation_variable_persist_layer.py@@ -1,12 +1,12 @@import logging-from core.variables import VariableBasefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_IDfrom core.workflow.conversation_variable_updater import ConversationVariableUpdaterfrom core.workflow.enums import NodeTypefrom core.workflow.graph_engine.layers.base import GraphEngineLayerfrom core.workflow.graph_events import GraphEngineEvent, NodeRunSucceededEventfrom core.workflow.nodes.variable_assigner.common import helpers as common_helpers+from core.workflow.variables import VariableBaselogger = logging.getLogger(__name__)diff --git a/api/core/helper/code_executor/template_transformer.py b/api/core/helper/code_executor/template_transformer.pyindex 5cdea19a8dd..1b56eaba21c 100644--- a/api/core/helper/code_executor/template_transformer.py+++ b/api/core/helper/code_executor/template_transformer.py@@ -5,7 +5,7 @@ from base64 import b64encodefrom collections.abc import Mappingfrom typing import Any-from core.variables.utils import dumps_with_segments+from core.workflow.variables.utils import dumps_with_segmentsclass TemplateTransformer(ABC):diff --git a/api/core/workflow/conversation_variable_updater.py b/api/core/workflow/conversation_variable_updater.pyindex 75f47691daa..6bfb2b28802 100644--- a/api/core/workflow/conversation_variable_updater.py+++ b/api/core/workflow/conversation_variable_updater.py@@ -1,7 +1,7 @@import abcfrom typing import Protocol-from core.variables import VariableBase+from core.workflow.variables import VariableBaseclass ConversationVariableUpdater(Protocol):diff --git a/api/core/workflow/graph_engine/entities/commands.py b/api/core/workflow/graph_engine/entities/commands.pyindex 41276eb4446..7e7b65247b5 100644--- a/api/core/workflow/graph_engine/entities/commands.py+++ b/api/core/workflow/graph_engine/entities/commands.py@@ -11,7 +11,7 @@ from typing import Anyfrom pydantic import BaseModel, Field-from core.variables.variables import Variable+from core.workflow.variables.variables import Variableclass CommandType(StrEnum):diff --git a/api/core/workflow/nodes/agent/agent_node.py b/api/core/workflow/nodes/agent/agent_node.pyindex 5c39a671029..ac86b1784f0 100644--- a/api/core/workflow/nodes/agent/agent_node.py+++ b/api/core/workflow/nodes/agent/agent_node.py@@ -25,7 +25,6 @@ from core.tools.entities.tool_entities import ()from core.tools.tool_manager import ToolManagerfrom core.tools.utils.message_transformer import ToolFileMessageTransformer-from core.variables.segments import ArrayFileSegment, StringSegmentfrom core.workflow.enums import (NodeType,SystemVariableKey,@@ -44,6 +43,7 @@ from core.workflow.nodes.agent.entities import AgentNodeData, AgentOldVersionModfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.base.variable_template_parser import VariableTemplateParserfrom core.workflow.runtime import VariablePool+from core.workflow.variables.segments import ArrayFileSegment, StringSegmentfrom extensions.ext_database import dbfrom factories import file_factoryfrom factories.agent_factory import get_plugin_agent_strategydiff --git a/api/core/workflow/nodes/answer/answer_node.py b/api/core/workflow/nodes/answer/answer_node.pyindex d3b3fac107b..388447368eb 100644--- a/api/core/workflow/nodes/answer/answer_node.py+++ b/api/core/workflow/nodes/answer/answer_node.py@@ -1,13 +1,13 @@from collections.abc import Mapping, Sequencefrom typing import Any-from core.variables import ArrayFileSegment, FileSegment, Segmentfrom core.workflow.enums import NodeExecutionType, NodeType, WorkflowNodeExecutionStatusfrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.answer.entities import AnswerNodeDatafrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.base.template import Templatefrom core.workflow.nodes.base.variable_template_parser import VariableTemplateParser+from core.workflow.variables import ArrayFileSegment, FileSegment, Segmentclass AnswerNode(Node[AnswerNodeData]):diff --git a/api/core/workflow/nodes/code/code_node.py b/api/core/workflow/nodes/code/code_node.pyindex f7a6c41f0af..d907ce21204 100644--- a/api/core/workflow/nodes/code/code_node.py+++ b/api/core/workflow/nodes/code/code_node.py@@ -5,13 +5,13 @@ from typing import TYPE_CHECKING, Any, ClassVar, Protocol, castfrom core.helper.code_executor.code_node_provider import CodeNodeProviderfrom core.helper.code_executor.javascript.javascript_code_provider import JavascriptCodeProviderfrom core.helper.code_executor.python3.python3_code_provider import Python3CodeProvider-from core.variables.segments import ArrayFileSegment-from core.variables.types import SegmentTypefrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.code.entities import CodeLanguage, CodeNodeDatafrom core.workflow.nodes.code.limits import CodeNodeLimits+from core.workflow.variables.segments import ArrayFileSegment+from core.workflow.variables.types import SegmentTypefrom .exc import (CodeNodeError,diff --git a/api/core/workflow/nodes/code/entities.py b/api/core/workflow/nodes/code/entities.pyindex 80260111965..9a3528866c1 100644--- a/api/core/workflow/nodes/code/entities.py+++ b/api/core/workflow/nodes/code/entities.py@@ -3,9 +3,9 @@ from typing import Annotated, Literalfrom pydantic import AfterValidator, BaseModelfrom core.helper.code_executor.code_executor import CodeLanguage-from core.variables.types import SegmentTypefrom core.workflow.nodes.base import BaseNodeDatafrom core.workflow.nodes.base.entities import VariableSelector+from core.workflow.variables.types import SegmentType_ALLOWED_OUTPUT_FROM_CODE = frozenset([diff --git a/api/core/workflow/nodes/document_extractor/node.py b/api/core/workflow/nodes/document_extractor/node.pyindex c442e018542..59be4c54efe 100644--- a/api/core/workflow/nodes/document_extractor/node.py+++ b/api/core/workflow/nodes/document_extractor/node.py@@ -21,12 +21,12 @@ from docx.table import Tablefrom docx.text.paragraph import Paragraphfrom core.helper import ssrf_proxy-from core.variables import ArrayFileSegment-from core.variables.segments import ArrayStringSegment, FileSegmentfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.file import File, FileTransferMethod, file_managerfrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Node+from core.workflow.variables import ArrayFileSegment+from core.workflow.variables.segments import ArrayStringSegment, FileSegmentfrom .entities import DocumentExtractorNodeData, UnstructuredApiConfigfrom .exc import DocumentExtractorError, FileDownloadError, TextExtractionError, UnsupportedFileTypeErrordiff --git a/api/core/workflow/nodes/http_request/executor.py b/api/core/workflow/nodes/http_request/executor.pyindex 8f180b47b5d..cd6007e720d 100644--- a/api/core/workflow/nodes/http_request/executor.py+++ b/api/core/workflow/nodes/http_request/executor.py@@ -11,10 +11,10 @@ import httpxfrom json_repair import repair_jsonfrom core.helper.ssrf_proxy import ssrf_proxy-from core.variables.segments import ArrayFileSegment, FileSegmentfrom core.workflow.file.enums import FileTransferMethodfrom core.workflow.file.file_manager import file_manager as default_file_managerfrom core.workflow.runtime import VariablePool+from core.workflow.variables.segments import ArrayFileSegment, FileSegmentfrom ..protocols import FileManagerProtocol, HttpClientProtocolfrom .entities import (diff --git a/api/core/workflow/nodes/http_request/node.py b/api/core/workflow/nodes/http_request/node.pyindex d45775652ff..89eebb181c4 100644--- a/api/core/workflow/nodes/http_request/node.py+++ b/api/core/workflow/nodes/http_request/node.py@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING, Anyfrom core.helper.ssrf_proxy import ssrf_proxyfrom core.tools.tool_file_manager import ToolFileManager-from core.variables.segments import ArrayFileSegmentfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.file import File, FileTransferMethodfrom core.workflow.file.file_manager import file_manager as default_file_manager@@ -15,6 +14,7 @@ from core.workflow.nodes.base.entities import VariableSelectorfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.http_request.executor import Executorfrom core.workflow.nodes.protocols import FileManagerProtocol, HttpClientProtocol+from core.workflow.variables.segments import ArrayFileSegmentfrom factories import file_factoryfrom .config import build_http_request_config, resolve_http_request_configdiff --git a/api/core/workflow/nodes/human_input/entities.py b/api/core/workflow/nodes/human_input/entities.pyindex 72d4fc675be..a4473dfa7d6 100644--- a/api/core/workflow/nodes/human_input/entities.py+++ b/api/core/workflow/nodes/human_input/entities.py@@ -10,10 +10,10 @@ from typing import Annotated, Any, ClassVar, Literal, Selffrom pydantic import BaseModel, Field, field_validator, model_validator-from core.variables.consts import SELECTORS_LENGTHfrom core.workflow.nodes.base import BaseNodeDatafrom core.workflow.nodes.base.variable_template_parser import VariableTemplateParserfrom core.workflow.runtime import VariablePool+from core.workflow.variables.consts import SELECTORS_LENGTHfrom .enums import ButtonStyle, DeliveryMethodType, EmailRecipientType, FormInputType, PlaceholderType, TimeoutUnitdiff --git a/api/core/workflow/nodes/iteration/iteration_node.py b/api/core/workflow/nodes/iteration/iteration_node.pyindex 25a881ea7dd..5e7aa2a7513 100644--- a/api/core/workflow/nodes/iteration/iteration_node.py+++ b/api/core/workflow/nodes/iteration/iteration_node.py@@ -7,9 +7,6 @@ from typing import TYPE_CHECKING, Any, NewType, castfrom typing_extensions import TypeIsfrom core.model_runtime.entities.llm_entities import LLMUsage-from core.variables import IntegerVariable, NoneSegment-from core.variables.segments import ArrayAnySegment, ArraySegment-from core.variables.variables import Variablefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_IDfrom core.workflow.enums import (NodeExecutionType,@@ -36,6 +33,9 @@ from core.workflow.nodes.base import LLMUsageTrackingMixinfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.iteration.entities import ErrorHandleMode, IterationNodeDatafrom core.workflow.runtime import VariablePool+from core.workflow.variables import IntegerVariable, NoneSegment+from core.workflow.variables.segments import ArrayAnySegment, ArraySegment+from core.workflow.variables.variables import Variablefrom libs.datetime_utils import naive_utc_nowfrom .exc import (diff --git a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.pyindex b25c3a3d29c..0cfd39e485a 100644--- a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py+++ b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py@@ -5,12 +5,6 @@ from typing import TYPE_CHECKING, Any, Literalfrom core.app.app_config.entities import DatasetRetrieveConfigEntityfrom core.model_runtime.entities.llm_entities import LLMUsagefrom core.model_runtime.utils.encoders import jsonable_encoder-from core.variables import (- ArrayFileSegment,- FileSegment,- StringSegment,-)-from core.variables.segments import ArrayObjectSegmentfrom core.workflow.entities import GraphInitParamsfrom core.workflow.enums import (NodeType,@@ -22,6 +16,12 @@ from core.workflow.nodes.base import LLMUsageTrackingMixinfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.llm.file_saver import FileSaverImpl, LLMFileSaverfrom core.workflow.repositories.rag_retrieval_protocol import KnowledgeRetrievalRequest, RAGRetrievalProtocol, Source+from core.workflow.variables import (+ ArrayFileSegment,+ FileSegment,+ StringSegment,+)+from core.workflow.variables.segments import ArrayObjectSegmentfrom .entities import KnowledgeRetrievalNodeDatafrom .exc import (diff --git a/api/core/workflow/nodes/list_operator/node.py b/api/core/workflow/nodes/list_operator/node.pyindex 3978a795508..d9ef16fbe7c 100644--- a/api/core/workflow/nodes/list_operator/node.py+++ b/api/core/workflow/nodes/list_operator/node.py@@ -1,12 +1,12 @@from collections.abc import Callable, Sequencefrom typing import Any, TypeAlias, TypeVar-from core.variables import ArrayFileSegment, ArrayNumberSegment, ArrayStringSegment-from core.variables.segments import ArrayAnySegment, ArrayBooleanSegment, ArraySegmentfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.file import Filefrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Node+from core.workflow.variables import ArrayFileSegment, ArrayNumberSegment, ArrayStringSegment+from core.workflow.variables.segments import ArrayAnySegment, ArrayBooleanSegment, ArraySegmentfrom .entities import FilterOperator, ListOperatorNodeData, Orderfrom .exc import InvalidConditionError, InvalidFilterValueError, InvalidKeyError, ListOperatorErrordiff --git a/api/core/workflow/nodes/llm/llm_utils.py b/api/core/workflow/nodes/llm/llm_utils.pyindex cf509f65f09..f753e198971 100644--- a/api/core/workflow/nodes/llm/llm_utils.py+++ b/api/core/workflow/nodes/llm/llm_utils.py@@ -12,10 +12,10 @@ from core.model_runtime.entities.llm_entities import LLMUsagefrom core.model_runtime.entities.model_entities import AIModelEntityfrom core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModelfrom core.prompt.entities.advanced_prompt_entities import MemoryConfig-from core.variables.segments import ArrayAnySegment, ArrayFileSegment, FileSegment, NoneSegment, StringSegmentfrom core.workflow.enums import SystemVariableKeyfrom core.workflow.file.models import Filefrom core.workflow.runtime import VariablePool+from core.workflow.variables.segments import ArrayAnySegment, ArrayFileSegment, FileSegment, NoneSegment, StringSegmentfrom extensions.ext_database import dbfrom libs.datetime_utils import naive_utc_nowfrom models.model import Conversationdiff --git a/api/core/workflow/nodes/llm/node.py b/api/core/workflow/nodes/llm/node.pyindex ec23fd72316..33dd88156fe 100644--- a/api/core/workflow/nodes/llm/node.py+++ b/api/core/workflow/nodes/llm/node.py@@ -43,14 +43,6 @@ from core.prompt.entities.advanced_prompt_entities import CompletionModelPromptTfrom core.prompt.utils.prompt_message_util import PromptMessageUtilfrom core.rag.entities.citation_metadata import RetrievalSourceMetadatafrom core.tools.signature import sign_upload_file-from core.variables import (- ArrayFileSegment,- ArraySegment,- FileSegment,- NoneSegment,- ObjectSegment,- StringSegment,-)from core.workflow.constants import SYSTEM_VARIABLE_NODE_IDfrom core.workflow.entities import GraphInitParamsfrom core.workflow.enums import (@@ -73,6 +65,14 @@ from core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.base.variable_template_parser import VariableTemplateParserfrom core.workflow.nodes.llm.protocols import CredentialsProvider, ModelFactoryfrom core.workflow.runtime import VariablePool+from core.workflow.variables import (+ ArrayFileSegment,+ ArraySegment,+ FileSegment,+ NoneSegment,+ ObjectSegment,+ StringSegment,+)from extensions.ext_database import dbfrom models.dataset import SegmentAttachmentBindingfrom models.model import UploadFilediff --git a/api/core/workflow/nodes/loop/entities.py b/api/core/workflow/nodes/loop/entities.pyindex 92a8702fc36..4090f277993 100644--- a/api/core/workflow/nodes/loop/entities.py+++ b/api/core/workflow/nodes/loop/entities.py@@ -3,9 +3,9 @@ from typing import Annotated, Any, Literalfrom pydantic import AfterValidator, BaseModel, Field, field_validator-from core.variables.types import SegmentTypefrom core.workflow.nodes.base import BaseLoopNodeData, BaseLoopState, BaseNodeDatafrom core.workflow.utils.condition.entities import Condition+from core.workflow.variables.types import SegmentType_VALID_VAR_TYPE = frozenset([diff --git a/api/core/workflow/nodes/loop/loop_node.py b/api/core/workflow/nodes/loop/loop_node.pyindex 241a186a949..c546df1fbab 100644--- a/api/core/workflow/nodes/loop/loop_node.py+++ b/api/core/workflow/nodes/loop/loop_node.py@@ -6,7 +6,6 @@ from datetime import datetimefrom typing import TYPE_CHECKING, Any, Literal, castfrom core.model_runtime.entities.llm_entities import LLMUsage-from core.variables import Segment, SegmentTypefrom core.workflow.enums import (NodeExecutionType,NodeType,@@ -31,6 +30,7 @@ from core.workflow.nodes.base import LLMUsageTrackingMixinfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.loop.entities import LoopCompletedReason, LoopNodeData, LoopVariableDatafrom core.workflow.utils.condition.processor import ConditionProcessor+from core.workflow.variables import Segment, SegmentTypefrom factories.variable_factory import TypeMismatchError, build_segment_with_type, segment_to_variablefrom libs.datetime_utils import naive_utc_nowdiff --git a/api/core/workflow/nodes/parameter_extractor/entities.py b/api/core/workflow/nodes/parameter_extractor/entities.pyindex 4e3819c4cfe..90d78ae429a 100644--- a/api/core/workflow/nodes/parameter_extractor/entities.py+++ b/api/core/workflow/nodes/parameter_extractor/entities.py@@ -8,9 +8,9 @@ from pydantic import ()from core.prompt.entities.advanced_prompt_entities import MemoryConfig-from core.variables.types import SegmentTypefrom core.workflow.nodes.base import BaseNodeDatafrom core.workflow.nodes.llm.entities import ModelConfig, VisionConfig+from core.workflow.variables.types import SegmentType_OLD_BOOL_TYPE_NAME = "bool"_OLD_SELECT_TYPE_NAME = "select"diff --git a/api/core/workflow/nodes/parameter_extractor/exc.py b/api/core/workflow/nodes/parameter_extractor/exc.pyindex a1707a2461c..5a587805751 100644--- a/api/core/workflow/nodes/parameter_extractor/exc.py+++ b/api/core/workflow/nodes/parameter_extractor/exc.py@@ -1,6 +1,6 @@from typing import Any-from core.variables.types import SegmentType+from core.workflow.variables.types import SegmentTypeclass ParameterExtractorNodeError(ValueError):diff --git a/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py b/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.pyindex 93402d50841..66ef17e585c 100644--- a/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py+++ b/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py@@ -24,7 +24,6 @@ from core.prompt.advanced_prompt_transform import AdvancedPromptTransformfrom core.prompt.entities.advanced_prompt_entities import ChatModelMessage, CompletionModelPromptTemplatefrom core.prompt.simple_prompt_transform import ModelModefrom core.prompt.utils.prompt_message_util import PromptMessageUtil-from core.variables.types import ArrayValidation, SegmentTypefrom core.workflow.enums import NodeType, WorkflowNodeExecutionMetadataKey, WorkflowNodeExecutionStatusfrom core.workflow.file import Filefrom core.workflow.node_events import NodeRunResult@@ -32,6 +31,7 @@ from core.workflow.nodes.base import variable_template_parserfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.llm import llm_utilsfrom core.workflow.runtime import VariablePool+from core.workflow.variables.types import ArrayValidation, SegmentTypefrom factories.variable_factory import build_segment_with_typefrom .entities import ParameterExtractorNodeDatadiff --git a/api/core/workflow/nodes/tool/tool_node.py b/api/core/workflow/nodes/tool/tool_node.pyindex a7bf7d66429..0d7270a2821 100644--- a/api/core/workflow/nodes/tool/tool_node.py+++ b/api/core/workflow/nodes/tool/tool_node.py@@ -11,8 +11,6 @@ from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameterfrom core.tools.errors import ToolInvokeErrorfrom core.tools.tool_engine import ToolEnginefrom core.tools.utils.message_transformer import ToolFileMessageTransformer-from core.variables.segments import ArrayAnySegment, ArrayFileSegment-from core.variables.variables import ArrayAnyVariablefrom core.workflow.enums import (NodeType,SystemVariableKey,@@ -23,6 +21,8 @@ from core.workflow.file import File, FileTransferMethodfrom core.workflow.node_events import NodeEventBase, NodeRunResult, StreamChunkEvent, StreamCompletedEventfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.base.variable_template_parser import VariableTemplateParser+from core.workflow.variables.segments import ArrayAnySegment, ArrayFileSegment+from core.workflow.variables.variables import ArrayAnyVariablefrom extensions.ext_database import dbfrom factories import file_factoryfrom models import ToolFilediff --git a/api/core/workflow/nodes/trigger_webhook/node.py b/api/core/workflow/nodes/trigger_webhook/node.pyindex 060afd6ae6b..9f6046c11a7 100644--- a/api/core/workflow/nodes/trigger_webhook/node.py+++ b/api/core/workflow/nodes/trigger_webhook/node.py@@ -2,14 +2,14 @@ import loggingfrom collections.abc import Mappingfrom typing import Any-from core.variables.types import SegmentType-from core.variables.variables import FileVariablefrom core.workflow.constants import SYSTEM_VARIABLE_NODE_IDfrom core.workflow.entities.workflow_node_execution import WorkflowNodeExecutionStatusfrom core.workflow.enums import NodeExecutionType, NodeTypefrom core.workflow.file import FileTransferMethodfrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Node+from core.workflow.variables.types import SegmentType+from core.workflow.variables.variables import FileVariablefrom factories import file_factoryfrom factories.variable_factory import build_segment_with_typediff --git a/api/core/workflow/nodes/variable_aggregator/entities.py b/api/core/workflow/nodes/variable_aggregator/entities.pyindex aab17aad22c..febbf1d1d6b 100644--- a/api/core/workflow/nodes/variable_aggregator/entities.py+++ b/api/core/workflow/nodes/variable_aggregator/entities.py@@ -1,7 +1,7 @@from pydantic import BaseModel-from core.variables.types import SegmentTypefrom core.workflow.nodes.base import BaseNodeData+from core.workflow.variables.types import SegmentTypeclass AdvancedSettings(BaseModel):diff --git a/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py b/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.pyindex 4b3a2304e75..762b7dab07a 100644--- a/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py+++ b/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py@@ -1,10 +1,10 @@from collections.abc import Mapping-from core.variables.segments import Segmentfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.variable_aggregator.entities import VariableAggregatorNodeData+from core.workflow.variables.segments import Segmentclass VariableAggregatorNode(Node[VariableAggregatorNodeData]):diff --git a/api/core/workflow/nodes/variable_assigner/common/helpers.py b/api/core/workflow/nodes/variable_assigner/common/helpers.pyindex 04a73237391..37fde9d1b06 100644--- a/api/core/workflow/nodes/variable_assigner/common/helpers.py+++ b/api/core/workflow/nodes/variable_assigner/common/helpers.py@@ -3,9 +3,9 @@ from typing import Any, TypeVarfrom pydantic import BaseModel-from core.variables import Segment-from core.variables.consts import SELECTORS_LENGTH-from core.variables.types import SegmentType+from core.workflow.variables import Segment+from core.workflow.variables.consts import SELECTORS_LENGTH+from core.workflow.variables.types import SegmentType# Use double underscore (`__`) prefix for internal variables# to minimize risk of collision with user-defined variable names.diff --git a/api/core/workflow/nodes/variable_assigner/v1/node.py b/api/core/workflow/nodes/variable_assigner/v1/node.pyindex 9f5818f4bbd..b987949541c 100644--- a/api/core/workflow/nodes/variable_assigner/v1/node.py+++ b/api/core/workflow/nodes/variable_assigner/v1/node.py@@ -1,7 +1,6 @@from collections.abc import Mapping, Sequencefrom typing import TYPE_CHECKING, Any-from core.variables import SegmentType, VariableBasefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_IDfrom core.workflow.entities import GraphInitParamsfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatus@@ -9,6 +8,7 @@ from core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.variable_assigner.common import helpers as common_helpersfrom core.workflow.nodes.variable_assigner.common.exc import VariableOperatorNodeError+from core.workflow.variables import SegmentType, VariableBasefrom .node_data import VariableAssignerData, WriteModediff --git a/api/core/workflow/nodes/variable_assigner/v2/helpers.py b/api/core/workflow/nodes/variable_assigner/v2/helpers.pyindex f5490fb900e..ce3fe9620c1 100644--- a/api/core/workflow/nodes/variable_assigner/v2/helpers.py+++ b/api/core/workflow/nodes/variable_assigner/v2/helpers.py@@ -1,6 +1,6 @@from typing import Any-from core.variables import SegmentType+from core.workflow.variables import SegmentTypefrom .enums import Operationdiff --git a/api/core/workflow/nodes/variable_assigner/v2/node.py b/api/core/workflow/nodes/variable_assigner/v2/node.pyindex 5857702e722..0d4c3d27740 100644--- a/api/core/workflow/nodes/variable_assigner/v2/node.py+++ b/api/core/workflow/nodes/variable_assigner/v2/node.py@@ -2,14 +2,14 @@ import jsonfrom collections.abc import Mapping, MutableMapping, Sequencefrom typing import TYPE_CHECKING, Any-from core.variables import SegmentType, VariableBase-from core.variables.consts import SELECTORS_LENGTHfrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_IDfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.base.node import Nodefrom core.workflow.nodes.variable_assigner.common import helpers as common_helpersfrom core.workflow.nodes.variable_assigner.common.exc import VariableOperatorNodeError+from core.workflow.variables import SegmentType, VariableBase+from core.workflow.variables.consts import SELECTORS_LENGTHfrom . import helpersfrom .entities import VariableAssignerNodeData, VariableOperationItemdiff --git a/api/core/workflow/runtime/graph_runtime_state_protocol.py b/api/core/workflow/runtime/graph_runtime_state_protocol.pyindex bfbb5ba7041..81d87e5a74c 100644--- a/api/core/workflow/runtime/graph_runtime_state_protocol.py+++ b/api/core/workflow/runtime/graph_runtime_state_protocol.py@@ -2,8 +2,8 @@ from collections.abc import Mapping, Sequencefrom typing import Any, Protocolfrom core.model_runtime.entities.llm_entities import LLMUsage-from core.variables.segments import Segmentfrom core.workflow.system_variable import SystemVariableReadOnlyView+from core.workflow.variables.segments import Segmentclass ReadOnlyVariablePool(Protocol):diff --git a/api/core/workflow/runtime/read_only_wrappers.py b/api/core/workflow/runtime/read_only_wrappers.pyindex d3e4c60d9bf..25a834a5390 100644--- a/api/core/workflow/runtime/read_only_wrappers.py+++ b/api/core/workflow/runtime/read_only_wrappers.py@@ -5,8 +5,8 @@ from copy import deepcopyfrom typing import Anyfrom core.model_runtime.entities.llm_entities import LLMUsage-from core.variables.segments import Segmentfrom core.workflow.system_variable import SystemVariableReadOnlyView+from core.workflow.variables.segments import Segmentfrom .graph_runtime_state import GraphRuntimeStatefrom .variable_pool import VariablePooldiff --git a/api/core/workflow/runtime/variable_pool.py b/api/core/workflow/runtime/variable_pool.pyindex 0ba9d8b3a8a..48ad102b43d 100644--- a/api/core/workflow/runtime/variable_pool.py+++ b/api/core/workflow/runtime/variable_pool.py@@ -8,10 +8,6 @@ from typing import Annotated, Any, Union, castfrom pydantic import BaseModel, Field-from core.variables import Segment, SegmentGroup, VariableBase-from core.variables.consts import SELECTORS_LENGTH-from core.variables.segments import FileSegment, ObjectSegment-from core.variables.variables import RAGPipelineVariableInput, Variablefrom core.workflow.constants import (CONVERSATION_VARIABLE_NODE_ID,ENVIRONMENT_VARIABLE_NODE_ID,@@ -20,6 +16,10 @@ from core.workflow.constants import ()from core.workflow.file import File, FileAttribute, file_managerfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import Segment, SegmentGroup, VariableBase+from core.workflow.variables.consts import SELECTORS_LENGTH+from core.workflow.variables.segments import FileSegment, ObjectSegment+from core.workflow.variables.variables import RAGPipelineVariableInput, Variablefrom factories import variable_factoryVariableValue = Union[str, int, float, dict[str, object], list[object], File]diff --git a/api/core/workflow/utils/condition/processor.py b/api/core/workflow/utils/condition/processor.pyindex c3f25a4d626..4e635cc2f28 100644--- a/api/core/workflow/utils/condition/processor.py+++ b/api/core/workflow/utils/condition/processor.py@@ -2,10 +2,10 @@ import jsonfrom collections.abc import Mapping, Sequencefrom typing import Literal, NamedTuple-from core.variables import ArrayFileSegment-from core.variables.segments import ArrayBooleanSegment, BooleanSegmentfrom core.workflow.file import FileAttribute, file_managerfrom core.workflow.runtime import VariablePool+from core.workflow.variables import ArrayFileSegment+from core.workflow.variables.segments import ArrayBooleanSegment, BooleanSegmentfrom .entities import Condition, SubCondition, SupportedComparisonOperatordiff --git a/api/core/workflow/variable_loader.py b/api/core/workflow/variable_loader.pyindex 7992785fe1f..dfa4ce2e751 100644--- a/api/core/workflow/variable_loader.py+++ b/api/core/workflow/variable_loader.py@@ -2,9 +2,9 @@ import abcfrom collections.abc import Mapping, Sequencefrom typing import Any, Protocol-from core.variables import VariableBase-from core.variables.consts import SELECTORS_LENGTHfrom core.workflow.runtime import VariablePool+from core.workflow.variables import VariableBase+from core.workflow.variables.consts import SELECTORS_LENGTHclass VariableLoader(Protocol):diff --git a/api/core/variables/__init__.py b/api/core/workflow/variables/__init__.pysimilarity index 100%rename from api/core/variables/__init__.pyrename to api/core/workflow/variables/__init__.pydiff --git a/api/core/variables/consts.py b/api/core/workflow/variables/consts.pysimilarity index 100%rename from api/core/variables/consts.pyrename to api/core/workflow/variables/consts.pydiff --git a/api/core/variables/exc.py b/api/core/workflow/variables/exc.pysimilarity index 100%rename from api/core/variables/exc.pyrename to api/core/workflow/variables/exc.pydiff --git a/api/core/variables/segment_group.py b/api/core/workflow/variables/segment_group.pysimilarity index 100%rename from api/core/variables/segment_group.pyrename to api/core/workflow/variables/segment_group.pydiff --git a/api/core/variables/segments.py b/api/core/workflow/variables/segments.pysimilarity index 100%rename from api/core/variables/segments.pyrename to api/core/workflow/variables/segments.pydiff --git a/api/core/variables/types.py b/api/core/workflow/variables/types.pysimilarity index 100%rename from api/core/variables/types.pyrename to api/core/workflow/variables/types.pydiff --git a/api/core/variables/utils.py b/api/core/workflow/variables/utils.pysimilarity index 100%rename from api/core/variables/utils.pyrename to api/core/workflow/variables/utils.pydiff --git a/api/core/variables/variables.py b/api/core/workflow/variables/variables.pysimilarity index 95%rename from api/core/variables/variables.pyrename to api/core/workflow/variables/variables.pyindex 338d81df780..af866283dac 100644--- a/api/core/variables/variables.py+++ b/api/core/workflow/variables/variables.py@@ -4,8 +4,6 @@ from uuid import uuid4from pydantic import BaseModel, Discriminator, Field, Tag-from core.helper import encrypter-from .segments import (ArrayAnySegment,ArrayBooleanSegment,@@ -27,6 +25,14 @@ from .segments import (from .types import SegmentType+def _obfuscated_token(token: str) -> str:+ if not token:+ return token+ if len(token) <= 8:+ return "*" * 20+ return token[:6] + "*" * 12 + token[-2:]++class VariableBase(Segment):"""A variable is a segment that has a name.@@ -86,7 +92,7 @@ class SecretVariable(StringVariable):@propertydef log(self) -> str:- return encrypter.obfuscated_token(self.value)+ return _obfuscated_token(self.value)class NoneVariable(NoneSegment, VariableBase):diff --git a/api/core/workflow/workflow_type_encoder.py b/api/core/workflow/workflow_type_encoder.pyindex 93c6a319609..a192b884f76 100644--- a/api/core/workflow/workflow_type_encoder.py+++ b/api/core/workflow/workflow_type_encoder.py@@ -4,8 +4,8 @@ from typing import Any, overloadfrom pydantic import BaseModel-from core.variables import Segmentfrom core.workflow.file.models import File+from core.workflow.variables import Segmentclass WorkflowRuntimeTypeConverter:diff --git a/api/extensions/otel/parser/base.py b/api/extensions/otel/parser/base.pyindex c6589dd99f8..66d1c977d63 100644--- a/api/extensions/otel/parser/base.py+++ b/api/extensions/otel/parser/base.py@@ -9,11 +9,11 @@ from opentelemetry.trace import Spanfrom opentelemetry.trace.status import Status, StatusCodefrom pydantic import BaseModel-from core.variables import Segmentfrom core.workflow.enums import NodeTypefrom core.workflow.file.models import Filefrom core.workflow.graph_events import GraphNodeEventBasefrom core.workflow.nodes.base.node import Node+from core.workflow.variables import Segmentfrom extensions.otel.semconv.gen_ai import ChainAttributes, GenAIAttributesdiff --git a/api/extensions/otel/parser/retrieval.py b/api/extensions/otel/parser/retrieval.pyindex fc151af691c..82cb865b8b9 100644--- a/api/extensions/otel/parser/retrieval.py+++ b/api/extensions/otel/parser/retrieval.py@@ -8,9 +8,9 @@ from typing import Anyfrom opentelemetry.trace import Span-from core.variables import Segmentfrom core.workflow.graph_events import GraphNodeEventBasefrom core.workflow.nodes.base.node import Node+from core.workflow.variables import Segmentfrom extensions.otel.parser.base import DefaultNodeOTelParser, safe_json_dumpsfrom extensions.otel.semconv.gen_ai import RetrieverAttributesdiff --git a/api/factories/variable_factory.py b/api/factories/variable_factory.pyindex a7cfb6a65ec..b74d9517f4f 100644--- a/api/factories/variable_factory.py+++ b/api/factories/variable_factory.py@@ -3,8 +3,13 @@ from typing import Any, castfrom uuid import uuid4from configs import dify_config-from core.variables.exc import VariableError-from core.variables.segments import (+from core.workflow.constants import (+ CONVERSATION_VARIABLE_NODE_ID,+ ENVIRONMENT_VARIABLE_NODE_ID,+)+from core.workflow.file import File+from core.workflow.variables.exc import VariableError+from core.workflow.variables.segments import (ArrayAnySegment,ArrayBooleanSegment,ArrayFileSegment,@@ -21,8 +26,8 @@ from core.variables.segments import (Segment,StringSegment,)-from core.variables.types import SegmentType-from core.variables.variables import (+from core.workflow.variables.types import SegmentType+from core.workflow.variables.variables import (ArrayAnyVariable,ArrayBooleanVariable,ArrayFileVariable,@@ -39,11 +44,6 @@ from core.variables.variables import (StringVariable,VariableBase,)-from core.workflow.constants import (- CONVERSATION_VARIABLE_NODE_ID,- ENVIRONMENT_VARIABLE_NODE_ID,-)-from core.workflow.file import Fileclass UnsupportedSegmentTypeError(Exception):diff --git a/api/fields/_value_type_serializer.py b/api/fields/_value_type_serializer.pyindex b2b793d40ea..461c163e2f0 100644--- a/api/fields/_value_type_serializer.py+++ b/api/fields/_value_type_serializer.py@@ -1,7 +1,7 @@from typing import TypedDict-from core.variables.segments import Segment-from core.variables.types import SegmentType+from core.workflow.variables.segments import Segment+from core.workflow.variables.types import SegmentTypeclass _VarTypedDict(TypedDict, total=False):diff --git a/api/fields/workflow_fields.py b/api/fields/workflow_fields.pyindex 2755f77f612..019949e105a 100644--- a/api/fields/workflow_fields.py+++ b/api/fields/workflow_fields.py@@ -1,7 +1,7 @@from flask_restx import fieldsfrom core.helper import encrypter-from core.variables import SecretVariable, SegmentType, VariableBase+from core.workflow.variables import SecretVariable, SegmentType, VariableBasefrom fields.member_fields import simple_account_fieldsfrom libs.helper import TimestampFielddiff --git a/api/models/workflow.py b/api/models/workflow.pyindex c88a48632a7..6a86251216d 100644--- a/api/models/workflow.py+++ b/api/models/workflow.py@@ -22,8 +22,6 @@ from sqlalchemy import (from sqlalchemy.orm import Mapped, declared_attr, mapped_columnfrom typing_extensions import deprecated-from core.variables import utils as variable_utils-from core.variables.variables import FloatVariable, IntegerVariable, StringVariablefrom core.workflow.constants import (CONVERSATION_VARIABLE_NODE_ID,SYSTEM_VARIABLE_NODE_ID,@@ -33,6 +31,8 @@ from core.workflow.entities.pause_reason import HumanInputRequired, PauseReason,from core.workflow.enums import NodeType, WorkflowExecutionStatusfrom core.workflow.file.constants import maybe_file_objectfrom core.workflow.file.models import File+from core.workflow.variables import utils as variable_utils+from core.workflow.variables.variables import FloatVariable, IntegerVariable, StringVariablefrom extensions.ext_storage import Storagefrom factories.variable_factory import TypeMismatchError, build_segment_with_typefrom libs.datetime_utils import naive_utc_now@@ -46,7 +46,7 @@ if TYPE_CHECKING:from constants import DEFAULT_FILE_NUMBER_LIMITS, HIDDEN_VALUEfrom core.helper import encrypter-from core.variables import SecretVariable, Segment, SegmentType, VariableBase+from core.workflow.variables import SecretVariable, Segment, SegmentType, VariableBasefrom factories import variable_factoryfrom libs import helperdiff --git a/api/services/conversation_service.py b/api/services/conversation_service.pyindex 295d48d8a13..da030656dbe 100644--- a/api/services/conversation_service.py+++ b/api/services/conversation_service.py@@ -10,7 +10,7 @@ from configs import dify_configfrom core.app.entities.app_invoke_entities import InvokeFromfrom core.db.session_factory import session_factoryfrom core.llm_generator.llm_generator import LLMGenerator-from core.variables.types import SegmentType+from core.workflow.variables.types import SegmentTypefrom extensions.ext_database import dbfrom factories import variable_factoryfrom libs.datetime_utils import naive_utc_nowdiff --git a/api/services/conversation_variable_updater.py b/api/services/conversation_variable_updater.pyindex 92008d5ff15..b0012d6f6a2 100644--- a/api/services/conversation_variable_updater.py+++ b/api/services/conversation_variable_updater.py@@ -1,7 +1,7 @@from sqlalchemy import selectfrom sqlalchemy.orm import Session, sessionmaker-from core.variables.variables import VariableBase+from core.workflow.variables.variables import VariableBasefrom models import ConversationVariablediff --git a/api/services/rag_pipeline/rag_pipeline.py b/api/services/rag_pipeline/rag_pipeline.pyindex 4ae3496cd64..c0f9e4f3236 100644--- a/api/services/rag_pipeline/rag_pipeline.py+++ b/api/services/rag_pipeline/rag_pipeline.py@@ -36,7 +36,6 @@ from core.rag.entities.event import ()from core.repositories.factory import DifyCoreRepositoryFactoryfrom core.repositories.sqlalchemy_workflow_node_execution_repository import SQLAlchemyWorkflowNodeExecutionRepository-from core.variables.variables import VariableBasefrom core.workflow.entities.workflow_node_execution import (WorkflowNodeExecution,WorkflowNodeExecutionStatus,@@ -52,6 +51,7 @@ from core.workflow.nodes.node_mapping import LATEST_VERSION, NODE_TYPE_CLASSES_Mfrom core.workflow.repositories.workflow_node_execution_repository import OrderConfigfrom core.workflow.runtime import VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables.variables import VariableBasefrom core.workflow.workflow_entry import WorkflowEntryfrom extensions.ext_database import dbfrom libs.infinite_scroll_pagination import InfiniteScrollPaginationdiff --git a/api/services/trigger/webhook_service.py b/api/services/trigger/webhook_service.pyindex edbc7e0cc8c..75a1350e607 100644--- a/api/services/trigger/webhook_service.py+++ b/api/services/trigger/webhook_service.py@@ -16,9 +16,9 @@ from werkzeug.exceptions import RequestEntityTooLargefrom configs import dify_configfrom core.app.entities.app_invoke_entities import InvokeFromfrom core.tools.tool_file_manager import ToolFileManager-from core.variables.types import SegmentTypefrom core.workflow.enums import NodeTypefrom core.workflow.file.models import FileTransferMethod+from core.workflow.variables.types import SegmentTypefrom enums.quota_type import QuotaTypefrom extensions.ext_database import dbfrom extensions.ext_redis import redis_clientdiff --git a/api/services/variable_truncator.py b/api/services/variable_truncator.pyindex 056ea4d78a4..12be12776ac 100644--- a/api/services/variable_truncator.py+++ b/api/services/variable_truncator.py@@ -6,7 +6,9 @@ from collections.abc import Mappingfrom typing import Any, Generic, TypeAlias, TypeVar, overloadfrom configs import dify_config-from core.variables.segments import (+from core.workflow.file.models import File+from core.workflow.nodes.variable_assigner.common.helpers import UpdatedVariable+from core.workflow.variables.segments import (ArrayFileSegment,ArraySegment,BooleanSegment,@@ -18,9 +20,7 @@ from core.variables.segments import (Segment,StringSegment,)-from core.variables.utils import dumps_with_segments-from core.workflow.file.models import File-from core.workflow.nodes.variable_assigner.common.helpers import UpdatedVariable+from core.workflow.variables.utils import dumps_with_segments_MAX_DEPTH = 100diff --git a/api/services/workflow_draft_variable_service.py b/api/services/workflow_draft_variable_service.pyindex 991925ae6b1..18ad6c5c161 100644--- a/api/services/workflow_draft_variable_service.py+++ b/api/services/workflow_draft_variable_service.py@@ -14,20 +14,20 @@ from sqlalchemy.sql.expression import and_, or_from configs import dify_configfrom core.app.entities.app_invoke_entities import InvokeFrom-from core.variables import Segment, StringSegment, VariableBase-from core.variables.consts import SELECTORS_LENGTH-from core.variables.segments import (- ArrayFileSegment,- FileSegment,-)-from core.variables.types import SegmentType-from core.variables.utils import dumps_with_segmentsfrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, ENVIRONMENT_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_IDfrom core.workflow.enums import SystemVariableKeyfrom core.workflow.file.models import Filefrom core.workflow.nodes import NodeTypefrom core.workflow.nodes.variable_assigner.common.helpers import get_updated_variablesfrom core.workflow.variable_loader import VariableLoader+from core.workflow.variables import Segment, StringSegment, VariableBase+from core.workflow.variables.consts import SELECTORS_LENGTH+from core.workflow.variables.segments import (+ ArrayFileSegment,+ FileSegment,+)+from core.workflow.variables.types import SegmentType+from core.workflow.variables.utils import dumps_with_segmentsfrom extensions.ext_storage import storagefrom factories.file_factory import StorageKeyLoaderfrom factories.variable_factory import build_segment, segment_to_variablediff --git a/api/services/workflow_service.py b/api/services/workflow_service.pyindex abcd41b1bea..406fdae5258 100644--- a/api/services/workflow_service.py+++ b/api/services/workflow_service.py@@ -15,8 +15,6 @@ from core.app.apps.workflow.app_config_manager import WorkflowAppConfigManagerfrom core.app.entities.app_invoke_entities import InvokeFromfrom core.repositories import DifyCoreRepositoryFactoryfrom core.repositories.human_input_repository import HumanInputFormRepositoryImpl-from core.variables import VariableBase-from core.variables.variables import Variablefrom core.workflow.entities import GraphInitParams, WorkflowNodeExecutionfrom core.workflow.entities.pause_reason import HumanInputRequiredfrom core.workflow.enums import ErrorStrategy, WorkflowNodeExecutionMetadataKey, WorkflowNodeExecutionStatus@@ -41,6 +39,8 @@ from core.workflow.repositories.human_input_form_repository import FormCreateParfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariablefrom core.workflow.variable_loader import load_into_variable_pool+from core.workflow.variables import VariableBase+from core.workflow.variables.variables import Variablefrom core.workflow.workflow_entry import WorkflowEntryfrom enums.cloud_plan import CloudPlanfrom events.app_event import app_draft_workflow_was_synced, app_published_workflow_was_updateddiff --git a/api/tests/integration_tests/services/test_workflow_draft_variable_service.py b/api/tests/integration_tests/services/test_workflow_draft_variable_service.pyindex f3a5ba0d11c..5faa002ffff 100644--- a/api/tests/integration_tests/services/test_workflow_draft_variable_service.py+++ b/api/tests/integration_tests/services/test_workflow_draft_variable_service.py@@ -6,11 +6,11 @@ import pytestfrom sqlalchemy import deletefrom sqlalchemy.orm import Session-from core.variables.segments import StringSegment-from core.variables.types import SegmentType-from core.variables.variables import StringVariablefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_IDfrom core.workflow.nodes import NodeType+from core.workflow.variables.segments import StringSegment+from core.workflow.variables.types import SegmentType+from core.workflow.variables.variables import StringVariablefrom extensions.ext_database import dbfrom extensions.ext_storage import storagefrom factories.variable_factory import build_segmentdiff --git a/api/tests/integration_tests/tasks/test_remove_app_and_related_data_task.py b/api/tests/integration_tests/tasks/test_remove_app_and_related_data_task.pyindex d0202336200..a259ccb2b94 100644--- a/api/tests/integration_tests/tasks/test_remove_app_and_related_data_task.py+++ b/api/tests/integration_tests/tasks/test_remove_app_and_related_data_task.py@@ -5,7 +5,7 @@ import pytestfrom sqlalchemy import deletefrom core.db.session_factory import session_factory-from core.variables.segments import StringSegment+from core.workflow.variables.segments import StringSegmentfrom models import Tenantfrom models.enums import CreatorUserRolefrom models.model import App, UploadFile@@ -191,7 +191,7 @@ class TestDeleteDraftVariablesWithOffloadIntegration:@pytest.fixturedef setup_offload_test_data(self, app_and_tenant):tenant, app = app_and_tenant- from core.variables.types import SegmentType+ from core.workflow.variables.types import SegmentTypefrom libs.datetime_utils import naive_utc_nowwith session_factory.create_session() as session:@@ -422,7 +422,7 @@ class TestDeleteDraftVariablesSessionCommit:@pytest.fixturedef setup_offload_test_data(self, app_and_tenant):"""Create test data with offload files for session commit tests."""- from core.variables.types import SegmentType+ from core.workflow.variables.types import SegmentTypefrom libs.datetime_utils import naive_utc_nowtenant, app = app_and_tenantdiff --git a/api/tests/test_containers_integration_tests/services/test_workflow_draft_variable_service.py b/api/tests/test_containers_integration_tests/services/test_workflow_draft_variable_service.pyindex ee155021e3d..1f91b40963e 100644--- a/api/tests/test_containers_integration_tests/services/test_workflow_draft_variable_service.py+++ b/api/tests/test_containers_integration_tests/services/test_workflow_draft_variable_service.py@@ -1,8 +1,8 @@import pytestfrom faker import Faker-from core.variables.segments import StringSegmentfrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID+from core.workflow.variables.segments import StringSegmentfrom models import App, Workflowfrom models.enums import DraftVariableTypefrom models.workflow import WorkflowDraftVariable@@ -467,7 +467,7 @@ class TestWorkflowDraftVariableService:fake = Faker()app = self._create_test_app(db_session_with_containers, mock_external_service_dependencies, fake=fake)workflow = self._create_test_workflow(db_session_with_containers, app, fake=fake)- from core.variables.variables import StringVariable+ from core.workflow.variables.variables import StringVariableconv_var = StringVariable(id=fake.uuid4(),@@ -650,7 +650,7 @@ class TestWorkflowDraftVariableService:fake = Faker()app = self._create_test_app(db_session_with_containers, mock_external_service_dependencies, fake=fake)workflow = self._create_test_workflow(db_session_with_containers, app, fake=fake)- from core.variables.variables import StringVariable+ from core.workflow.variables.variables import StringVariableconv_var1 = StringVariable(id=fake.uuid4(),diff --git a/api/tests/test_containers_integration_tests/tasks/test_remove_app_and_related_data_task.py b/api/tests/test_containers_integration_tests/tasks/test_remove_app_and_related_data_task.pyindex 7ac9573ab77..8501a8e39b6 100644--- a/api/tests/test_containers_integration_tests/tasks/test_remove_app_and_related_data_task.py+++ b/api/tests/test_containers_integration_tests/tasks/test_remove_app_and_related_data_task.py@@ -4,8 +4,8 @@ from unittest.mock import ANY, call, patchimport pytestfrom core.db.session_factory import session_factory-from core.variables.segments import StringSegment-from core.variables.types import SegmentType+from core.workflow.variables.segments import StringSegment+from core.workflow.variables.types import SegmentTypefrom libs.datetime_utils import naive_utc_nowfrom models import Tenantfrom models.enums import CreatorUserRolediff --git a/api/tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py b/api/tests/unit_tests/controllers/console/app/workflow_draft_variables_test.pyindex ec35366d02f..6a287dba366 100644--- a/api/tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py+++ b/api/tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py@@ -13,8 +13,8 @@ from controllers.console.app.workflow_draft_variable import (_WORKFLOW_DRAFT_VARIABLE_WITHOUT_VALUE_FIELDS,_serialize_full_content,)-from core.variables.types import SegmentTypefrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID+from core.workflow.variables.types import SegmentTypefrom factories.variable_factory import build_segmentfrom libs.datetime_utils import naive_utc_nowfrom libs.uuid_utils import uuidv7diff --git a/api/tests/unit_tests/core/app/apps/advanced_chat/test_app_runner_conversation_variables.py b/api/tests/unit_tests/core/app/apps/advanced_chat/test_app_runner_conversation_variables.pyindex 3a4fdc3cd87..0ca54a2f4a2 100644--- a/api/tests/unit_tests/core/app/apps/advanced_chat/test_app_runner_conversation_variables.py+++ b/api/tests/unit_tests/core/app/apps/advanced_chat/test_app_runner_conversation_variables.py@@ -7,7 +7,7 @@ from sqlalchemy.orm import Sessionfrom core.app.apps.advanced_chat.app_runner import AdvancedChatAppRunnerfrom core.app.entities.app_invoke_entities import AdvancedChatAppGenerateEntity, InvokeFrom-from core.variables import SegmentType+from core.workflow.variables import SegmentTypefrom factories import variable_factoryfrom models import ConversationVariable, Workflowdiff --git a/api/tests/unit_tests/core/app/apps/common/test_workflow_response_converter.py b/api/tests/unit_tests/core/app/apps/common/test_workflow_response_converter.pyindex f252324a85d..5508a117c16 100644--- a/api/tests/unit_tests/core/app/apps/common/test_workflow_response_converter.py+++ b/api/tests/unit_tests/core/app/apps/common/test_workflow_response_converter.py@@ -1,8 +1,8 @@from collections.abc import Mapping, Sequencefrom core.app.apps.common.workflow_response_converter import WorkflowResponseConverter-from core.variables.segments import ArrayFileSegment, FileSegmentfrom core.workflow.file import FILE_MODEL_IDENTITY, File, FileTransferMethod, FileType+from core.workflow.variables.segments import ArrayFileSegment, FileSegmentclass TestWorkflowResponseConverterFetchFilesFromVariableValue:diff --git a/api/tests/unit_tests/core/app/layers/test_conversation_variable_persist_layer.py b/api/tests/unit_tests/core/app/layers/test_conversation_variable_persist_layer.pyindex b6e8cc9c8ea..d3ae577d0da 100644--- a/api/tests/unit_tests/core/app/layers/test_conversation_variable_persist_layer.py+++ b/api/tests/unit_tests/core/app/layers/test_conversation_variable_persist_layer.py@@ -3,8 +3,6 @@ from datetime import datetimefrom unittest.mock import Mockfrom core.app.layers.conversation_variable_persist_layer import ConversationVariablePersistenceLayer-from core.variables import StringVariable-from core.variables.segments import Segmentfrom core.workflow.constants import CONVERSATION_VARIABLE_NODE_IDfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.graph_engine.protocols.command_channel import CommandChannel@@ -13,6 +11,8 @@ from core.workflow.node_events import NodeRunResultfrom core.workflow.nodes.variable_assigner.common import helpers as common_helpersfrom core.workflow.runtime.graph_runtime_state_protocol import ReadOnlyGraphRuntimeStatefrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import StringVariable+from core.workflow.variables.segments import Segmentclass MockReadOnlyVariablePool:diff --git a/api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py b/api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.pyindex 1d885f6b2e6..539f0cb581a 100644--- a/api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py+++ b/api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py@@ -13,7 +13,6 @@ from core.app.layers.pause_state_persist_layer import (_AdvancedChatAppGenerateEntityWrapper,_WorkflowGenerateEntityWrapper,)-from core.variables.segments import Segmentfrom core.workflow.entities.pause_reason import SchedulingPausefrom core.workflow.graph_engine.entities.commands import GraphEngineCommandfrom core.workflow.graph_engine.layers.base import GraphEngineLayerNotInitializedError@@ -24,6 +23,7 @@ from core.workflow.graph_events.graph import (GraphRunSucceededEvent,)from core.workflow.runtime.graph_runtime_state_protocol import ReadOnlyVariablePool+from core.workflow.variables.segments import Segmentfrom models.model import AppModefrom repositories.factory import DifyAPIRepositoryFactorydiff --git a/api/tests/unit_tests/core/variables/test_segment.py b/api/tests/unit_tests/core/variables/test_segment.pyindex bb9e3818341..a9af8bea1d4 100644--- a/api/tests/unit_tests/core/variables/test_segment.py+++ b/api/tests/unit_tests/core/variables/test_segment.py@@ -3,7 +3,10 @@ import dataclassesfrom pydantic import BaseModelfrom core.helper import encrypter-from core.variables.segments import (+from core.workflow.file import File, FileTransferMethod, FileType+from core.workflow.runtime import VariablePool+from core.workflow.system_variable import SystemVariable+from core.workflow.variables.segments import (ArrayAnySegment,ArrayFileSegment,ArrayNumberSegment,@@ -19,8 +22,8 @@ from core.variables.segments import (StringSegment,get_segment_discriminator,)-from core.variables.types import SegmentType-from core.variables.variables import (+from core.workflow.variables.types import SegmentType+from core.workflow.variables.variables import (ArrayAnyVariable,ArrayFileVariable,ArrayNumberVariable,@@ -35,9 +38,6 @@ from core.variables.variables import (StringVariable,Variable,)-from core.workflow.file import File, FileTransferMethod, FileType-from core.workflow.runtime import VariablePool-from core.workflow.system_variable import SystemVariabledef test_segment_group_to_text():diff --git a/api/tests/unit_tests/core/variables/test_segment_type.py b/api/tests/unit_tests/core/variables/test_segment_type.pyindex 3bfc5a957f7..e28fed187bb 100644--- a/api/tests/unit_tests/core/variables/test_segment_type.py+++ b/api/tests/unit_tests/core/variables/test_segment_type.py@@ -1,6 +1,6 @@import pytest-from core.variables.types import ArrayValidation, SegmentType+from core.workflow.variables.types import ArrayValidation, SegmentTypeclass TestSegmentTypeIsArrayType:diff --git a/api/tests/unit_tests/core/variables/test_segment_type_validation.py b/api/tests/unit_tests/core/variables/test_segment_type_validation.pyindex 0ec0fc536ec..52e5dd180c5 100644--- a/api/tests/unit_tests/core/variables/test_segment_type_validation.py+++ b/api/tests/unit_tests/core/variables/test_segment_type_validation.py@@ -10,8 +10,10 @@ from typing import Anyimport pytest-from core.variables.segment_group import SegmentGroup-from core.variables.segments import (+from core.workflow.file.enums import FileTransferMethod, FileType+from core.workflow.file.models import File+from core.workflow.variables.segment_group import SegmentGroup+from core.workflow.variables.segments import (ArrayFileSegment,BooleanSegment,FileSegment,@@ -20,9 +22,7 @@ from core.variables.segments import (ObjectSegment,StringSegment,)-from core.variables.types import ArrayValidation, SegmentType-from core.workflow.file.enums import FileTransferMethod, FileType-from core.workflow.file.models import File+from core.workflow.variables.types import ArrayValidation, SegmentTypedef create_test_file(diff --git a/api/tests/unit_tests/core/variables/test_variables.py b/api/tests/unit_tests/core/variables/test_variables.pyindex fb4b18b57a1..6fc162e533b 100644--- a/api/tests/unit_tests/core/variables/test_variables.py+++ b/api/tests/unit_tests/core/variables/test_variables.py@@ -1,7 +1,7 @@import pytestfrom pydantic import ValidationError-from core.variables import (+from core.workflow.variables import (ArrayFileVariable,ArrayVariable,FloatVariable,@@ -11,7 +11,7 @@ from core.variables import (SegmentType,StringVariable,)-from core.variables.variables import VariableBase+from core.workflow.variables.variables import VariableBasedef test_frozen_variables():diff --git a/api/tests/unit_tests/core/workflow/entities/test_variable_pool.py b/api/tests/unit_tests/core/workflow/entities/test_variable_pool.pyindex 18f6753b053..d4254df3194 100644--- a/api/tests/unit_tests/core/workflow/entities/test_variable_pool.py+++ b/api/tests/unit_tests/core/workflow/entities/test_variable_pool.py@@ -1,10 +1,10 @@-from core.variables.segments import (+from core.workflow.runtime import VariablePool+from core.workflow.variables.segments import (BooleanSegment,IntegerSegment,NoneSegment,StringSegment,)-from core.workflow.runtime import VariablePoolclass TestVariablePoolGetAndNestedAttribute:diff --git a/api/tests/unit_tests/core/workflow/graph_engine/command_channels/test_redis_channel.py b/api/tests/unit_tests/core/workflow/graph_engine/command_channels/test_redis_channel.pyindex f33fd0deeba..db9b977e4a9 100644--- a/api/tests/unit_tests/core/workflow/graph_engine/command_channels/test_redis_channel.py+++ b/api/tests/unit_tests/core/workflow/graph_engine/command_channels/test_redis_channel.py@@ -3,7 +3,6 @@import jsonfrom unittest.mock import MagicMock-from core.variables import IntegerVariable, StringVariablefrom core.workflow.graph_engine.command_channels.redis_channel import RedisChannelfrom core.workflow.graph_engine.entities.commands import (AbortCommand,@@ -12,6 +11,7 @@ from core.workflow.graph_engine.entities.commands import (UpdateVariablesCommand,VariableUpdate,)+from core.workflow.variables import IntegerVariable, StringVariableclass TestRedisChannel:diff --git a/api/tests/unit_tests/core/workflow/graph_engine/test_command_system.py b/api/tests/unit_tests/core/workflow/graph_engine/test_command_system.pyindex 1af5a80a56b..6c3700ea2b6 100644--- a/api/tests/unit_tests/core/workflow/graph_engine/test_command_system.py+++ b/api/tests/unit_tests/core/workflow/graph_engine/test_command_system.py@@ -4,7 +4,6 @@ import timefrom unittest.mock import MagicMockfrom core.app.entities.app_invoke_entities import InvokeFrom-from core.variables import IntegerVariable, StringVariablefrom core.workflow.entities.graph_init_params import GraphInitParamsfrom core.workflow.entities.pause_reason import SchedulingPausefrom core.workflow.graph import Graph@@ -20,6 +19,7 @@ from core.workflow.graph_engine.entities.commands import (from core.workflow.graph_events import GraphRunAbortedEvent, GraphRunPausedEvent, GraphRunStartedEventfrom core.workflow.nodes.start.start_node import StartNodefrom core.workflow.runtime import GraphRuntimeState, VariablePool+from core.workflow.variables import IntegerVariable, StringVariablefrom models.enums import UserFromdiff --git a/api/tests/unit_tests/core/workflow/graph_engine/test_mock_nodes_template_code.py b/api/tests/unit_tests/core/workflow/graph_engine/test_mock_nodes_template_code.pyindex e760d7b3d30..6c4178dfede 100644--- a/api/tests/unit_tests/core/workflow/graph_engine/test_mock_nodes_template_code.py+++ b/api/tests/unit_tests/core/workflow/graph_engine/test_mock_nodes_template_code.py@@ -215,9 +215,9 @@ class TestMockTemplateTransformNode:def test_mock_template_transform_node_with_variables(self):"""Test that MockTemplateTransformNode processes templates with variables."""- from core.variables import StringVariablefrom core.workflow.entities import GraphInitParamsfrom core.workflow.runtime import GraphRuntimeState, VariablePool+ from core.workflow.variables import StringVariable# Create test parametersgraph_init_params = GraphInitParams(diff --git a/api/tests/unit_tests/core/workflow/graph_engine/test_table_runner.py b/api/tests/unit_tests/core/workflow/graph_engine/test_table_runner.pyindex 5c85f2be927..5cbb7cf36e2 100644--- a/api/tests/unit_tests/core/workflow/graph_engine/test_table_runner.py+++ b/api/tests/unit_tests/core/workflow/graph_engine/test_table_runner.py@@ -21,15 +21,6 @@ from typing import Anyfrom core.app.workflow.node_factory import DifyNodeFactoryfrom core.tools.utils.yaml_utils import _load_yaml_file-from core.variables import (- ArrayNumberVariable,- ArrayObjectVariable,- ArrayStringVariable,- FloatVariable,- IntegerVariable,- ObjectVariable,- StringVariable,-)from core.workflow.entities.graph_init_params import GraphInitParamsfrom core.workflow.graph import Graphfrom core.workflow.graph_engine import GraphEngine, GraphEngineConfig@@ -41,6 +32,15 @@ from core.workflow.graph_events import ()from core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import (+ ArrayNumberVariable,+ ArrayObjectVariable,+ ArrayStringVariable,+ FloatVariable,+ IntegerVariable,+ ObjectVariable,+ StringVariable,+)from .test_mock_config import MockConfigfrom .test_mock_factory import MockNodeFactorydiff --git a/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py b/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.pyindex 2262d25a141..2c2da3c4f9f 100644--- a/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py+++ b/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py@@ -1,6 +1,5 @@from configs import dify_configfrom core.helper.code_executor.code_executor import CodeLanguage-from core.variables.types import SegmentTypefrom core.workflow.nodes.code.code_node import CodeNodefrom core.workflow.nodes.code.entities import CodeNodeDatafrom core.workflow.nodes.code.exc import (@@ -9,6 +8,7 @@ from core.workflow.nodes.code.exc import (OutputValidationError,)from core.workflow.nodes.code.limits import CodeNodeLimits+from core.workflow.variables.types import SegmentTypeCodeNode._limits = CodeNodeLimits(max_string_length=dify_config.CODE_MAX_STRING_LENGTH,diff --git a/api/tests/unit_tests/core/workflow/nodes/code/entities_spec.py b/api/tests/unit_tests/core/workflow/nodes/code/entities_spec.pyindex d14a6ea69ca..cfdeb30ab81 100644--- a/api/tests/unit_tests/core/workflow/nodes/code/entities_spec.py+++ b/api/tests/unit_tests/core/workflow/nodes/code/entities_spec.py@@ -2,8 +2,8 @@ import pytestfrom pydantic import ValidationErrorfrom core.helper.code_executor.code_executor import CodeLanguage-from core.variables.types import SegmentTypefrom core.workflow.nodes.code.entities import CodeNodeData+from core.workflow.variables.types import SegmentTypeclass TestCodeNodeDataOutput:diff --git a/api/tests/unit_tests/core/workflow/nodes/knowledge_retrieval/test_knowledge_retrieval_node.py b/api/tests/unit_tests/core/workflow/nodes/knowledge_retrieval/test_knowledge_retrieval_node.pyindex 5733b2cf5b2..a60dde199df 100644--- a/api/tests/unit_tests/core/workflow/nodes/knowledge_retrieval/test_knowledge_retrieval_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/knowledge_retrieval/test_knowledge_retrieval_node.py@@ -6,7 +6,6 @@ import pytestfrom core.app.entities.app_invoke_entities import InvokeFromfrom core.model_runtime.entities.llm_entities import LLMUsage-from core.variables import StringSegmentfrom core.workflow.entities import GraphInitParamsfrom core.workflow.enums import WorkflowNodeExecutionStatusfrom core.workflow.nodes.knowledge_retrieval.entities import (@@ -20,6 +19,7 @@ from core.workflow.nodes.knowledge_retrieval.knowledge_retrieval_node import Knofrom core.workflow.repositories.rag_retrieval_protocol import RAGRetrievalProtocol, Sourcefrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import StringSegmentfrom models.enums import UserFromdiff --git a/api/tests/unit_tests/core/workflow/nodes/list_operator/node_spec.py b/api/tests/unit_tests/core/workflow/nodes/list_operator/node_spec.pyindex 366bec50014..63a87623dae 100644--- a/api/tests/unit_tests/core/workflow/nodes/list_operator/node_spec.py+++ b/api/tests/unit_tests/core/workflow/nodes/list_operator/node_spec.py@@ -5,9 +5,9 @@ from core.workflow.graph_engine.entities.graph import Graphfrom core.workflow.graph_engine.entities.graph_init_params import GraphInitParamsfrom core.workflow.graph_engine.entities.graph_runtime_state import GraphRuntimeState-from core.variables import ArrayNumberSegment, ArrayStringSegmentfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.nodes.list_operator.node import ListOperatorNode+from core.workflow.variables import ArrayNumberSegment, ArrayStringSegmentfrom models.workflow import WorkflowTypediff --git a/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py b/api/tests/unit_tests/core/workflow/nodes/llm/test_node.pyindex a235a4167cb..e505aed3230 100644--- a/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/llm/test_node.py@@ -20,7 +20,6 @@ from core.model_runtime.entities.message_entities import ()from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, ModelTypefrom core.model_runtime.model_providers.model_provider_factory import ModelProviderFactory-from core.variables import ArrayAnySegment, ArrayFileSegment, NoneSegmentfrom core.workflow.entities import GraphInitParamsfrom core.workflow.file import File, FileTransferMethod, FileTypefrom core.workflow.nodes.llm import llm_utils@@ -37,6 +36,7 @@ from core.workflow.nodes.llm.node import LLMNodefrom core.workflow.nodes.llm.protocols import CredentialsProvider, ModelFactoryfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import ArrayAnySegment, ArrayFileSegment, NoneSegmentfrom models.enums import UserFromfrom models.provider import ProviderTypediff --git a/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_entities.py b/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_entities.pyindex b28d1d3d0ad..2742b7dab08 100644--- a/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_entities.py+++ b/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_entities.py@@ -1,5 +1,5 @@-from core.variables.types import SegmentTypefrom core.workflow.nodes.parameter_extractor.entities import ParameterConfig+from core.workflow.variables.types import SegmentTypeclass TestParameterConfig:diff --git a/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_parameter_extractor_node.py b/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_parameter_extractor_node.pyindex b359284d00f..ae229bbe2e0 100644--- a/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_parameter_extractor_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/parameter_extractor/test_parameter_extractor_node.py@@ -8,7 +8,6 @@ from typing import Anyimport pytestfrom core.model_runtime.entities import LLMMode-from core.variables.types import SegmentTypefrom core.workflow.nodes.llm import ModelConfig, VisionConfigfrom core.workflow.nodes.parameter_extractor.entities import ParameterConfig, ParameterExtractorNodeDatafrom core.workflow.nodes.parameter_extractor.exc import (@@ -18,6 +17,7 @@ from core.workflow.nodes.parameter_extractor.exc import (RequiredParameterMissingError,)from core.workflow.nodes.parameter_extractor.parameter_extractor_node import ParameterExtractorNode+from core.workflow.variables.types import SegmentTypefrom factories.variable_factory import build_segment_with_typediff --git a/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py b/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.pyindex 669f36c1008..35c59b92c4b 100644--- a/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py@@ -6,9 +6,6 @@ import pytestfrom docx.oxml.text.paragraph import CT_Pfrom core.app.entities.app_invoke_entities import InvokeFrom-from core.variables import ArrayFileSegment-from core.variables.segments import ArrayStringSegment-from core.variables.variables import StringVariablefrom core.workflow.entities import GraphInitParamsfrom core.workflow.enums import NodeType, WorkflowNodeExecutionStatusfrom core.workflow.file import File, FileTransferMethod@@ -20,6 +17,9 @@ from core.workflow.nodes.document_extractor.node import (_extract_text_from_pdf,_extract_text_from_plain_text,)+from core.workflow.variables import ArrayFileSegment+from core.workflow.variables.segments import ArrayStringSegment+from core.workflow.variables.variables import StringVariablefrom models.enums import UserFromdiff --git a/api/tests/unit_tests/core/workflow/nodes/test_if_else.py b/api/tests/unit_tests/core/workflow/nodes/test_if_else.pyindex 930bdbda4a4..bc87a641618 100644--- a/api/tests/unit_tests/core/workflow/nodes/test_if_else.py+++ b/api/tests/unit_tests/core/workflow/nodes/test_if_else.py@@ -6,7 +6,6 @@ import pytestfrom core.app.entities.app_invoke_entities import InvokeFromfrom core.app.workflow.node_factory import DifyNodeFactory-from core.variables import ArrayFileSegmentfrom core.workflow.entities import GraphInitParamsfrom core.workflow.enums import WorkflowNodeExecutionStatusfrom core.workflow.file import File, FileTransferMethod, FileType@@ -16,6 +15,7 @@ from core.workflow.nodes.if_else.if_else_node import IfElseNodefrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariablefrom core.workflow.utils.condition.entities import Condition, SubCondition, SubVariableCondition+from core.workflow.variables import ArrayFileSegmentfrom extensions.ext_database import dbfrom models.enums import UserFromdiff --git a/api/tests/unit_tests/core/workflow/nodes/test_list_operator.py b/api/tests/unit_tests/core/workflow/nodes/test_list_operator.pyindex 66ddc0d3c72..73c17ee45a3 100644--- a/api/tests/unit_tests/core/workflow/nodes/test_list_operator.py+++ b/api/tests/unit_tests/core/workflow/nodes/test_list_operator.py@@ -3,7 +3,6 @@ from unittest.mock import MagicMockimport pytestfrom core.app.entities.app_invoke_entities import InvokeFrom-from core.variables import ArrayFileSegmentfrom core.workflow.enums import WorkflowNodeExecutionStatusfrom core.workflow.file import File, FileTransferMethod, FileTypefrom core.workflow.nodes.list_operator.entities import (@@ -17,6 +16,7 @@ from core.workflow.nodes.list_operator.entities import ()from core.workflow.nodes.list_operator.exc import InvalidKeyErrorfrom core.workflow.nodes.list_operator.node import ListOperatorNode, _get_file_extract_string_func+from core.workflow.variables import ArrayFileSegmentfrom models.enums import UserFromdiff --git a/api/tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py b/api/tests/unit_tests/core/workflow/nodes/tool/test_tool_node.pyindex 526ff72c8cf..d945c6bfffb 100644--- a/api/tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py@@ -11,12 +11,12 @@ import pytestfrom core.model_runtime.entities.llm_entities import LLMUsagefrom core.tools.entities.tool_entities import ToolInvokeMessagefrom core.tools.utils.message_transformer import ToolFileMessageTransformer-from core.variables.segments import ArrayFileSegmentfrom core.workflow.entities import GraphInitParamsfrom core.workflow.file import File, FileTransferMethod, FileTypefrom core.workflow.node_events import StreamChunkEvent, StreamCompletedEventfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables.segments import ArrayFileSegmentif TYPE_CHECKING: # pragma: no cover - imported for type checking onlyfrom core.workflow.nodes.tool.tool_node import ToolNodediff --git a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.pyindex d4b7a017f98..8a52f963ef5 100644--- a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py+++ b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py@@ -4,7 +4,6 @@ from uuid import uuid4from core.app.entities.app_invoke_entities import InvokeFromfrom core.app.workflow.node_factory import DifyNodeFactory-from core.variables import ArrayStringVariable, StringVariablefrom core.workflow.entities import GraphInitParamsfrom core.workflow.graph import Graphfrom core.workflow.graph_events.node import NodeRunSucceededEvent@@ -13,6 +12,7 @@ from core.workflow.nodes.variable_assigner.v1 import VariableAssignerNodefrom core.workflow.nodes.variable_assigner.v1.node_data import WriteModefrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import ArrayStringVariable, StringVariablefrom models.enums import UserFromDEFAULT_NODE_ID = "node_id"diff --git a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_helpers.py b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_helpers.pyindex 1501722b82a..9a874337edb 100644--- a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_helpers.py+++ b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_helpers.py@@ -1,6 +1,6 @@-from core.variables import SegmentTypefrom core.workflow.nodes.variable_assigner.v2.enums import Operationfrom core.workflow.nodes.variable_assigner.v2.helpers import is_input_value_valid+from core.workflow.variables import SegmentTypedef test_is_input_value_valid_overwrite_array_string():diff --git a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.pyindex b08f9c37b40..5ed68fe8d0a 100644--- a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py+++ b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py@@ -4,13 +4,13 @@ from uuid import uuid4from core.app.entities.app_invoke_entities import InvokeFromfrom core.app.workflow.node_factory import DifyNodeFactory-from core.variables import ArrayStringVariablefrom core.workflow.entities import GraphInitParamsfrom core.workflow.graph import Graphfrom core.workflow.nodes.variable_assigner.v2 import VariableAssignerNodefrom core.workflow.nodes.variable_assigner.v2.enums import InputType, Operationfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import ArrayStringVariablefrom models.enums import UserFromDEFAULT_NODE_ID = "node_id"diff --git a/api/tests/unit_tests/core/workflow/nodes/webhook/test_webhook_node.py b/api/tests/unit_tests/core/workflow/nodes/webhook/test_webhook_node.pyindex 8ceaad5cc97..24d3740b99b 100644--- a/api/tests/unit_tests/core/workflow/nodes/webhook/test_webhook_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/webhook/test_webhook_node.py@@ -3,7 +3,6 @@ from unittest.mock import patchimport pytestfrom core.app.entities.app_invoke_entities import InvokeFrom-from core.variables import FileVariable, StringVariablefrom core.workflow.entities.graph_init_params import GraphInitParamsfrom core.workflow.entities.workflow_node_execution import WorkflowNodeExecutionStatusfrom core.workflow.file import File, FileTransferMethod, FileType@@ -18,6 +17,7 @@ from core.workflow.nodes.trigger_webhook.node import TriggerWebhookNodefrom core.workflow.runtime.graph_runtime_state import GraphRuntimeStatefrom core.workflow.runtime.variable_pool import VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables import FileVariable, StringVariablefrom models.enums import UserFromfrom models.workflow import WorkflowTypediff --git a/api/tests/unit_tests/core/workflow/test_variable_pool.py b/api/tests/unit_tests/core/workflow/test_variable_pool.pyindex fb9a893d433..7f2b080498d 100644--- a/api/tests/unit_tests/core/workflow/test_variable_pool.py+++ b/api/tests/unit_tests/core/workflow/test_variable_pool.py@@ -3,8 +3,12 @@ from collections import defaultdictimport pytest-from core.variables import FileSegment, StringSegment-from core.variables.segments import (+from core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, ENVIRONMENT_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID+from core.workflow.file import File, FileTransferMethod, FileType+from core.workflow.runtime import VariablePool+from core.workflow.system_variable import SystemVariable+from core.workflow.variables import FileSegment, StringSegment+from core.workflow.variables.segments import (ArrayAnySegment,ArrayFileSegment,ArrayNumberSegment,@@ -15,7 +19,7 @@ from core.variables.segments import (NoneSegment,ObjectSegment,)-from core.variables.variables import (+from core.workflow.variables.variables import (ArrayNumberVariable,ArrayObjectVariable,ArrayStringVariable,@@ -25,10 +29,6 @@ from core.variables.variables import (StringVariable,Variable,)-from core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, ENVIRONMENT_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID-from core.workflow.file import File, FileTransferMethod, FileType-from core.workflow.runtime import VariablePool-from core.workflow.system_variable import SystemVariablefrom factories.variable_factory import build_segment, segment_to_variablediff --git a/api/tests/unit_tests/core/workflow/test_workflow_entry.py b/api/tests/unit_tests/core/workflow/test_workflow_entry.pyindex 793b0d4eba9..4a71692f1ee 100644--- a/api/tests/unit_tests/core/workflow/test_workflow_entry.py+++ b/api/tests/unit_tests/core/workflow/test_workflow_entry.py@@ -4,7 +4,6 @@ import pytestfrom configs import dify_configfrom core.helper.code_executor.code_executor import CodeLanguage-from core.variables.variables import StringVariablefrom core.workflow.constants import (CONVERSATION_VARIABLE_NODE_ID,ENVIRONMENT_VARIABLE_NODE_ID,@@ -15,6 +14,7 @@ from core.workflow.nodes.code.code_node import CodeNodefrom core.workflow.nodes.code.limits import CodeNodeLimitsfrom core.workflow.runtime import VariablePoolfrom core.workflow.system_variable import SystemVariable+from core.workflow.variables.variables import StringVariablefrom core.workflow.workflow_entry import WorkflowEntrydiff --git a/api/tests/unit_tests/factories/test_variable_factory.py b/api/tests/unit_tests/factories/test_variable_factory.pyindex 53ae18a61d0..87d02cb1871 100644--- a/api/tests/unit_tests/factories/test_variable_factory.py+++ b/api/tests/unit_tests/factories/test_variable_factory.py@@ -7,7 +7,8 @@ import pytestfrom hypothesis import HealthCheck, given, settingsfrom hypothesis import strategies as st-from core.variables import (+from core.workflow.file import File, FileTransferMethod, FileType+from core.workflow.variables import (ArrayNumberVariable,ArrayObjectVariable,ArrayStringVariable,@@ -16,8 +17,8 @@ from core.variables import (SecretVariable,StringVariable,)-from core.variables.exc import VariableError-from core.variables.segments import (+from core.workflow.variables.exc import VariableError+from core.workflow.variables.segments import (ArrayAnySegment,ArrayFileSegment,ArrayNumberSegment,@@ -32,8 +33,7 @@ from core.variables.segments import (Segment,StringSegment,)-from core.variables.types import SegmentType-from core.workflow.file import File, FileTransferMethod, FileType+from core.workflow.variables.types import SegmentTypefrom factories import variable_factoryfrom factories.variable_factory import TypeMismatchError, build_segment, build_segment_with_typediff --git a/api/tests/unit_tests/models/test_conversation_variable.py b/api/tests/unit_tests/models/test_conversation_variable.pyindex 5d84a2ec85d..d44aa564885 100644--- a/api/tests/unit_tests/models/test_conversation_variable.py+++ b/api/tests/unit_tests/models/test_conversation_variable.py@@ -1,6 +1,6 @@from uuid import uuid4-from core.variables import SegmentType+from core.workflow.variables import SegmentTypefrom factories import variable_factoryfrom models import ConversationVariablediff --git a/api/tests/unit_tests/models/test_workflow.py b/api/tests/unit_tests/models/test_workflow.pyindex 29f71767d09..544693da346 100644--- a/api/tests/unit_tests/models/test_workflow.py+++ b/api/tests/unit_tests/models/test_workflow.py@@ -4,10 +4,10 @@ from unittest import mockfrom uuid import uuid4from constants import HIDDEN_VALUE-from core.variables import FloatVariable, IntegerVariable, SecretVariable, StringVariable-from core.variables.segments import IntegerSegment, Segmentfrom core.workflow.file.enums import FileTransferMethod, FileTypefrom core.workflow.file.models import File+from core.workflow.variables import FloatVariable, IntegerVariable, SecretVariable, StringVariable+from core.workflow.variables.segments import IntegerSegment, Segmentfrom factories.variable_factory import build_segmentfrom models.workflow import Workflow, WorkflowDraftVariable, WorkflowNodeExecutionModel, is_system_variable_editablediff --git a/api/tests/unit_tests/services/test_variable_truncator.py b/api/tests/unit_tests/services/test_variable_truncator.pyindex 4534e68b4e5..8199d586dab 100644--- a/api/tests/unit_tests/services/test_variable_truncator.py+++ b/api/tests/unit_tests/services/test_variable_truncator.py@@ -17,7 +17,9 @@ from uuid import uuid4import pytest-from core.variables.segments import (+from core.workflow.file.enums import FileTransferMethod, FileType+from core.workflow.file.models import File+from core.workflow.variables.segments import (ArrayFileSegment,ArrayNumberSegment,ArraySegment,@@ -28,8 +30,6 @@ from core.variables.segments import (ObjectSegment,StringSegment,)-from core.workflow.file.enums import FileTransferMethod, FileType-from core.workflow.file.models import Filefrom services.variable_truncator import (DummyVariableTruncator,MaxDepthExceededError,diff --git a/api/tests/unit_tests/services/workflow/test_draft_var_loader_simple.py b/api/tests/unit_tests/services/workflow/test_draft_var_loader_simple.pyindex 6e03472b9dd..83642fc209f 100644--- a/api/tests/unit_tests/services/workflow/test_draft_var_loader_simple.py+++ b/api/tests/unit_tests/services/workflow/test_draft_var_loader_simple.py@@ -6,8 +6,8 @@ from unittest.mock import Mock, patchimport pytestfrom sqlalchemy import Engine-from core.variables.segments import ObjectSegment, StringSegment-from core.variables.types import SegmentType+from core.workflow.variables.segments import ObjectSegment, StringSegment+from core.workflow.variables.types import SegmentTypefrom models.model import UploadFilefrom models.workflow import WorkflowDraftVariable, WorkflowDraftVariableFilefrom services.workflow_draft_variable_service import DraftVarLoader@@ -174,7 +174,7 @@ class TestDraftVarLoaderSimple:mock_storage.load.return_value = test_json_content.encode()with patch.object(WorkflowDraftVariable, "build_segment_with_type") as mock_build_segment:- from core.variables.segments import FloatSegment+ from core.workflow.variables.segments import FloatSegmentmock_segment = FloatSegment(value=test_number)mock_build_segment.return_value = mock_segment@@ -224,7 +224,7 @@ class TestDraftVarLoaderSimple:mock_storage.load.return_value = test_json_content.encode()with patch.object(WorkflowDraftVariable, "build_segment_with_type") as mock_build_segment:- from core.variables.segments import ArrayAnySegment+ from core.workflow.variables.segments import ArrayAnySegmentmock_segment = ArrayAnySegment(value=test_array)mock_build_segment.return_value = mock_segmentdiff --git a/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py b/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.pyindex 66361f26e07..447e36731c4 100644--- a/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py+++ b/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py@@ -7,10 +7,10 @@ import pytestfrom sqlalchemy import Enginefrom sqlalchemy.orm import Session-from core.variables.segments import StringSegment-from core.variables.types import SegmentTypefrom core.workflow.constants import SYSTEM_VARIABLE_NODE_IDfrom core.workflow.enums import NodeType+from core.workflow.variables.segments import StringSegment+from core.workflow.variables.types import SegmentTypefrom libs.uuid_utils import uuidv7from models.account import Accountfrom models.enums import DraftVariableType