Update chat API (fixes #3006)

This commit is contained in:
oobabooga 2023-07-04 17:36:47 -07:00
parent 333075e726
commit 70a4d5dbcf
3 changed files with 4 additions and 5 deletions

View File

@ -72,7 +72,6 @@ class Handler(BaseHTTPRequestHandler):
self.end_headers() self.end_headers()
user_input = body['user_input'] user_input = body['user_input']
history = body['history']
regenerate = body.get('regenerate', False) regenerate = body.get('regenerate', False)
_continue = body.get('_continue', False) _continue = body.get('_continue', False)
@ -80,9 +79,9 @@ class Handler(BaseHTTPRequestHandler):
generate_params['stream'] = False generate_params['stream'] = False
generator = generate_chat_reply( generator = generate_chat_reply(
user_input, history, generate_params, regenerate=regenerate, _continue=_continue, loading_message=False) user_input, generate_params, regenerate=regenerate, _continue=_continue, loading_message=False)
answer = history answer = generate_params['history']
for a in generator: for a in generator:
answer = a answer = a

View File

@ -55,14 +55,13 @@ async def _handle_connection(websocket, path):
body = json.loads(message) body = json.loads(message)
user_input = body['user_input'] user_input = body['user_input']
history = body['history']
generate_params = build_parameters(body, chat=True) generate_params = build_parameters(body, chat=True)
generate_params['stream'] = True generate_params['stream'] = True
regenerate = body.get('regenerate', False) regenerate = body.get('regenerate', False)
_continue = body.get('_continue', False) _continue = body.get('_continue', False)
generator = generate_chat_reply( generator = generate_chat_reply(
user_input, history, generate_params, regenerate=regenerate, _continue=_continue, loading_message=False) user_input, generate_params, regenerate=regenerate, _continue=_continue, loading_message=False)
message_num = 0 message_num = 0
for a in generator: for a in generator:

View File

@ -65,6 +65,7 @@ def build_parameters(body, chat=False):
'context_instruct': context_instruct, 'context_instruct': context_instruct,
'turn_template': turn_template, 'turn_template': turn_template,
'chat-instruct_command': str(body.get('chat-instruct_command', shared.settings['chat-instruct_command'])), 'chat-instruct_command': str(body.get('chat-instruct_command', shared.settings['chat-instruct_command'])),
'history': body.get('history', {'internal': [], 'visible': []})
}) })
return generate_params return generate_params