Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
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'])
|