Skip to content

Commit ca94c60

Browse files
authored
fix vllm llamaindex stream bug (#679)
Signed-off-by: Xinyao Wang <[email protected]>
1 parent 6ce6551 commit ca94c60

File tree

1 file changed

+3
-5
lines changed
  • comps/llms/text-generation/vllm/llama_index

1 file changed

+3
-5
lines changed

comps/llms/text-generation/vllm/llama_index/llm.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ def llm_generate(input: LLMParamsDoc):
5757
if input.streaming:
5858

5959
def stream_generator():
60-
chat_response = ""
6160
for text in llm.stream_complete(input.query):
62-
chat_response += text
63-
chunk_repr = repr(text.encode("utf-8"))
64-
yield f"data: {chunk_repr}\n\n"
61+
output = text.text
62+
yield f"data: {output}\n\n"
6563
if logflag:
66-
logger.info(f"[llm - chat_stream] stream response: {chat_response}")
64+
logger.info(f"[llm - chat_stream] stream response: {output}")
6765
yield "data: [DONE]\n\n"
6866

6967
return StreamingResponse(stream_generator(), media_type="text/event-stream")

0 commit comments

Comments
 (0)