script.py 854 B

123456789101112131415161718192021222324252627282930313233343536
  1. import gradio as gr
  2. params = {
  3. "bias string": " *I speak in an annoyingly cute way*",
  4. }
  5. def input_modifier(string):
  6. """
  7. This function is applied to your text inputs before
  8. they are fed into the model.
  9. """
  10. return string
  11. def output_modifier(string):
  12. """
  13. This function is applied to the model outputs.
  14. """
  15. return string
  16. def bot_prefix_modifier(string):
  17. """
  18. This function is only applied in chat mode. It modifies
  19. the prefix text for the Bot and can be used to bias its
  20. behavior.
  21. """
  22. return f'{string} {params["bias string"].strip()} '
  23. def ui():
  24. # Gradio elements
  25. string = gr.Textbox(value=params["bias string"], label='Character bias')
  26. # Event functions to update the parameters in the backend
  27. string.change(lambda x: params.update({"bias string": x}), string, None)