Reorganize Chat settings tab

This commit is contained in:
oobabooga 2023-06-25 01:10:20 -03:00
parent b45baeea41
commit e6e5f546b8

View File

@ -542,6 +542,8 @@ def create_interface():
shared.gradio['chat_style'] = gr.Dropdown(choices=utils.get_available_chat_styles(), label='Chat style', value=shared.settings['chat_style'], visible=shared.settings['mode'] != 'instruct') shared.gradio['chat_style'] = gr.Dropdown(choices=utils.get_available_chat_styles(), label='Chat style', value=shared.settings['chat_style'], visible=shared.settings['mode'] != 'instruct')
with gr.Tab('Chat settings', elem_id='chat-settings'): with gr.Tab('Chat settings', elem_id='chat-settings'):
with gr.Tab("Character"):
with gr.Row(): with gr.Row():
with gr.Column(scale=8): with gr.Column(scale=8):
with gr.Row(): with gr.Row():
@ -559,6 +561,7 @@ def create_interface():
shared.gradio['character_picture'] = gr.Image(label='Character picture', type='pil') shared.gradio['character_picture'] = gr.Image(label='Character picture', type='pil')
shared.gradio['your_picture'] = gr.Image(label='Your picture', type='pil', value=Image.open(Path('cache/pfp_me.png')) if Path('cache/pfp_me.png').exists() else None) shared.gradio['your_picture'] = gr.Image(label='Your picture', type='pil', value=Image.open(Path('cache/pfp_me.png')) if Path('cache/pfp_me.png').exists() else None)
with gr.Tab("Instruction template"):
with gr.Row(): with gr.Row():
with gr.Row(): with gr.Row():
shared.gradio['instruction_template'] = gr.Dropdown(choices=utils.get_available_instruction_templates(), label='Instruction template', value='None', info='Change this according to the model/LoRA that you are using. Used in instruct and chat-instruct modes.', elem_classes='slim-dropdown') shared.gradio['instruction_template'] = gr.Dropdown(choices=utils.get_available_instruction_templates(), label='Instruction template', value='None', info='Change this according to the model/LoRA that you are using. Used in instruct and chat-instruct modes.', elem_classes='slim-dropdown')
@ -573,16 +576,15 @@ def create_interface():
with gr.Row(): with gr.Row():
shared.gradio['chat-instruct_command'] = gr.Textbox(value=shared.settings['chat-instruct_command'], lines=4, label='Command for chat-instruct mode', info='<|character|> gets replaced by the bot name, and <|prompt|> gets replaced by the regular chat prompt.') shared.gradio['chat-instruct_command'] = gr.Textbox(value=shared.settings['chat-instruct_command'], lines=4, label='Command for chat-instruct mode', info='<|character|> gets replaced by the bot name, and <|prompt|> gets replaced by the regular chat prompt.')
with gr.Row():
with gr.Tab('Chat history'): with gr.Tab('Chat history'):
with gr.Row(): with gr.Row():
with gr.Column():
shared.gradio['upload_chat_history'] = gr.File(type='binary', file_types=['.json', '.txt'], label="Upload")
with gr.Column(): with gr.Column():
shared.gradio['download'] = gr.File(label="Download") shared.gradio['download'] = gr.File(label="Download")
shared.gradio['download_button'] = gr.Button(value='Refresh') shared.gradio['download_button'] = gr.Button(value='Refresh')
with gr.Column():
shared.gradio['upload_chat_history'] = gr.File(type='binary', file_types=['.json', '.txt'], label="Upload")
with gr.Tab('Upload character'): with gr.Tab('Upload character'):
with gr.Tab('JSON'): with gr.Tab('JSON'):
with gr.Row(): with gr.Row():
@ -590,6 +592,7 @@ def create_interface():
shared.gradio['upload_img_bot'] = gr.Image(type='pil', label='Profile Picture (optional)') shared.gradio['upload_img_bot'] = gr.Image(type='pil', label='Profile Picture (optional)')
shared.gradio['Upload character'] = gr.Button(value='Submit', interactive=False) shared.gradio['Upload character'] = gr.Button(value='Submit', interactive=False)
with gr.Tab('TavernAI'): with gr.Tab('TavernAI'):
shared.gradio['upload_img_tavern'] = gr.File(type='binary', file_types=['image'], label='TavernAI PNG File') shared.gradio['upload_img_tavern'] = gr.File(type='binary', file_types=['image'], label='TavernAI PNG File')
shared.gradio['Upload tavern character'] = gr.Button(value='Submit', interactive=False) shared.gradio['Upload tavern character'] = gr.Button(value='Submit', interactive=False)
@ -833,7 +836,7 @@ def create_interface():
lambda: 'characters/instruction-following/', None, shared.gradio['delete_root']).then( lambda: 'characters/instruction-following/', None, shared.gradio['delete_root']).then(
lambda: gr.update(visible=True), None, shared.gradio['file_deleter']) lambda: gr.update(visible=True), None, shared.gradio['file_deleter'])
shared.gradio['download_button'].click(lambda x: chat.save_history(x, timestamp=True), shared.gradio['mode'], shared.gradio['download']) shared.gradio['download_button'].click(lambda x: chat.save_history(x, timestamp=True, user_request=True), shared.gradio['mode'], shared.gradio['download'])
shared.gradio['Upload character'].click(chat.upload_character, [shared.gradio['upload_json'], shared.gradio['upload_img_bot']], [shared.gradio['character_menu']]) shared.gradio['Upload character'].click(chat.upload_character, [shared.gradio['upload_json'], shared.gradio['upload_img_bot']], [shared.gradio['character_menu']])
shared.gradio['upload_json'].upload(lambda: gr.update(interactive=True), None, [shared.gradio['Upload character']]) shared.gradio['upload_json'].upload(lambda: gr.update(interactive=True), None, [shared.gradio['Upload character']])
shared.gradio['upload_json'].clear(lambda: gr.update(interactive=False), None, [shared.gradio['Upload character']]) shared.gradio['upload_json'].clear(lambda: gr.update(interactive=False), None, [shared.gradio['Upload character']])