@@ -51,28 +51,31 @@ def execute(self, document, chat_id=None, **kwargs):
5151 return NodeResult ({'content' : '' , 'document_list' : []}, {})
5252
5353 # 安全获取 application
54- application = None
54+ application_id = None
5555 if (self .workflow_manage and
5656 self .workflow_manage .work_flow_post_handler and
5757 self .workflow_manage .work_flow_post_handler .chat_info ):
58- application = self .workflow_manage .work_flow_post_handler .chat_info .application
58+ application_id = self .workflow_manage .work_flow_post_handler .chat_info .application .id
59+ knowledge_id = self .workflow_params .get ('knowledge_id' )
5960
6061 # doc文件中的图片保存
6162 def save_image (image_list ):
6263 for image in image_list :
6364 meta = {
64- 'debug' : False if (application and application . id ) else True ,
65+ 'debug' : False if (application_id or knowledge_id ) else True ,
6566 'chat_id' : chat_id ,
66- 'application_id' : str (application .id ) if (application and application .id ) else None ,
67+ 'application_id' : str (application_id ) if application_id else None ,
68+ 'knowledge_id' : str (knowledge_id ) if knowledge_id else None ,
6769 'file_id' : str (image .id )
6870 }
6971 file_bytes = image .meta .pop ('content' )
7072 f = bytes_to_uploaded_file (file_bytes , image .file_name )
7173 FileSerializer (data = {
7274 'file' : f ,
7375 'meta' : meta ,
74- 'source_id' : meta ['application_id' ],
75- 'source_type' : FileSourceType .APPLICATION .value
76+ 'source_id' : meta ['application_id' ] if meta ['application_id' ] else meta ['knowledge_id' ],
77+ 'source_type' : FileSourceType .APPLICATION .value if meta [
78+ 'application_id' ] else FileSourceType .KNOWLEDGE .value
7679 }).upload ()
7780
7881 document_list = []
0 commit comments