Skip to content

Commit

Permalink
Fixed character overlap issue when api streaming output (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
Somezak1 authored Sep 18, 2023
1 parent 3149253 commit 2e0e60b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastchat/serve/openai_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2e0e60b

Please sign in to comment.