From 2e0e60b4db2613a47632edcbff458ebee7fa85ee Mon Sep 17 00:00:00 2001 From: Shangwei Chen <109785802+Somezak1@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:17:52 +0800 Subject: [PATCH] Fixed character overlap issue when api streaming output (#2431) --- fastchat/serve/openai_api_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastchat/serve/openai_api_server.py b/fastchat/serve/openai_api_server.py index 02e8481f4..7b596de64 100644 --- a/fastchat/serve/openai_api_server.py +++ b/fastchat/serve/openai_api_server.py @@ -435,7 +435,7 @@ async def chat_completion_stream_generator( return decoded_unicode = content["text"].replace("\ufffd", "") delta_text = decoded_unicode[len(previous_text) :] - previous_text = decoded_unicode + previous_text = decoded_unicode if len(decoded_unicode) > len(previous_text) else previous_text if len(delta_text) == 0: delta_text = None @@ -554,7 +554,7 @@ async def generate_completion_stream_generator( return decoded_unicode = content["text"].replace("\ufffd", "") delta_text = decoded_unicode[len(previous_text) :] - previous_text = decoded_unicode + previous_text = decoded_unicode if len(decoded_unicode) > len(previous_text) else previous_text # todo: index is not apparent choice_data = CompletionResponseStreamChoice( index=i,