MCPcopy
hub / github.com/1Panel-dev/MaxKB / chat_work_flow

Method chat_work_flow

apps/chat/serializers/chat.py:392–439  ·  view source on GitHub ↗
(self, chat_info: ChatInfo, instance: dict, base_to_response)

Source from the content-addressed store, hash-verified

390 return chat_record
391
392 def chat_work_flow(self, chat_info: ChatInfo, instance: dict, base_to_response):
393 message = instance.get('message')
394 re_chat = instance.get('re_chat')
395 stream = instance.get('stream')
396 chat_user_id = self.data.get("chat_user_id")
397 chat_user_type = self.data.get('chat_user_type')
398 ip_address = self.data.get('ip_address')
399 source = self.data.get('source')
400 form_data = instance.get('form_data')
401 image_list = instance.get('image_list')
402 video_list = instance.get('video_list')
403 document_list = instance.get('document_list')
404 audio_list = instance.get('audio_list')
405 other_list = instance.get('other_list')
406 workspace_id = chat_info.application.workspace_id
407 chat_record_id = instance.get('chat_record_id')
408 debug = self.data.get('debug', False)
409 chat_record = None
410 history_chat_record = chat_info.chat_record_list
411 if chat_record_id is not None:
412 chat_record = self.get_chat_record(chat_info, chat_record_id)
413 if chat_record:
414 history_chat_record = [r for r in chat_info.chat_record_list if str(r.id) != chat_record_id]
415 work_flow = chat_info.application.work_flow
416 work_flow_manage = WorkflowManage(Workflow.new_instance(work_flow),
417 {'history_chat_record': history_chat_record, 'question': message,
418 'chat_id': chat_info.chat_id, 'chat_record_id': str(
419 uuid.uuid7()) if chat_record_id is None else str(chat_record_id),
420 'stream': stream,
421 're_chat': re_chat,
422 'chat_user_id': chat_user_id,
423 'chat_user_type': chat_user_type,
424 'ip_address': ip_address,
425 'source': source,
426 'workspace_id': workspace_id,
427 'debug': debug,
428 'chat_user': chat_info.get_chat_user(),
429 'chat_user_group': chat_info.get_chat_user_group(),
430 'application_id': str(chat_info.application_id)},
431 WorkFlowPostHandler(chat_info),
432 base_to_response, form_data, image_list, document_list, audio_list,
433 video_list,
434 other_list,
435 instance.get('runtime_node_id'),
436 instance.get('node_data'), chat_record, instance.get('child_node'))
437 chat_info.set_chat(message)
438 r = work_flow_manage.run()
439 return r
440
441 def is_valid_chat_user(self):
442 chat_user_id = self.data.get('chat_user_id')

Callers 1

chatMethod · 0.95

Calls 9

get_chat_recordMethod · 0.95
runMethod · 0.95
WorkflowManageClass · 0.90
WorkFlowPostHandlerClass · 0.90
get_chat_userMethod · 0.80
get_chat_user_groupMethod · 0.80
set_chatMethod · 0.80
getMethod · 0.45
new_instanceMethod · 0.45

Tested by

no test coverage detected