Skip to content

Commit deb3818

Browse files
authored
Merge pull request ggml-org#1 from sumo43/master
Fix streaming
2 parents ad67d5e + 0bddcd9 commit deb3818

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

run_wrap.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717

1818
t0 = time.time()
1919
tokens = []
20+
last = ''
2021
for line in proc.stdout:
2122
token = int(line.decode('utf-8').strip())
22-
dec = enc.decode([token])
23-
print(dec, end=" ", flush=True)
23+
dec = enc.decode(tokens + [token])
24+
chunk = dec[len(last):]
25+
print(chunk, end='',flush=True)
2426
tokens.append(token)
27+
last = dec
2528
t1 = time.time()
2629

27-
print('\n---\n')
28-
print("Sorry I'm not sure why sentencepiece can't stream tokens properly, I'll solve it later. Here is the whole thing properly:")
2930
print('\n---\n')
3031
print(enc.decode(tokens))
3132

0 commit comments

Comments
 (0)