From c4f0e6d740a79962b2c79c6a822ef3b956c49296 Mon Sep 17 00:00:00 2001 From: matatonic <73265741+matatonic@users.noreply.github.com> Date: Thu, 11 May 2023 15:32:25 -0400 Subject: [PATCH] is_chat changes fix for openai extension (#2008) --- extensions/openai/script.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/extensions/openai/script.py b/extensions/openai/script.py index 711b76a2..8685ff0b 100644 --- a/extensions/openai/script.py +++ b/extensions/openai/script.py @@ -147,15 +147,6 @@ class Handler(BaseHTTPRequestHandler): self.send_error(404) def do_POST(self): - # ... haaack. - is_chat = shared.args.chat - try: - shared.args.chat = True - self.do_POST_wrap() - finally: - shared.args.chat = is_chat - - def do_POST_wrap(self): if debug: print(self.headers) # did you know... python-openai sends your linux kernel & python version? content_length = int(self.headers['Content-Length']) @@ -349,7 +340,7 @@ class Handler(BaseHTTPRequestHandler): # generate reply ####################################### if debug: print({'prompt': prompt, 'req_params': req_params, 'stopping_strings': stopping_strings}) - generator = generate_reply(prompt, req_params, stopping_strings=stopping_strings) + generator = generate_reply(prompt, req_params, stopping_strings=stopping_strings, is_chat=True) answer = '' seen_content = '' @@ -526,7 +517,7 @@ class Handler(BaseHTTPRequestHandler): if debug: print({'edit_template': edit_task, 'req_params': req_params, 'token_count': token_count}) - generator = generate_reply(edit_task, req_params, stopping_strings=standard_stopping_strings) + generator = generate_reply(edit_task, req_params, stopping_strings=standard_stopping_strings, is_chat=True) answer = '' for a in generator: