From a1633e0a2f31ede1f142af3ae67b1753b2f97dc9 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Thu, 28 Aug 2025 09:34:47 +0800 Subject: [PATCH] Fix: second round value removal. (#9756) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/canvas.py | 2 ++ agent/component/base.py | 4 +++- api/db/db_models.py | 14 +++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/agent/canvas.py b/agent/canvas.py index 2d8525876..a2f7c1683 100644 --- a/agent/canvas.py +++ b/agent/canvas.py @@ -208,6 +208,8 @@ class Canvas: self.message_id = get_uuid() created_at = int(time.time()) self.add_user_input(kwargs.get("query")) + for k, cpn in self.components.items(): + self.components[k]["obj"].reset(True) for k in kwargs.keys(): if k in ["query", "user_id", "files"] and kwargs[k]: diff --git a/agent/component/base.py b/agent/component/base.py index 3471a4631..d7a3d2f03 100644 --- a/agent/component/base.py +++ b/agent/component/base.py @@ -448,9 +448,11 @@ class ComponentBase(ABC): def error(self): return self._param.outputs.get("_ERROR", {}).get("value") - def reset(self): + def reset(self, only_output=False): for k in self._param.outputs.keys(): self._param.outputs[k]["value"] = None + if only_output: + return for k in self._param.inputs.keys(): self._param.inputs[k]["value"] = None self._param.debug_inputs = {} diff --git a/api/db/db_models.py b/api/db/db_models.py index 6a1291baa..bfae37838 100644 --- a/api/db/db_models.py +++ b/api/db/db_models.py @@ -824,9 +824,8 @@ class UserCanvas(DataBaseModel): class CanvasTemplate(DataBaseModel): id = CharField(max_length=32, primary_key=True) avatar = TextField(null=True, help_text="avatar base64 string") - title = CharField(max_length=255, null=True, help_text="Canvas title") - - description = TextField(null=True, help_text="Canvas description") + title = JSONField(null=True, default=dict, help_text="Canvas title") + description = JSONField(null=True, default=dict, help_text="Canvas description") canvas_type = CharField(max_length=32, null=True, help_text="Canvas type", index=True) dsl = JSONField(null=True, default={}) @@ -1021,4 +1020,13 @@ def migrate_db(): migrate(migrator.add_column("dialog", "meta_data_filter", JSONField(null=True, default={}))) except Exception: pass + + try: + migrate(migrator.alter_column_type("canvas_template", "title", JSONField(null=True, default=dict, help_text="Canvas title"))) + except Exception: + pass + try: + migrate(migrator.alter_column_type("canvas_template", "description", JSONField(null=True, default=dict, help_text="Canvas description"))) + except Exception: + pass logging.disable(logging.NOTSET)