From cc48f56f6744d42eecd76a0930f19705a7d13825 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:07:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AE=80=E6=98=93?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=AF=B9=E8=AF=9D=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=86=85=E5=AE=B9=20(#1722)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../step/chat_step/impl/base_chat_step.py | 20 ++++++++++++++----- ui/src/api/type/application.ts | 6 +++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py b/apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py index 4cad1796e..8d59deaa7 100644 --- a/apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py +++ b/apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py @@ -65,9 +65,12 @@ def event_content(response, try: for chunk in response: all_text += chunk.content - yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), chunk.content, + yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), 'ai-chat-node', + [], chunk.content, False, - 0, 0) + 0, 0, {'node_is_end': False, + 'view_type': 'many_view', + 'node_type': 'ai-chat-node'}) # 获取token if is_ai_chat: try: @@ -82,8 +85,11 @@ def event_content(response, write_context(step, manage, request_token, response_token, all_text) post_response_handler.handler(chat_id, chat_record_id, paragraph_list, problem_text, all_text, manage, step, padding_problem_text, client_id) - yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), '', True, - request_token, response_token) + yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), 'ai-chat-node', + [], '', True, + request_token, response_token, + {'node_is_end': True, 'view_type': 'many_view', + 'node_type': 'ai-chat-node'}) add_access_num(client_id, client_type) except Exception as e: logging.getLogger("max_kb_error").error(f'{str(e)}:{traceback.format_exc()}') @@ -92,7 +98,11 @@ def event_content(response, post_response_handler.handler(chat_id, chat_record_id, paragraph_list, problem_text, all_text, manage, step, padding_problem_text, client_id) add_access_num(client_id, client_type) - yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), all_text, True, 0, 0) + yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), all_text, + 'ai-chat-node', + [], True, 0, 0, + {'node_is_end': True, 'view_type': 'many_view', + 'node_type': 'ai-chat-node'}) class BaseChatStep(IChatStep): diff --git a/ui/src/api/type/application.ts b/ui/src/api/type/application.ts index bd4edeca8..b45a6783f 100644 --- a/ui/src/api/type/application.ts +++ b/ui/src/api/type/application.ts @@ -257,9 +257,9 @@ export class ChatRecordManage { } } append(answer_text_block: string) { - for (let index = 0; index < answer_text_block.length; index++) { - this.chat.buffer.push(answer_text_block[index]) - } + const index =this.chat.answer_text_list.indexOf("") + this.chat.answer_text_list[index]=answer_text_block + } }