From a6085c2a919afa4434080c248f1ec02ed004ab51 Mon Sep 17 00:00:00 2001 From: Jianxin Ma Date: Fri, 15 Mar 2024 19:02:59 +0800 Subject: [PATCH] bugfix streaming mode of openai_api.py --- openai_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openai_api.py b/openai_api.py index 0e127c6..3d12822 100644 --- a/openai_api.py +++ b/openai_api.py @@ -484,7 +484,7 @@ async def predict( stop_words_ids = [tokenizer.encode(s) for s in stop_words] if stop_words else None - delay_token_num = max([len(x) for x in stop_words]) + delay_token_num = max([len(x) for x in stop_words]) if stop_words_ids else 0 response_generator = model.chat_stream(tokenizer, query, history=history, @@ -493,8 +493,8 @@ async def predict( **gen_kwargs) for _new_response in response_generator: if len(_new_response) <= delay_token_num: - continue - new_response = _new_response[:-delay_token_num] + continue + new_response = _new_response[:-delay_token_num] if delay_token_num else _new_response if len(new_response) == current_length: continue