From 2252578da03234607101bba8d373e284523ae49d Mon Sep 17 00:00:00 2001 From: Yang An Date: Wed, 16 Aug 2023 15:10:10 +0800 Subject: [PATCH] Update openai_api.py --- openai_api.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openai_api.py b/openai_api.py index 6f90458..568984f 100644 --- a/openai_api.py +++ b/openai_api.py @@ -123,11 +123,10 @@ async def create_chat_completion(request: ChatCompletionRequest): generate = predict(query, history, request.model) return EventSourceResponse(generate, media_type="text/event-stream") - responses = [resp for resp in model.chat_stream(tokenizer, query, history=history)] - combined_response = ''.join(responses) + response, _ = model.chat_stream(tokenizer, query, history=history) choice_data = ChatCompletionResponseChoice( index=0, - message=ChatMessage(role="assistant", content=combined_response), + message=ChatMessage(role="assistant", content=response), finish_reason="stop" )