(self, chat_info: ChatInfo, instance, base_to_response)
| 335 | return chat_info |
| 336 | |
| 337 | def chat_simple(self, chat_info: ChatInfo, instance, base_to_response): |
| 338 | message = instance.get('message') |
| 339 | re_chat = instance.get('re_chat') |
| 340 | stream = instance.get('stream') |
| 341 | chat_user_id = self.data.get('chat_user_id') |
| 342 | chat_user_type = self.data.get('chat_user_type') |
| 343 | ip_address = self.data.get('ip_address') |
| 344 | source = self.data.get('source') |
| 345 | form_data = instance.get("form_data") |
| 346 | chat_record_id = instance.get('chat_record_id') |
| 347 | pipeline_manage_builder = PipelineManage.builder() |
| 348 | # 如果开启了问题优化,则添加上问题优化步骤 |
| 349 | if chat_info.application.problem_optimization: |
| 350 | pipeline_manage_builder.append_step(BaseResetProblemStep) |
| 351 | # 构建流水线管理器 |
| 352 | pipeline_message = (pipeline_manage_builder.append_step(BaseSearchDatasetStep) |
| 353 | .append_step(BaseGenerateHumanMessageStep) |
| 354 | .append_step(BaseChatStep) |
| 355 | .add_base_to_response(base_to_response) |
| 356 | .add_debug(self.data.get('debug', False)) |
| 357 | .build()) |
| 358 | exclude_paragraph_id_list = [] |
| 359 | # 相同问题是否需要排除已经查询到的段落 |
| 360 | if re_chat: |
| 361 | paragraph_id_list = flat_map( |
| 362 | [[paragraph.get('id') for paragraph in chat_record.details['search_step']['paragraph_list']] for |
| 363 | chat_record in chat_info.chat_record_list if |
| 364 | chat_record.problem_text == message and 'search_step' in chat_record.details and 'paragraph_list' in |
| 365 | chat_record.details['search_step']]) |
| 366 | exclude_paragraph_id_list = list(set(paragraph_id_list)) |
| 367 | # 构建运行参数 |
| 368 | params = chat_info.to_pipeline_manage_params(message, get_post_handler(chat_info), exclude_paragraph_id_list, |
| 369 | chat_user_id, chat_user_type, ip_address, source, stream, |
| 370 | form_data) |
| 371 | if chat_record_id: |
| 372 | params['chat_record_id'] = chat_record_id |
| 373 | chat_info.set_chat(message) |
| 374 | # 运行流水线作业 |
| 375 | pipeline_message.run(params) |
| 376 | return pipeline_message.context['chat_result'] |
| 377 | |
| 378 | @staticmethod |
| 379 | def get_chat_record(chat_info, chat_record_id): |
no test coverage detected