@@ -171,16 +171,19 @@ def save_context(self, details, workflow_manage):
171171 if self .node_params .get ('is_result' , False ):
172172 self .answer_text = details .get ('answer' )
173173
174- def execute (self , application_id , message , chat_id , chat_record_id , stream , re_chat , client_id , client_type ,
174+ def execute (self , application_id , message , chat_id , chat_record_id , stream , re_chat ,
175+ chat_user_id ,
176+ chat_user_type ,
175177 app_document_list = None , app_image_list = None , app_audio_list = None , child_node = None , node_data = None ,
176178 ** kwargs ) -> NodeResult :
177- from application .serializers .chat_message_serializers import ChatMessageSerializer
179+ from chat .serializers .chat import ChatSerializers
178180 # 生成嵌入应用的chat_id
179181 current_chat_id = string_to_uuid (chat_id + application_id )
180182 Chat .objects .get_or_create (id = current_chat_id , defaults = {
181183 'application_id' : application_id ,
182184 'abstract' : message [0 :1024 ],
183- 'client_id' : client_id ,
185+ 'chat_user_id' : chat_user_id ,
186+ 'chat_user_type' : chat_user_type
184187 })
185188 if app_document_list is None :
186189 app_document_list = []
@@ -197,22 +200,26 @@ def execute(self, application_id, message, chat_id, chat_record_id, stream, re_c
197200 child_node_value = child_node .get ('child_node' )
198201 application_node_dict = self .context .get ('application_node_dict' )
199202 reset_application_node_dict (application_node_dict , runtime_node_id , node_data )
203+ response = ChatSerializers (data = {
204+ "chat_id" : current_chat_id ,
205+ "chat_user_id" : chat_user_id ,
206+ 'chat_user_type' : chat_user_type ,
207+ 'application_id' : application_id ,
208+ 'debug' : False
209+ }).chat (instance =
210+ {'message' : message ,
211+ 're_chat' : re_chat ,
212+ 'stream' : stream ,
213+ 'document_list' : app_document_list ,
214+ 'image_list' : app_image_list ,
215+ 'audio_list' : app_audio_list ,
216+ 'runtime_node_id' : runtime_node_id ,
217+ 'chat_record_id' : record_id ,
218+ 'child_node' : child_node_value ,
219+ 'node_data' : node_data ,
220+ 'form_data' : kwargs }
221+ )
200222
201- response = ChatMessageSerializer (
202- data = {'chat_id' : current_chat_id , 'message' : message ,
203- 're_chat' : re_chat ,
204- 'stream' : stream ,
205- 'application_id' : application_id ,
206- 'client_id' : client_id ,
207- 'client_type' : client_type ,
208- 'document_list' : app_document_list ,
209- 'image_list' : app_image_list ,
210- 'audio_list' : app_audio_list ,
211- 'runtime_node_id' : runtime_node_id ,
212- 'chat_record_id' : record_id ,
213- 'child_node' : child_node_value ,
214- 'node_data' : node_data ,
215- 'form_data' : kwargs }).chat ()
216223 if response .status_code == 200 :
217224 if stream :
218225 content_generator = response .streaming_content
0 commit comments