This commit is contained in:
jyong
2025-04-17 15:07:23 +08:00
parent 9f8e05d9f0
commit 5c4bf2a9e4
49 changed files with 5609 additions and 122 deletions

View File

@ -130,6 +130,9 @@ class Workflow(Base):
_conversation_variables: Mapped[str] = mapped_column(
"conversation_variables", db.Text, nullable=False, server_default="{}"
)
_pipeline_variables: Mapped[str] = mapped_column(
"conversation_variables", db.Text, nullable=False, server_default="{}"
)
@classmethod
def new(
@ -343,6 +346,24 @@ class Workflow(Base):
ensure_ascii=False,
)
@property
def pipeline_variables(self) -> dict[str, Sequence[Variable]]:
# TODO: find some way to init `self._conversation_variables` when instance created.
if self._pipeline_variables is None:
self._pipeline_variables = "{}"
variables_dict: dict[str, Any] = json.loads(self._pipeline_variables)
results = {}
for k, v in variables_dict.items():
results[k] = [variable_factory.build_pipeline_variable_from_mapping(item) for item in v.values()]
return results
@pipeline_variables.setter
def pipeline_variables(self, values: dict[str, Sequence[Variable]]) -> None:
self._pipeline_variables = json.dumps(
{k: {item.name: item.model_dump() for item in v} for k, v in values.items()},
ensure_ascii=False,
)
class WorkflowRunStatus(StrEnum):
"""