davda54 commited on
Commit
500ab62
·
1 Parent(s): 696a3a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -41,8 +41,8 @@ LANGUAGE_IDS = {
41
 
42
  class BatchStreamer(TextIteratorStreamer):
43
  def put(self, value):
44
- if value.size(0) == 1:
45
- return super().put(value)
46
 
47
  if len(self.token_cache) == 0:
48
  self.token_cache = [[] for _ in range(value.size(0))]
@@ -51,9 +51,9 @@ class BatchStreamer(TextIteratorStreamer):
51
 
52
  # Add the new token to the cache and decodes the entire thing.
53
  for c, v in zip(self.token_cache, value):
54
- c.extend(v)
55
 
56
- paragraphs = [tokenizer.decode(p, **self.decode_kwargs).strip() for c in self.token_cache]
57
  text = '\n'.join(paragraphs)
58
 
59
  self.on_finalized_text(text)
 
41
 
42
  class BatchStreamer(TextIteratorStreamer):
43
  def put(self, value):
44
+ #if value.size(0) == 1:
45
+ # return super().put(value)
46
 
47
  if len(self.token_cache) == 0:
48
  self.token_cache = [[] for _ in range(value.size(0))]
 
51
 
52
  # Add the new token to the cache and decodes the entire thing.
53
  for c, v in zip(self.token_cache, value):
54
+ c += v
55
 
56
+ paragraphs = [tokenizer.decode(c, **self.decode_kwargs).strip() for c in self.token_cache]
57
  text = '\n'.join(paragraphs)
58
 
59
  self.on_finalized_text(text)