From 7a776ccf8715bbe4e6934772fd135d54e4d24f78 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:19:36 -0300 Subject: [PATCH] Make the gallery interactive to load characters --- extensions/gallery/script.py | 8 ++++++-- server.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py index 698575d1..68e2c1a3 100644 --- a/extensions/gallery/script.py +++ b/extensions/gallery/script.py @@ -29,6 +29,10 @@ def generate_html(): background-color: gray; } + .character-gallery tr { + cursor: pointer; + } + .character-gallery .image-td { width: 150px; } @@ -45,7 +49,7 @@ def generate_html(): for file in Path("characters").glob("*"): if file.name.endswith(".json"): character = file.name.replace(".json", "") - table_html += "" + table_html += f'' image_html = "
" for i in [ @@ -62,7 +66,7 @@ def generate_html(): except: continue - table_html += f'{image_html}{character}' + table_html += f'{image_html}{character}' table_html += "" table_html += "" diff --git a/server.py b/server.py index 8c32b3c0..7940edf8 100644 --- a/server.py +++ b/server.py @@ -207,7 +207,7 @@ if shared.args.chat or shared.args.cai_chat: shared.gradio['name2'] = gr.Textbox(value=shared.settings[f'name2{suffix}'], lines=1, label='Bot\'s name') shared.gradio['context'] = gr.Textbox(value=shared.settings[f'context{suffix}'], lines=2, label='Context') with gr.Row(): - shared.gradio['character_menu'] = gr.Dropdown(choices=available_characters, value='None', label='Character') + shared.gradio['character_menu'] = gr.Dropdown(choices=available_characters, value='None', label='Character', elem_id='character-menu') ui.create_refresh_button(shared.gradio['character_menu'], lambda : None, lambda : {'choices': get_available_characters()}, 'refresh-button') with gr.Row():