Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
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
|
55 |
|
56 |
-
paragraphs = [tokenizer.decode(
|
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)
|