Skip to content

Commit a004002

Browse files
committed
Always flush text streamer after prompt
1 parent 815916e commit a004002

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/generation/streamers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ export class TextStreamer extends BaseStreamer {
7272
throw Error('TextStreamer only supports batch size of 1');
7373
}
7474

75-
if (this.skip_prompt && this.next_tokens_are_prompt) {
75+
const is_prompt = this.next_tokens_are_prompt;
76+
if (is_prompt) {
7677
this.next_tokens_are_prompt = false;
77-
return;
78+
if (this.skip_prompt) return;
7879
}
7980

8081
const tokens = value[0];
@@ -85,7 +86,7 @@ export class TextStreamer extends BaseStreamer {
8586
const text = this.tokenizer.decode(this.token_cache, this.decode_kwargs);
8687

8788
let printable_text;
88-
if (text.endsWith('\n')) {
89+
if (is_prompt || text.endsWith('\n')) {
8990
// After the symbol for a new line, we flush the cache.
9091
printable_text = text.slice(this.print_len);
9192
this.token_cache = [];

0 commit comments

Comments
 (0)