Refactor text_generation.py, add support for custom generation functions (#1817)

This commit is contained in:
oobabooga 2023-05-05 18:53:03 -03:00 committed by GitHub
parent 876fbb97c0
commit 8aafb1f796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 289 additions and 195 deletions

View file

@ -266,8 +266,7 @@ class Handler(BaseHTTPRequestHandler):
stopping_strings += standard_stopping_strings
req_params['custom_stopping_strings'] = stopping_strings
shared.args.no_stream = not req_params['stream']
if not shared.args.no_stream:
if req_params['stream']:
shared.args.chat = True
# begin streaming
chunk = {
@ -337,7 +336,7 @@ class Handler(BaseHTTPRequestHandler):
if buffer_and_continue:
continue
if not shared.args.no_stream:
if req_params['stream']:
# Streaming
new_content = answer[len_seen:]
@ -365,7 +364,7 @@ class Handler(BaseHTTPRequestHandler):
self.wfile.write(response.encode('utf-8'))
completion_token_count += len(encode(new_content)[0])
if not shared.args.no_stream:
if req_params['stream']:
chunk = {
"id": cmpl_id,
"object": stream_object_type,