Refactor chat functions (#2003)
This commit is contained in:
parent
4e9da22c58
commit
638c6a65a2
8 changed files with 138 additions and 157 deletions
|
|
@ -35,18 +35,15 @@ class Handler(BaseHTTPRequestHandler):
|
|||
generate_params['stream'] = False
|
||||
|
||||
generator = generate_reply(
|
||||
prompt, generate_params, stopping_strings=stopping_strings)
|
||||
prompt, generate_params, stopping_strings=stopping_strings, is_chat=False)
|
||||
|
||||
answer = ''
|
||||
for a in generator:
|
||||
if isinstance(a, str):
|
||||
answer = a
|
||||
else:
|
||||
answer = a[0]
|
||||
answer = a
|
||||
|
||||
response = json.dumps({
|
||||
'results': [{
|
||||
'text': answer if shared.is_chat() else answer[len(prompt):]
|
||||
'text': answer[len(prompt):]
|
||||
}]
|
||||
})
|
||||
self.wfile.write(response.encode('utf-8'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue