From 91c2b8e11c4c3ef96cbb90111f74deb943555804 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 4 Jan 2024 20:48:26 -0800 Subject: [PATCH] Improvements to character_bias extension --- extensions/character_bias/script.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/extensions/character_bias/script.py b/extensions/character_bias/script.py index ff12f3af..94ab4914 100644 --- a/extensions/character_bias/script.py +++ b/extensions/character_bias/script.py @@ -18,7 +18,7 @@ with open(bias_file, "r") as f: params = { "activate": True, "bias string": " *I am so happy*", - "use custom string": False, + "custom string": "", } @@ -44,7 +44,7 @@ def bot_prefix_modifier(string): behavior. """ if params['activate']: - if params['use custom string']: + if params['custom string'].strip() != '': return f'{string} {params["custom string"].strip()} ' else: return f'{string} {params["bias string"].strip()} ' @@ -56,8 +56,7 @@ def ui(): # Gradio elements activate = gr.Checkbox(value=params['activate'], label='Activate character bias') dropdown_string = gr.Dropdown(choices=bias_options, value=params["bias string"], label='Character bias', info='To edit the options in this dropdown edit the "bias_options.txt" file') - use_custom_string = gr.Checkbox(value=False, label='Use custom bias textbox instead of dropdown') - custom_string = gr.Textbox(value="", placeholder="Enter custom bias string", label="Custom Character Bias", info='To use this textbox activate the checkbox above') + custom_string = gr.Textbox(value=params['custom string'], placeholder="Enter custom bias string", label="Custom Character Bias", info='If not empty, will be used instead of the value above') # Event functions to update the parameters in the backend def update_bias_string(x): @@ -73,11 +72,3 @@ def ui(): dropdown_string.change(update_bias_string, dropdown_string, None) custom_string.change(update_custom_string, custom_string, None) activate.change(lambda x: params.update({"activate": x}), activate, None) - use_custom_string.change(lambda x: params.update({"use custom string": x}), use_custom_string, None) - - # Group elements together depending on the selected option - def bias_string_group(): - if use_custom_string.value: - return gr.Group([use_custom_string, custom_string]) - else: - return dropdown_string