@@ -79,15 +79,23 @@ class Code(ComponentBase, ABC):
79
79
def _run (self , history , ** kwargs ):
80
80
arguments = {}
81
81
for input in self ._param .arguments :
82
- assert "@" in input ["component_id" ], "Each code argument should bind to a specific compontent"
83
- component_id = input ["component_id" ].split ("@" )[0 ]
84
- refered_component_key = input ["component_id" ].split ("@" )[1 ]
85
- refered_component = self ._canvas .get_component (component_id )["obj" ]
86
-
87
- for param in refered_component ._param .query :
88
- if param ["key" ] == refered_component_key :
89
- if "value" in param :
90
- arguments [input ["name" ]] = param ["value" ]
82
+ if "@" in input ["component_id" ]:
83
+ component_id = input ["component_id" ].split ("@" )[0 ]
84
+ refered_component_key = input ["component_id" ].split ("@" )[1 ]
85
+ refered_component = self ._canvas .get_component (component_id )["obj" ]
86
+
87
+ for param in refered_component ._param .query :
88
+ if param ["key" ] == refered_component_key :
89
+ if "value" in param :
90
+ arguments [input ["name" ]] = param ["value" ]
91
+ else :
92
+ cpn = self ._canvas .get_component (input ["component_id" ])["obj" ]
93
+ if cpn .component_name .lower () == "answer" :
94
+ arguments [input ["name" ]] = self ._canvas .get_history (1 )[0 ]["content" ]
95
+ continue
96
+ _ , out = cpn .output (allow_partial = False )
97
+ if not out .empty :
98
+ arguments [input ["name" ]] = "\n " .join (out ["content" ])
91
99
92
100
return self ._execute_code (
93
101
language = self ._param .lang ,
0 commit comments