mirror of
https://github.com/langgenius/dify.git
synced 2026-03-14 19:38:37 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
from collections.abc import Sequence
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from dify_graph.entities.base_node_data import BaseNodeData
|
|
from dify_graph.enums import NodeType
|
|
|
|
from .enums import InputType, Operation
|
|
|
|
|
|
class VariableOperationItem(BaseModel):
|
|
variable_selector: Sequence[str]
|
|
input_type: InputType
|
|
operation: Operation
|
|
# NOTE(QuantumGhost): The `value` field serves multiple purposes depending on context:
|
|
#
|
|
# 1. For CONSTANT input_type: Contains the literal value to be used in the operation.
|
|
# 2. For VARIABLE input_type: Initially contains the selector of the source variable.
|
|
# 3. During the variable updating procedure: The `value` field is reassigned to hold
|
|
# the resolved actual value that will be applied to the target variable.
|
|
value: Any = None
|
|
|
|
|
|
class VariableAssignerNodeData(BaseNodeData):
|
|
type: NodeType = NodeType.VARIABLE_ASSIGNER
|
|
version: str = "2"
|
|
items: Sequence[VariableOperationItem] = Field(default_factory=list)
|