From 8579fe51dd09651ce7168d2191f9d741540881a5 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:59:34 -0300 Subject: [PATCH 1/5] Fix new lines in the HTML tab --- modules/html_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/html_generator.py b/modules/html_generator.py index ff18c913..48d2e02e 100644 --- a/modules/html_generator.py +++ b/modules/html_generator.py @@ -34,7 +34,7 @@ def convert_to_markdown(string): string = string.replace('\\begin{blockquote}', '> ') string = string.replace('\\end{blockquote}', '') string = re.sub(r"(.)```", r"\1\n```", string) -# string = fix_newlines(string) + string = fix_newlines(string) return markdown.markdown(string, extensions=['fenced_code']) def generate_basic_html(string): From 91aa5b460ed1f330e35b02fd7f5368912ea6526c Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:08:38 -0300 Subject: [PATCH 2/5] If both .pt and .safetensors are present, download only safetensors --- download-model.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/download-model.py b/download-model.py index 25386e5f..dce7e749 100644 --- a/download-model.py +++ b/download-model.py @@ -100,6 +100,7 @@ def get_download_links_from_huggingface(model, branch): links = [] classifications = [] has_pytorch = False + has_pt = False has_safetensors = False is_lora = False while True: @@ -115,7 +116,7 @@ def get_download_links_from_huggingface(model, branch): is_lora = True is_pytorch = re.match("(pytorch|adapter)_model.*\.bin", fname) - is_safetensors = re.match("model.*\.safetensors", fname) + is_safetensors = re.match(".*\.safetensors", fname) is_pt = re.match(".*\.pt", fname) is_tokenizer = re.match("tokenizer.*\.model", fname) is_text = re.match(".*\.(txt|json|py|md)", fname) or is_tokenizer @@ -134,6 +135,7 @@ def get_download_links_from_huggingface(model, branch): has_pytorch = True classifications.append('pytorch') elif is_pt: + has_pt = True classifications.append('pt') cursor = base64.b64encode(f'{{"file_name":"{dict[-1]["path"]}"}}'.encode()) + b':50' @@ -141,9 +143,9 @@ def get_download_links_from_huggingface(model, branch): cursor = cursor.replace(b'=', b'%3D') # If both pytorch and safetensors are available, download safetensors only - if has_pytorch and has_safetensors: + if (has_pytorch or has_pt) and has_safetensors: for i in range(len(classifications)-1, -1, -1): - if classifications[i] == 'pytorch': + if classifications[i] in ['pytorch', 'pt']: links.pop(i) return links, is_lora From 88ad86249d59b2984a99c7366e89728e8a6cc19e Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:19:52 -0300 Subject: [PATCH 3/5] Remove unnecessary file --- training/formats/put-trainer-formats-here.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 training/formats/put-trainer-formats-here.txt diff --git a/training/formats/put-trainer-formats-here.txt b/training/formats/put-trainer-formats-here.txt deleted file mode 100644 index e69de29b..00000000 From cac577d99f3ebf864ec8d4701211ec94cf32c4fa Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:25:58 -0300 Subject: [PATCH 4/5] Fix interface reloading --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 4d9ee5e8..6023451b 100644 --- a/server.py +++ b/server.py @@ -494,7 +494,7 @@ def create_interface(): shared.gradio['reset_interface'] = gr.Button("Apply and restart the interface", type="primary") shared.gradio['reset_interface'].click(set_interface_arguments, [shared.gradio[k] for k in ['interface_modes_menu', 'extensions_menu', 'cmd_arguments_menu']], None) - shared.gradio['reset_interface'].click(lambda : None, None, None, _js='() => {document.body.innerHTML=\'

Reloading...

\'; setTimeout(function(){location.reload()},2500)}') + shared.gradio['reset_interface'].click(lambda : None, None, None, _js='() => {document.body.innerHTML=\'

Reloading...

\'; setTimeout(function(){location.reload()},2500); return []}') if shared.args.extensions is not None: extensions_module.create_extensions_block() From d1377c37af2bb29c97d06ec996b5a0a66010d005 Mon Sep 17 00:00:00 2001 From: Maya Eary Date: Tue, 28 Mar 2023 20:57:16 +0300 Subject: [PATCH 5/5] Fixes for api server - chat mode and integer temperature --- extensions/api/script.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/extensions/api/script.py b/extensions/api/script.py index bd7c1900..dd48f58f 100644 --- a/extensions/api/script.py +++ b/extensions/api/script.py @@ -43,14 +43,14 @@ class Handler(BaseHTTPRequestHandler): generator = generate_reply( question = prompt, - max_new_tokens = body.get('max_length', 200), + max_new_tokens = int(body.get('max_length', 200)), do_sample=True, - temperature=body.get('temperature', 0.5), - top_p=body.get('top_p', 1), - typical_p=body.get('typical', 1), - repetition_penalty=body.get('rep_pen', 1.1), + temperature=float(body.get('temperature', 0.5)), + top_p=float(body.get('top_p', 1)), + typical_p=float(body.get('typical', 1)), + repetition_penalty=float(body.get('rep_pen', 1.1)), encoder_repetition_penalty=1, - top_k=body.get('top_k', 0), + top_k=int(body.get('top_k', 0)), min_length=0, no_repeat_ngram_size=0, num_beams=1, @@ -62,7 +62,10 @@ class Handler(BaseHTTPRequestHandler): answer = '' for a in generator: - answer = a[0] + if isinstance(a, str): + answer = a + else: + answer = a[0] response = json.dumps({ 'results': [{