Spaces:
Sleeping
Sleeping
ts streaming
Browse files
app.py
CHANGED
|
@@ -21,10 +21,14 @@ def generate_streaming_wrapper(query: str, context: str):
|
|
| 21 |
# Convert async generator to sync generator
|
| 22 |
async_gen = _async_generator()
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
while True:
|
| 25 |
try:
|
| 26 |
chunk = loop.run_until_complete(async_gen.__anext__())
|
| 27 |
-
|
|
|
|
| 28 |
except StopAsyncIteration:
|
| 29 |
break
|
| 30 |
|
|
|
|
| 21 |
# Convert async generator to sync generator
|
| 22 |
async_gen = _async_generator()
|
| 23 |
|
| 24 |
+
# Accumulate chunks for Gradio streaming
|
| 25 |
+
accumulated_text = ""
|
| 26 |
+
|
| 27 |
while True:
|
| 28 |
try:
|
| 29 |
chunk = loop.run_until_complete(async_gen.__anext__())
|
| 30 |
+
accumulated_text += chunk
|
| 31 |
+
yield accumulated_text # Yield the accumulated text, not just the chunk
|
| 32 |
except StopAsyncIteration:
|
| 33 |
break
|
| 34 |
|