From 01a122dc9dc6b540a4ab009f3b88dd7cac51fb00 Mon Sep 17 00:00:00 2001 From: WANGRUI-ZB <50860994+WANGRUI-ZB@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:40:27 +0800 Subject: [PATCH] fix bug, agent invoke can not get params from begin (#4390) ### What problem does this PR solve? fix bug, agent invoke can not get params from begin ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: wangrui --- agent/component/invoke.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/agent/component/invoke.py b/agent/component/invoke.py index a8be31f6f..8f36c8c14 100644 --- a/agent/component/invoke.py +++ b/agent/component/invoke.py @@ -50,12 +50,22 @@ class Invoke(ComponentBase, ABC): args = {} for para in self._param.variables: if para.get("component_id"): - cpn = self._canvas.get_component(para["component_id"])["obj"] - if cpn.component_name.lower() == "answer": - args[para["key"]] = self._canvas.get_history(1)[0]["content"] - continue - _, out = cpn.output(allow_partial=False) - args[para["key"]] = "\n".join(out["content"]) + if '@' in para["component_id"]: + component = para["component_id"].split('@')[0] + field = para["component_id"].split('@')[1] + cpn = self._canvas.get_component(component)["obj"] + for param in cpn._param.query: + if param["key"] == field: + if "value" in param: + args[para["key"]] = param["value"] + else: + cpn = self._canvas.get_component(para["component_id"])["obj"] + if cpn.component_name.lower() == "answer": + args[para["key"]] = self._canvas.get_history(1)[0]["content"] + continue + _, out = cpn.output(allow_partial=False) + if not out.empty: + args[para["key"]] = "\n".join(out["content"]) else: args[para["key"]] = para["value"]