@@ -48,7 +48,7 @@ class LanguageModel extends EventEmitter {
48
48
throw 'You need to provide the name of the model to load, e.g. TinyStories-15M' ;
49
49
}
50
50
51
- this . out = '' ;
51
+ this . text = '' ;
52
52
this . tokens = [ ] ;
53
53
this . words = [ ] ;
54
54
this . finished = true ;
@@ -110,7 +110,7 @@ class LanguageModel extends EventEmitter {
110
110
if ( this . options . stopOnBosOrEos && ( token == 1 || token == 2 ) ) {
111
111
this . finished = true ;
112
112
} else {
113
- this . out += tokenStr ;
113
+ this . text += tokenStr ;
114
114
}
115
115
116
116
// on-token event
@@ -120,9 +120,9 @@ class LanguageModel extends EventEmitter {
120
120
const wordDelimiters = ' .,:;"“?!\n' ;
121
121
const re = new RegExp ( '(?=[' + wordDelimiters + '])|(?<=[' + wordDelimiters + '])' , 'g' ) ;
122
122
const prevNumWords = this . words . length ;
123
- this . words = this . out . split ( re ) ;
123
+ this . words = this . text . split ( re ) ;
124
124
// ignore the last word if we can't be certain it's complete
125
- if ( ! wordDelimiters . includes ( this . out . slice ( - 1 ) ) && ! this . finished ) {
125
+ if ( ! wordDelimiters . includes ( this . text . slice ( - 1 ) ) && ! this . finished ) {
126
126
this . words . pop ( ) ;
127
127
}
128
128
// on-word event
@@ -134,11 +134,11 @@ class LanguageModel extends EventEmitter {
134
134
if ( this . finished ) {
135
135
// fulfill the promise returned by generate()
136
136
if ( this . promiseResolve ) {
137
- this . promiseResolve ( this . out ) ;
137
+ this . promiseResolve ( this . text ) ;
138
138
}
139
- this . emit ( 'finish' , this . out , this ) ;
139
+ this . emit ( 'finish' , this . text , this ) ;
140
140
if ( this . callback ) {
141
- this . callback ( this . out , this ) ;
141
+ this . callback ( this . text , this ) ;
142
142
}
143
143
}
144
144
} , 'viifi' ) ;
@@ -175,12 +175,12 @@ class LanguageModel extends EventEmitter {
175
175
// if there are any outstanding requests, resolve them
176
176
// with the output received so far
177
177
if ( this . promiseResolve ) {
178
- this . promiseResolve ( this . out ) ;
178
+ this . promiseResolve ( this . text ) ;
179
179
}
180
180
181
181
await this . llama2 . ccall ( 'set_parameters' , null , [ 'number' , 'number' ] , [ this . options . temperature , this . options . steps ] ) ;
182
182
183
- this . out = '' ;
183
+ this . text = '' ;
184
184
this . tokens = [ { index : 1 , str : '<s>' , probability : 1 } ] ;
185
185
this . words = [ ] ;
186
186
this . finished = false ;
@@ -230,12 +230,12 @@ class LanguageModel extends EventEmitter {
230
230
// if there are any outstanding requests, resolve them
231
231
// with the output received so far
232
232
if ( this . promiseResolve ) {
233
- this . promiseResolve ( this . out ) ;
233
+ this . promiseResolve ( this . text ) ;
234
234
}
235
235
236
236
await this . llama2 . ccall ( 'set_parameters' , null , [ 'number' , 'number' ] , [ this . options . temperature , this . options . steps ] ) ;
237
237
238
- this . out = '' ;
238
+ this . text = '' ;
239
239
this . tokens = [ ] ;
240
240
this . words = [ ] ;
241
241
this . finished = true ;
0 commit comments