kz209 commited on
Commit
5e80f43
1 Parent(s): 3ccffef
Files changed (1) hide show
  1. utils/multiple_stream.py +6 -8
utils/multiple_stream.py CHANGED
@@ -24,22 +24,20 @@ def stream_data(content_list, model):
24
  outputs = ["" for _ in content_list]
25
 
26
  # Use the gen method to handle batch generation
 
 
27
  while True:
28
  updated = False
29
- #for i, content in enumerate(content_list):
30
  try:
31
- id, word = next(model.gen(content_list, streaming=True)) # Wrap content in a list to match expected input type
32
- print(outputs)
33
- print(id, word)
34
  outputs[id] += f" {word}"
35
  updated = True
36
  except StopIteration:
37
- pass
38
-
39
- if not updated:
40
  break
41
 
42
- yield tuple(outputs)
 
43
 
44
 
45
  def create_interface():
 
24
  outputs = ["" for _ in content_list]
25
 
26
  # Use the gen method to handle batch generation
27
+ generator = model.gen(content_list, streaming=True)
28
+
29
  while True:
30
  updated = False
31
+
32
  try:
33
+ id, word = next(generator) # Get the next generated word for the corresponding content
 
 
34
  outputs[id] += f" {word}"
35
  updated = True
36
  except StopIteration:
 
 
 
37
  break
38
 
39
+ if updated:
40
+ yield tuple(outputs)
41
 
42
 
43
  def create_interface():