File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff 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 = [ ] ;
You can’t perform that action at this time.
0 commit comments