Make chat mode more like cai

This commit is contained in:
oobabooga 2023-01-15 18:16:46 -03:00
parent 9f1b6e0398
commit e6691bd920
3 changed files with 27 additions and 29 deletions

View File

@ -4,7 +4,7 @@ A gradio webui for running large language models like gpt-j-6B, gpt-neo, opt, ga
Its goal is to become the [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) of text generation.
|![Image1](https://github.com/oobabooga/screenshots/raw/main/qa.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/cai.png) |
|![Image1](https://github.com/oobabooga/screenshots/raw/main/qa.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/cai2.png) |
|:---:|:---:|
|![Image3](https://github.com/oobabooga/screenshots/raw/main/gpt4chan.png) | ![Image4](https://github.com/oobabooga/screenshots/raw/main/galactica.png) |

View File

@ -166,7 +166,7 @@ def generate_chat_html(history, name1, name2):
margin-left: auto;
margin-right: auto;
max-width: 800px;
height: 50vh;
height: 66.67vh;
overflow-y: auto;
padding-right: 20px;
display: flex;

View File

@ -268,10 +268,19 @@ elif args.chat or args.cai_chat:
name1_str = settings['name1']
name2_str = settings['name2']
with gr.Blocks(css=css+".h-\[40vh\] {height: 50vh}", analytics_enabled=False) as interface:
gr.Markdown(description)
with gr.Blocks(css=css+".h-\[40vh\] {height: 66.67vh} .gradio-container {max-width: 800px; margin-left: auto; margin-right: auto}", analytics_enabled=False) as interface:
if args.cai_chat:
display1 = gr.HTML(value=generate_chat_html([], "", ""))
else:
display1 = gr.Chatbot()
textbox = gr.Textbox(lines=2, label='Input')
btn = gr.Button("Generate")
with gr.Row():
with gr.Column():
btn3 = gr.Button("Remove last message")
with gr.Column():
btn2 = gr.Button("Clear history")
length_slider = gr.Slider(minimum=settings['max_new_tokens_min'], maximum=settings['max_new_tokens_max'], step=1, label='max_new_tokens', value=settings['max_new_tokens'])
with gr.Row():
with gr.Column():
@ -285,18 +294,7 @@ elif args.chat or args.cai_chat:
with gr.Row():
check = gr.Checkbox(value=settings['stop_at_newline'], label='Stop generating at new line character?')
with gr.Column():
if args.cai_chat:
display1 = gr.HTML(value=generate_chat_html([], "", ""))
else:
display1 = gr.Chatbot()
textbox = gr.Textbox(lines=2, label='Input')
btn = gr.Button("Generate")
with gr.Row():
with gr.Column():
btn3 = gr.Button("Remove last message")
with gr.Column():
btn2 = gr.Button("Clear history")
if args.cai_chat:
btn.click(cai_chatbot_wrapper, [textbox, length_slider, preset_menu, model_menu, name1, name2, context, check], display1, show_progress=True, api_name="textgen")