mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Reorganize the layout
This commit is contained in:
parent
b53b658320
commit
3d6a3aac73
53
server.py
53
server.py
@ -83,13 +83,13 @@ def generate_reply(question, temperature, max_length, inference_settings, select
|
|||||||
if model_name.lower().startswith('galactica'):
|
if model_name.lower().startswith('galactica'):
|
||||||
return reply, reply
|
return reply, reply
|
||||||
else:
|
else:
|
||||||
return reply, ''
|
return reply, 'Only applicable for galactica models.'
|
||||||
|
|
||||||
# Choosing the default model
|
# Choosing the default model
|
||||||
if args.model is not None:
|
if args.model is not None:
|
||||||
model_name = args.model
|
model_name = args.model
|
||||||
else:
|
else:
|
||||||
if len(available_models == 0):
|
if len(available_models) == 0:
|
||||||
print("No models are available! Please download at least one.")
|
print("No models are available! Please download at least one.")
|
||||||
exit(0)
|
exit(0)
|
||||||
elif len(available_models) == 1:
|
elif len(available_models) == 1:
|
||||||
@ -117,31 +117,44 @@ if args.notebook:
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with gr.Tab('Raw'):
|
||||||
textbox = gr.Textbox(value=default_text, lines=23)
|
textbox = gr.Textbox(value=default_text, lines=23)
|
||||||
|
with gr.Tab('Markdown'):
|
||||||
|
markdown = gr.Markdown()
|
||||||
|
btn = gr.Button("Generate")
|
||||||
|
|
||||||
|
with gr.Row():
|
||||||
|
with gr.Column():
|
||||||
|
temp_slider = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Temperature', value=0.7)
|
||||||
|
length_slider = gr.Slider(minimum=1, maximum=2000, step=1, label='max_length', value=200)
|
||||||
|
with gr.Column():
|
||||||
|
preset_menu = gr.Dropdown(choices=list(map(lambda x : x.split('/')[-1].split('.')[0], glob.glob("presets/*.txt"))), value="Default", label='Preset')
|
||||||
|
model_menu = gr.Dropdown(choices=available_models, value=model_name, label='Model')
|
||||||
|
|
||||||
|
btn.click(generate_reply, [textbox, temp_slider, length_slider, preset_menu, model_menu], [textbox, markdown], show_progress=False)
|
||||||
|
else:
|
||||||
|
with gr.Blocks() as interface:
|
||||||
|
gr.Markdown(
|
||||||
|
f"""
|
||||||
|
# Text generation lab
|
||||||
|
Generate text using Large Language Models.
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
with gr.Row():
|
||||||
|
with gr.Column():
|
||||||
|
textbox = gr.Textbox(value=default_text, lines=15, label='Input')
|
||||||
temp_slider = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Temperature', value=0.7)
|
temp_slider = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Temperature', value=0.7)
|
||||||
length_slider = gr.Slider(minimum=1, maximum=2000, step=1, label='max_length', value=200)
|
length_slider = gr.Slider(minimum=1, maximum=2000, step=1, label='max_length', value=200)
|
||||||
preset_menu = gr.Dropdown(choices=list(map(lambda x : x.split('/')[-1].split('.')[0], glob.glob("presets/*.txt"))), value="Default", label='Preset')
|
preset_menu = gr.Dropdown(choices=list(map(lambda x : x.split('/')[-1].split('.')[0], glob.glob("presets/*.txt"))), value="Default", label='Preset')
|
||||||
model_menu = gr.Dropdown(choices=available_models, value=model_name, label='Model')
|
model_menu = gr.Dropdown(choices=available_models, value=model_name, label='Model')
|
||||||
btn = gr.Button("Generate")
|
btn = gr.Button("Generate")
|
||||||
|
with gr.Column():
|
||||||
|
with gr.Tab('Raw'):
|
||||||
|
output_textbox = gr.Textbox(value=default_text, lines=15, label='Output')
|
||||||
|
with gr.Tab('Markdown'):
|
||||||
markdown = gr.Markdown()
|
markdown = gr.Markdown()
|
||||||
|
|
||||||
btn.click(generate_reply, [textbox, temp_slider, length_slider, preset_menu, model_menu], [textbox, markdown], show_progress=False)
|
btn.click(generate_reply, [textbox, temp_slider, length_slider, preset_menu, model_menu], [output_textbox, markdown], show_progress=True)
|
||||||
else:
|
|
||||||
interface = gr.Interface(
|
|
||||||
generate_reply,
|
|
||||||
inputs=[
|
|
||||||
gr.Textbox(value=default_text, lines=15),
|
|
||||||
gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Temperature', value=0.7),
|
|
||||||
gr.Slider(minimum=1, maximum=2000, step=1, label='max_length', value=200),
|
|
||||||
gr.Dropdown(choices=list(map(lambda x : x.split('/')[-1].split('.')[0], glob.glob("presets/*.txt"))), value="Default", label='Preset'),
|
|
||||||
gr.Dropdown(choices=available_models, value=model_name, label='Model'),
|
|
||||||
],
|
|
||||||
outputs=[
|
|
||||||
gr.Textbox(placeholder="", lines=15),
|
|
||||||
gr.Markdown()
|
|
||||||
],
|
|
||||||
title="Text generation lab",
|
|
||||||
description=f"Generate text using Large Language Models.",
|
|
||||||
)
|
|
||||||
|
|
||||||
interface.launch(share=False, server_name="0.0.0.0")
|
interface.launch(share=False, server_name="0.0.0.0")
|
||||||
|
Loading…
Reference in New Issue
Block a user