Spaces:
Sleeping
Sleeping
Sam
commited on
Commit
·
e159a2b
1
Parent(s):
12db87c
Switching to for loop instead of async for loop to fix response streaming
Browse files
app.py
CHANGED
@@ -168,15 +168,14 @@ async def handle_message(message: cl.Message):
|
|
168 |
# Create a generator from the RAG chain
|
169 |
response_generator = retrieval_augmented_qa_chain.stream({"question": message.content})
|
170 |
|
171 |
-
#
|
172 |
-
|
173 |
# Extract the content from the chunk
|
174 |
chunk_content = response_chunk.get("response", {}).get("content", "")
|
175 |
if chunk_content:
|
176 |
# Stream the chunk to Chainlit
|
177 |
await stream_msg.stream_token(chunk_content)
|
178 |
|
179 |
-
|
180 |
## Remove to stream the response
|
181 |
# response = retrieval_augmented_qa_chain.invoke({"question": message.content})
|
182 |
|
|
|
168 |
# Create a generator from the RAG chain
|
169 |
response_generator = retrieval_augmented_qa_chain.stream({"question": message.content})
|
170 |
|
171 |
+
# Use a standard for loop instead of async for
|
172 |
+
for response_chunk in response_generator:
|
173 |
# Extract the content from the chunk
|
174 |
chunk_content = response_chunk.get("response", {}).get("content", "")
|
175 |
if chunk_content:
|
176 |
# Stream the chunk to Chainlit
|
177 |
await stream_msg.stream_token(chunk_content)
|
178 |
|
|
|
179 |
## Remove to stream the response
|
180 |
# response = retrieval_augmented_qa_chain.invoke({"question": message.content})
|
181 |
|