Tonic commited on
Commit
97a4588
1 Parent(s): 34c221f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -18
app.py CHANGED
@@ -59,24 +59,29 @@ def gradio_predict(user_message, system_message, max_new_tokens, temperature, to
59
  response = Tulu_bot.predict(user_message, temperature, max_new_tokens, top_p, repetition_penalty, do_sample)
60
  return response
61
 
62
-
63
  Tulu_bot = TuluChatBot(model, tokenizer)
64
 
65
- iface = gr.Interface(
66
- fn=gradio_predict,
67
- title=title,
68
- description=description,
69
- inputs=[
70
- gr.Textbox(label="Your Message", type="text", lines=3),
71
- gr.Textbox(label="Introduce a Character Here or Set a Scene (system prompt)", type="text", lines=2),
72
- gr.Checkbox(label="Advanced", value=True, id="do_sample"), # Add an id to the checkbox
73
- gr.Slider(label="Max new tokens", value=1269, minimum=550, maximum=3200, step=1, visible=gr.Visibility(id="do_sample", value=True)),
74
- gr.Slider(label="Temperature", value=1.2, minimum=0.05, maximum=4.0, step=0.05, visible=gr.Visibility(id="do_sample", value=True)),
75
- gr.Slider(label="Top-p (nucleus sampling)", value=0.90, minimum=0.01, maximum=0.99, step=0.05, visible=gr.Visibility(id="do_sample", value=True)),
76
- gr.Slider(label="Repetition penalty", value=1.9, minimum=1.0, maximum=2.0, step=0.05, visible=gr.Visibility(id="do_sample", value=True))
77
- ],
78
- outputs="text",
79
- theme="ParityError/Anime"
80
- )
81
 
82
- iface.queue(max_size=5).launch()
 
 
 
 
 
 
 
 
 
 
59
  response = Tulu_bot.predict(user_message, temperature, max_new_tokens, top_p, repetition_penalty, do_sample)
60
  return response
61
 
 
62
  Tulu_bot = TuluChatBot(model, tokenizer)
63
 
64
+ with gr.Blocks() as demo:
65
+ with gr.Row():
66
+ user_message = gr.Textbox(label="Your Message", lines=3)
67
+ system_message = gr.Textbox(label="Introduce a Character Here or Set a Scene (system prompt)", lines=2)
68
+ with gr.Row():
69
+ do_sample = gr.Checkbox(label="Advanced", value=True)
70
+ with gr.Row(visible=do_sample):
71
+ max_new_tokens = gr.Slider(label="Max new tokens", value=1269, minimum=550, maximum=3200, step=1)
72
+ temperature = gr.Slider(label="Temperature", value=1.2, minimum=0.05, maximum=4.0, step=0.05)
73
+ top_p = gr.Slider(label="Top-p (nucleus sampling)", value=0.90, minimum=0.01, maximum=0.99, step=0.05)
74
+ repetition_penalty = gr.Slider(label="Repetition penalty", value=1.9, minimum=1.0, maximum=2.0, step=0.05)
75
+ submit_button = gr.Button("Submit")
76
+ output_text = gr.Textbox()
 
 
 
77
 
78
+ def process(user_message, system_message, max_new_tokens, temperature, top_p, repetition_penalty, do_sample):
79
+ return gradio_predict(user_message, system_message, max_new_tokens, temperature, top_p, repetition_penalty, do_sample)
80
+
81
+ submit_button.click(
82
+ process,
83
+ inputs=[user_message, system_message, max_new_tokens, temperature, top_p, repetition_penalty, do_sample],
84
+ outputs=output_text
85
+ )
86
+
87
+ demo.launch()