mtyrrell commited on
Commit
7d8975d
·
1 Parent(s): 738c309

ts streaming

Browse files
Files changed (1) hide show
  1. app.py +5 -1
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
- yield chunk
 
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