muryshev commited on
Commit
d619817
1 Parent(s): e651b99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -227,15 +227,15 @@ def generate_search_request():
227
  # Use Response to stream tokens
228
  return Response(generate_tokens(model, generator), content_type='text/plain', status=200, direct_passthrough=True)
229
 
230
- response_tokens = ''
231
  def generate_and_log_tokens(user_request, model, generator):
232
  global response_tokens
233
  for token in generate_tokens(model, generator):
234
  if token == b'': # or (max_new_tokens is not None and i >= max_new_tokens):
235
  log(user_request, response_tokens.decode("utf-8", errors="ignore"))
236
- response_tokens = ''
237
  break
238
- response_tokens += token
239
  yield token
240
 
241
  @app.route('/', methods=['POST'])
 
227
  # Use Response to stream tokens
228
  return Response(generate_tokens(model, generator), content_type='text/plain', status=200, direct_passthrough=True)
229
 
230
+ response_tokens = bytearray()
231
  def generate_and_log_tokens(user_request, model, generator):
232
  global response_tokens
233
  for token in generate_tokens(model, generator):
234
  if token == b'': # or (max_new_tokens is not None and i >= max_new_tokens):
235
  log(user_request, response_tokens.decode("utf-8", errors="ignore"))
236
+ response_tokens = bytearray()
237
  break
238
+ response_tokens.append(token)
239
  yield token
240
 
241
  @app.route('/', methods=['POST'])