@@ -172,6 +172,7 @@ def bytes_to_uploaded_file(file_bytes, file_name="unknown"):
172172 )
173173 return uploaded_file
174174
175+
175176def _get_result_detail (result ):
176177 if isinstance (result , dict ):
177178 result_dict = {k : (str (v )[:500 ] if len (str (v )) > 500 else v ) for k , v in result .items ()}
@@ -240,18 +241,19 @@ def execute(self, tool_lib_id, input_field_list, **kwargs) -> NodeResult:
240241 else :
241242 result = function_executor .exec_code (tool_lib .code , all_params )
242243 else :
243- result = self .tool_exec_record (tool_lib_id , tool_lib . code , all_params )
244+ result = self .tool_exec_record (tool_lib , all_params )
244245 return NodeResult ({'result' : result },
245246 (self .workflow_manage .params .get ('knowledge_base' ) or {}) if self .node .properties .get (
246247 'kind' ) == 'data-source' else {}, _write_context = write_context )
247248
248- def tool_exec_record (self , tool_lib_id , code , all_params ):
249+ def tool_exec_record (self , tool_lib , all_params ):
249250 task_record_id = uuid .uuid7 ()
250251 start_time = time .time ()
251252 try :
252253 ToolRecord (
253254 id = task_record_id ,
254- tool_id = tool_lib_id ,
255+ workflow_id = tool_lib .workspace_id ,
256+ tool_id = tool_lib .id ,
255257 source_type = ToolTaskTypeChoices .KNOWLEDGE .value if self .workflow_manage .params .get (
256258 'knowledge_id' ) else ToolTaskTypeChoices .APPLICATION .value ,
257259 source_id = self .workflow_manage .params .get ('knowledge_id' ) or self .workflow_manage .params .get (
@@ -260,7 +262,7 @@ def tool_exec_record(self, tool_lib_id, code, all_params):
260262 state = State .STARTED
261263 ).save ()
262264
263- result = function_executor .exec_code (code , all_params )
265+ result = function_executor .exec_code (tool_lib . code , all_params )
264266 result_dict = _get_result_detail (result )
265267 QuerySet (ToolRecord ).filter (id = task_record_id ).update (
266268 state = State .SUCCESS ,
0 commit comments