Add checkbox to disable the character bias

This commit is contained in:
oobabooga 2023-02-26 02:37:21 -03:00
parent ef91bd802d
commit 3c9432f039

View File

@ -1,7 +1,8 @@
import gradio as gr import gradio as gr
params = { params = {
"bias string": " *I speak in an annoyingly cute way*", "activate": True,
"bias string": " *I am so happy*",
} }
def input_modifier(string): def input_modifier(string):
@ -26,11 +27,16 @@ def bot_prefix_modifier(string):
behavior. behavior.
""" """
return f'{string} {params["bias string"].strip()} ' if params['activate'] == True:
return f'{string} {params["bias string"].strip()} '
else:
return string
def ui(): def ui():
# Gradio elements # Gradio elements
activate = gr.Checkbox(value=params['activate'], label='Activate character bias')
string = gr.Textbox(value=params["bias string"], label='Character bias') string = gr.Textbox(value=params["bias string"], label='Character bias')
# Event functions to update the parameters in the backend # Event functions to update the parameters in the backend
string.change(lambda x: params.update({"bias string": x}), string, None) string.change(lambda x: params.update({"bias string": x}), string, None)
activate.change(lambda x: params.update({"activate": x}), activate, None)