mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 16:17:57 +01:00
Merge branch 'oobabooga:main' into feature/gpt-j-4bit-v2
This commit is contained in:
commit
1ac003d41c
@ -100,6 +100,7 @@ def get_download_links_from_huggingface(model, branch):
|
|||||||
links = []
|
links = []
|
||||||
classifications = []
|
classifications = []
|
||||||
has_pytorch = False
|
has_pytorch = False
|
||||||
|
has_pt = False
|
||||||
has_safetensors = False
|
has_safetensors = False
|
||||||
is_lora = False
|
is_lora = False
|
||||||
while True:
|
while True:
|
||||||
@ -115,7 +116,7 @@ def get_download_links_from_huggingface(model, branch):
|
|||||||
is_lora = True
|
is_lora = True
|
||||||
|
|
||||||
is_pytorch = re.match("(pytorch|adapter)_model.*\.bin", fname)
|
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_pt = re.match(".*\.pt", fname)
|
||||||
is_tokenizer = re.match("tokenizer.*\.model", fname)
|
is_tokenizer = re.match("tokenizer.*\.model", fname)
|
||||||
is_text = re.match(".*\.(txt|json|py|md)", fname) or is_tokenizer
|
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
|
has_pytorch = True
|
||||||
classifications.append('pytorch')
|
classifications.append('pytorch')
|
||||||
elif is_pt:
|
elif is_pt:
|
||||||
|
has_pt = True
|
||||||
classifications.append('pt')
|
classifications.append('pt')
|
||||||
|
|
||||||
cursor = base64.b64encode(f'{{"file_name":"{dict[-1]["path"]}"}}'.encode()) + b':50'
|
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')
|
cursor = cursor.replace(b'=', b'%3D')
|
||||||
|
|
||||||
# If both pytorch and safetensors are available, download safetensors only
|
# 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):
|
for i in range(len(classifications)-1, -1, -1):
|
||||||
if classifications[i] == 'pytorch':
|
if classifications[i] in ['pytorch', 'pt']:
|
||||||
links.pop(i)
|
links.pop(i)
|
||||||
|
|
||||||
return links, is_lora
|
return links, is_lora
|
||||||
|
@ -43,14 +43,14 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
generator = generate_reply(
|
generator = generate_reply(
|
||||||
question = prompt,
|
question = prompt,
|
||||||
max_new_tokens = body.get('max_length', 200),
|
max_new_tokens = int(body.get('max_length', 200)),
|
||||||
do_sample=True,
|
do_sample=True,
|
||||||
temperature=body.get('temperature', 0.5),
|
temperature=float(body.get('temperature', 0.5)),
|
||||||
top_p=body.get('top_p', 1),
|
top_p=float(body.get('top_p', 1)),
|
||||||
typical_p=body.get('typical', 1),
|
typical_p=float(body.get('typical', 1)),
|
||||||
repetition_penalty=body.get('rep_pen', 1.1),
|
repetition_penalty=float(body.get('rep_pen', 1.1)),
|
||||||
encoder_repetition_penalty=1,
|
encoder_repetition_penalty=1,
|
||||||
top_k=body.get('top_k', 0),
|
top_k=int(body.get('top_k', 0)),
|
||||||
min_length=0,
|
min_length=0,
|
||||||
no_repeat_ngram_size=0,
|
no_repeat_ngram_size=0,
|
||||||
num_beams=1,
|
num_beams=1,
|
||||||
@ -62,6 +62,9 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
answer = ''
|
answer = ''
|
||||||
for a in generator:
|
for a in generator:
|
||||||
|
if isinstance(a, str):
|
||||||
|
answer = a
|
||||||
|
else:
|
||||||
answer = a[0]
|
answer = a[0]
|
||||||
|
|
||||||
response = json.dumps({
|
response = json.dumps({
|
||||||
|
@ -34,7 +34,7 @@ def convert_to_markdown(string):
|
|||||||
string = string.replace('\\begin{blockquote}', '> ')
|
string = string.replace('\\begin{blockquote}', '> ')
|
||||||
string = string.replace('\\end{blockquote}', '')
|
string = string.replace('\\end{blockquote}', '')
|
||||||
string = re.sub(r"(.)```", r"\1\n```", string)
|
string = re.sub(r"(.)```", r"\1\n```", string)
|
||||||
# string = fix_newlines(string)
|
string = fix_newlines(string)
|
||||||
return markdown.markdown(string, extensions=['fenced_code'])
|
return markdown.markdown(string, extensions=['fenced_code'])
|
||||||
|
|
||||||
def generate_basic_html(string):
|
def generate_basic_html(string):
|
||||||
|
@ -494,7 +494,7 @@ def create_interface():
|
|||||||
shared.gradio['reset_interface'] = gr.Button("Apply and restart the interface", type="primary")
|
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(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=\'<h1 style="font-family:monospace;margin-top:20%;color:lightgray;text-align:center;">Reloading...</h1>\'; setTimeout(function(){location.reload()},2500)}')
|
shared.gradio['reset_interface'].click(lambda : None, None, None, _js='() => {document.body.innerHTML=\'<h1 style="font-family:monospace;margin-top:20%;color:lightgray;text-align:center;">Reloading...</h1>\'; setTimeout(function(){location.reload()},2500); return []}')
|
||||||
|
|
||||||
if shared.args.extensions is not None:
|
if shared.args.extensions is not None:
|
||||||
extensions_module.create_extensions_block()
|
extensions_module.create_extensions_block()
|
||||||
|
Loading…
Reference in New Issue
Block a user