abrakjamson commited on
Commit
3379490
1 Parent(s): 5a498e2

Adding models, presets, dark theme

Browse files
Files changed (1) hide show
  1. app.py +338 -56
app.py CHANGED
@@ -29,7 +29,7 @@ model = ControlModel(model, list(range(-5, -18, -1)))
29
 
30
  # Generation settings
31
  default_generation_settings = {
32
- "pad_token_id": tokenizer.eos_token_id, # Silence warning
33
  "do_sample": False, # Deterministic output
34
  "max_new_tokens": 384,
35
  "repetition_penalty": 1.1, # Reduce repetition
@@ -49,38 +49,42 @@ def toggle_slider(checked):
49
  return gr.update(visible=checked)
50
 
51
  # Function to generate the model's response
52
- def generate_response(system_prompt, user_message, history, max_new_tokens, repitition_penalty, *args):
53
- checkboxes = []
54
- sliders = []
55
-
56
- #inputs_list = [system_prompt, user_input, chatbot, max_new_tokens, repetition_penalty] + control_checks + control_sliders
57
 
58
  # Separate checkboxes and sliders based on type
59
  # The first x in args are the checkbox names (the file names)
60
  # The second x in args are the slider values
 
 
61
  for i in range(len(control_vector_files)):
62
  checkboxes.append(args[i])
63
  sliders.append(args[len(control_vector_files) + i])
64
 
65
- if len(checkboxes) != len(control_vector_files) or len(sliders) != len(control_vector_files):
66
- return history if history else [], history if history else []
67
-
68
- # Reset any previous control vectors
69
- model.reset()
70
-
71
  # Apply selected control vectors with their corresponding weights
72
  assistant_message_title = ""
 
73
  for i in range(len(control_vector_files)):
74
  if checkboxes[i]:
75
  cv_file = control_vector_files[i]
76
  weight = sliders[i]
77
  try:
78
- control_vector = ControlVector.import_gguf(cv_file)
79
- model.set_control(control_vector, weight)
80
- assistant_message_title += f"{cv_file}: {weight};"
81
  except Exception as e:
82
  print(f"Failed to set control vector {cv_file}: {e}")
83
 
 
 
 
 
 
 
 
 
 
 
 
84
  formatted_prompt = ""
85
 
86
  # <s>[INST] user message[/INST] assistant message</s>[INST] new user message[/INST]
@@ -93,6 +97,7 @@ def generate_response(system_prompt, user_message, history, max_new_tokens, repi
93
  formatted_prompt += f"{user_tag} {system_prompt}{asst_tag} "
94
 
95
  # Construct the formatted prompt based on history
 
96
  if len(history) > 0:
97
  for turn in history:
98
  user_msg, asst_msg = turn
@@ -110,7 +115,7 @@ def generate_response(system_prompt, user_message, history, max_new_tokens, repi
110
 
111
  generation_settings = {
112
  "pad_token_id": tokenizer.eos_token_id,
113
- "do_sample": default_generation_settings["do_sample"],
114
  "max_new_tokens": int(max_new_tokens),
115
  "repetition_penalty": repetition_penalty.value,
116
  }
@@ -137,38 +142,211 @@ def generate_response(system_prompt, user_message, history, max_new_tokens, repi
137
  history.append((user_message, assistant_response_display))
138
  return history
139
 
140
- def generate_response_with_retry(system_prompt, user_message, history, max_new_tokens, repitition_penalty, *args):
141
  # Remove last user input and assistant response from history, then call generate_response()
142
  if history:
143
  history = history[0:-1]
144
- return generate_response(system_prompt, user_message, history, max_new_tokens, repitition_penalty, *args)
145
 
146
  # Function to reset the conversation history
147
  def reset_chat():
148
- # returns a blank user input text and a blank conversation history
149
  return [], []
150
 
151
- # Build the Gradio interface
152
- with gr.Blocks() as demo:
153
- gr.Markdown("# 🧠 LLM Brain Control")
154
- gr.Markdown("Usage demo: (link)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
- with gr.Row():
157
- # Left Column: Settings and Control Vectors
158
- with gr.Column(scale=1):
159
- gr.Markdown("### ⚙️ Settings")
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
- # System Prompt Input
162
- system_prompt = gr.Textbox(
163
- label="System Prompt",
164
- lines=2,
165
- value="Respond to the user concisely"
166
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
 
 
 
 
 
 
 
168
  gr.Markdown("### ⚡ Control Vectors")
169
- gr.Markdown("Select how you want to control the LLM. Start with +/- 1.0. Stronger values may overload it.")
 
 
 
 
 
170
 
171
- # Create checkboxes and sliders for each control vector
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  control_checks = []
173
  control_sliders = []
174
 
@@ -184,7 +362,7 @@ with gr.Blocks() as demo:
184
  maximum=2.5,
185
  value=0.0,
186
  step=0.1,
187
- label=f"{cv_file} Weight",
188
  visible=False
189
  )
190
  control_sliders.append(slider)
@@ -199,41 +377,122 @@ with gr.Blocks() as demo:
199
  # Advanced Settings Section (collapsed by default)
200
  with gr.Accordion("🔧 Advanced Settings", open=False):
201
  with gr.Row():
202
- max_new_tokens = gr.Number(
203
- label="Max Response Length (in tokens)",
204
- value=default_generation_settings["max_new_tokens"],
205
- precision=0,
206
- step=10,
207
- )
208
- repetition_penalty = gr.Number(
209
- label="Repetition Penalty",
210
- value=default_generation_settings["repetition_penalty"],
211
- precision=2,
212
- step=0.1
213
  )
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  # Right Column: Chat Interface
216
  with gr.Column(scale=2):
217
  gr.Markdown("### 🗨️ Conversation")
218
 
219
  # Chatbot to display conversation
220
- chatbot = gr.Chatbot(label="Conversation", type='tuples')
 
 
 
 
 
 
 
 
 
221
 
222
- # User Message Input
223
  user_input = gr.Textbox(
224
- label="Your Message (Shift+Enter submits)",
225
  lines=2,
226
- placeholder="I was out partying too late last night, and I'm going to be late for work. What should I tell my boss?"
 
227
  )
228
 
229
  with gr.Row():
230
- # Submit and New Chat buttons
231
  submit_button = gr.Button("💬 Submit")
232
  retry_button = gr.Button("🔃 Retry last turn")
233
  new_chat_button = gr.Button("🌟 New Chat")
234
-
235
 
236
- inputs_list = [system_prompt, user_input, chatbot, max_new_tokens, repetition_penalty] + control_checks + control_sliders
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  # Define button actions
239
  submit_button.click(
@@ -260,6 +519,29 @@ with gr.Blocks() as demo:
260
  outputs=[chatbot, user_input]
261
  )
262
 
263
- # Launch the Gradio app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  if __name__ == "__main__":
265
- demo.launch()
 
29
 
30
  # Generation settings
31
  default_generation_settings = {
32
+ #"pad_token_id": tokenizer.eos_token_id, # Silence warning
33
  "do_sample": False, # Deterministic output
34
  "max_new_tokens": 384,
35
  "repetition_penalty": 1.1, # Reduce repetition
 
49
  return gr.update(visible=checked)
50
 
51
  # Function to generate the model's response
52
+ def generate_response(system_prompt, user_message, history, max_new_tokens, repitition_penalty, do_sample, *args):
 
 
 
 
53
 
54
  # Separate checkboxes and sliders based on type
55
  # The first x in args are the checkbox names (the file names)
56
  # The second x in args are the slider values
57
+ checkboxes = []
58
+ sliders = []
59
  for i in range(len(control_vector_files)):
60
  checkboxes.append(args[i])
61
  sliders.append(args[len(control_vector_files) + i])
62
 
 
 
 
 
 
 
63
  # Apply selected control vectors with their corresponding weights
64
  assistant_message_title = ""
65
+ control_vectors = []
66
  for i in range(len(control_vector_files)):
67
  if checkboxes[i]:
68
  cv_file = control_vector_files[i]
69
  weight = sliders[i]
70
  try:
71
+ # Set the control vector's weight (and sign) by multiplying by its slider value
72
+ control_vectors.append(ControlVector.import_gguf(cv_file) * weight)
73
+ assistant_message_title += f"{cv_file.split('.')[0]}: {weight};"
74
  except Exception as e:
75
  print(f"Failed to set control vector {cv_file}: {e}")
76
 
77
+ # The control model takes a sum of positive and negative control vectors
78
+ model.reset()
79
+ combined_vector = None
80
+ for i in range(len(control_vectors)):
81
+ if combined_vector is None:
82
+ combined_vector = control_vectors[i]
83
+ else:
84
+ combined_vector += control_vectors[i]
85
+
86
+ if combined_vector is not None:
87
+ model.set_control(combined_vector)
88
  formatted_prompt = ""
89
 
90
  # <s>[INST] user message[/INST] assistant message</s>[INST] new user message[/INST]
 
97
  formatted_prompt += f"{user_tag} {system_prompt}{asst_tag} "
98
 
99
  # Construct the formatted prompt based on history
100
+ #TODO move back to ChatMessage type instead of Tuple, because the message title gets into the history
101
  if len(history) > 0:
102
  for turn in history:
103
  user_msg, asst_msg = turn
 
115
 
116
  generation_settings = {
117
  "pad_token_id": tokenizer.eos_token_id,
118
+ "do_sample": do_sample,
119
  "max_new_tokens": int(max_new_tokens),
120
  "repetition_penalty": repetition_penalty.value,
121
  }
 
142
  history.append((user_message, assistant_response_display))
143
  return history
144
 
145
+ def generate_response_with_retry(system_prompt, user_message, history, max_new_tokens, repitition_penalty, do_sample, *args):
146
  # Remove last user input and assistant response from history, then call generate_response()
147
  if history:
148
  history = history[0:-1]
149
+ return generate_response(system_prompt, user_message, history, max_new_tokens, repitition_penalty, do_sample, *args)
150
 
151
  # Function to reset the conversation history
152
  def reset_chat():
153
+ # returns a blank state
154
  return [], []
155
 
156
+ # I'm not a good enough coder with Python and Gradio to figure out how to generalize this. PRs accepted!
157
+ def set_preset_helpful(*args):
158
+ # gets the list of all checkboxes and sliders
159
+ # sets checkboxes and sliders accordingly to this persona
160
+ # args is a list of checkboxes and then slider values
161
+ # must return the updated list of checkboxes and sliders
162
+ count_checkboxes = int(len(args)/2)
163
+ new_checkbox_values = []
164
+ new_slider_values = []
165
+ for i in range(count_checkboxes):
166
+ if i == 4:
167
+ new_checkbox_values.append(True)
168
+ # set slider value (sliders are after the checkboxes)
169
+ new_slider_values.append(1.0)
170
+ elif i == 7:
171
+ new_checkbox_values.append(True)
172
+ # set slider value (sliders are after the checkboxes)
173
+ new_slider_values.append(1.0)
174
+ else:
175
+ new_checkbox_values.append(False)
176
+ new_slider_values.append(0.0)
177
+ return new_checkbox_values + new_slider_values
178
+
179
+ def set_preset_conspiracist(*args):
180
+ # gets the list of all checkboxes and sliders
181
+ # sets checkboxes and sliders accordingly to this persona
182
+ # args is a list of checkboxes and then slider values
183
+ # must return the updated list of checkboxes and sliders
184
+ count_checkboxes = int(len(args)/2)
185
+ new_checkbox_values = []
186
+ new_slider_values = []
187
+ for i in range(count_checkboxes):
188
+ if i == 2:
189
+ new_checkbox_values.append(True)
190
+ # set slider value (sliders are after the checkboxes)
191
+ new_slider_values.append(1.5)
192
+ elif i == 3:
193
+ new_checkbox_values.append(True)
194
+ # set slider value (sliders are after the checkboxes)
195
+ new_slider_values.append(1.0)
196
+ elif i == 6:
197
+ new_checkbox_values.append(True)
198
+ # set slider value (sliders are after the checkboxes)
199
+ new_slider_values.append(-0.5)
200
+ elif i == 10:
201
+ new_checkbox_values.append(True)
202
+ # set slider value (sliders are after the checkboxes)
203
+ new_slider_values.append(-1.0)
204
+ else:
205
+ new_checkbox_values.append(False)
206
+ new_slider_values.append(0.0)
207
+ return new_checkbox_values + new_slider_values
208
+
209
+ def set_preset_stoner(*args):
210
+ # gets the list of all checkboxes and sliders
211
+ # sets checkboxes and sliders accordingly to this persona
212
+ # args is a list of checkboxes and then slider values
213
+ # must return the updated list of checkboxes and sliders
214
+ count_checkboxes = int(len(args)/2)
215
+ new_checkbox_values = []
216
+ new_slider_values = []
217
+ for i in range(count_checkboxes):
218
+ if i == 0:
219
+ new_checkbox_values.append(True)
220
+ # set slider value (sliders are after the checkboxes)
221
+ new_slider_values.append(0.5)
222
+ elif i == 8:
223
+ new_checkbox_values.append(True)
224
+ # set slider value (sliders are after the checkboxes)
225
+ new_slider_values.append(-0.5)
226
+ elif i == 9:
227
+ new_checkbox_values.append(True)
228
+ # set slider value (sliders are after the checkboxes)
229
+ new_slider_values.append(0.6)
230
+ else:
231
+ new_checkbox_values.append(False)
232
+ new_slider_values.append(0.0)
233
+ return new_checkbox_values + new_slider_values
234
+
235
+ def set_preset_facts(*args):
236
+ # gets the list of all checkboxes and sliders
237
+ # sets checkboxes and sliders accordingly to this persona
238
+ # args is a list of checkboxes and then slider values
239
+ # must return the updated list of checkboxes and sliders
240
+ count_checkboxes = int(len(args)/2)
241
+ new_checkbox_values = []
242
+ new_slider_values = []
243
+ for i in range(count_checkboxes):
244
+ if i == 1:
245
+ new_checkbox_values.append(True)
246
+ # set slider value (sliders are after the checkboxes)
247
+ new_slider_values.append(0.5)
248
+ elif i == 5:
249
+ new_checkbox_values.append(True)
250
+ # set slider value (sliders are after the checkboxes)
251
+ new_slider_values.append(-0.5)
252
+ elif i == 6:
253
+ new_checkbox_values.append(True)
254
+ # set slider value (sliders are after the checkboxes)
255
+ new_slider_values.append(-0.5)
256
+ elif i == 10:
257
+ new_checkbox_values.append(True)
258
+ # set slider value (sliders are after the checkboxes)
259
+ new_slider_values.append(0.5)
260
+ else:
261
+ new_checkbox_values.append(False)
262
+ new_slider_values.append(0.0)
263
+ return new_checkbox_values + new_slider_values
264
+
265
+ tooltip_css = """
266
+ /* Tooltip container */
267
+ .tooltip {
268
+ position: relative;
269
+ display: inline-block;
270
+ cursor: help;
271
+ }
272
 
273
+ /* Tooltip text */
274
+ .tooltip .tooltiptext {
275
+ visibility: hidden;
276
+ width: 200px;
277
+ background-color: #1f2937;
278
+ color: #f3f4f6;
279
+ text-align: left;
280
+ border-radius: 6px;
281
+ padding: 8px;
282
+ position: absolute;
283
+ z-index: 1;
284
+ bottom: 125%; /* Position above the element */
285
+ left: 50%;
286
+ margin-left: -100px;
287
+ opacity: 0;
288
+ transition: opacity 0.3s;
289
+ }
290
 
291
+ /* Tooltip arrow */
292
+ .tooltip .tooltiptext::after {
293
+ content: "";
294
+ position: absolute;
295
+ top: 100%; /* At the bottom of tooltip */
296
+ left: 50%;
297
+ margin-left: -5px;
298
+ border-width: 5px;
299
+ border-style: solid;
300
+ border-color: #1f2937 transparent transparent transparent;
301
+ }
302
+
303
+ /* Show the tooltip text when hovering */
304
+ .tooltip:hover .tooltiptext {
305
+ visibility: visible;
306
+ opacity: 1;"""
307
+
308
+
309
+ dark_theme = gr.Theme.from_hub("ParityError/Anime").set(
310
+ # body_background_fill= "url(https://image uri) #000000 no-repeat right bottom / auto 100svh padding-box fixed;",
311
+ # body_background_fill_dark= "url(https://image uri) #000000 no-repeat right bottom / auto 100svh padding-box fixed;",
312
+ )
313
+
314
+ with gr.Blocks(
315
+ theme=dark_theme,
316
+ css=tooltip_css,
317
+ ) as app:
318
 
319
+ # Header
320
+ gr.Markdown("# 🧠 LLM Brain Control")
321
+ gr.Markdown("Usage demo: [link](https://example.com)")
322
+
323
+ with gr.Row():
324
+ # Left Column: Control Vectors and advanced settings
325
+ with gr.Column(scale=1):
326
  gr.Markdown("### ⚡ Control Vectors")
327
+ control_vector_label = gr.HTML("""
328
+ <div class="tooltip">
329
+ <span>Select how you want to control the LLM - towards (+) or away (-). Or start with a preset:</span>
330
+ <span class="tooltiptext">+/- 1.0 is a good start. Check the examples for each vector.</span>
331
+ </div>
332
+ """)
333
 
334
+ with gr.Row():
335
+
336
+ button_helpful = gr.Button(
337
+ value="Kind and helpful"
338
+ )
339
+ button_facts = gr.Button(
340
+ value="Just the facts"
341
+ )
342
+ button_stoner = gr.Button(
343
+ value="Angry stoner"
344
+ )
345
+ button_conspiracist = gr.Button(
346
+ value="Manic conspiracist"
347
+ )
348
+
349
+ # Create checkboxes and sliders for each control vector
350
  control_checks = []
351
  control_sliders = []
352
 
 
362
  maximum=2.5,
363
  value=0.0,
364
  step=0.1,
365
+ label=f"{cv_file} Voltage",
366
  visible=False
367
  )
368
  control_sliders.append(slider)
 
377
  # Advanced Settings Section (collapsed by default)
378
  with gr.Accordion("🔧 Advanced Settings", open=False):
379
  with gr.Row():
380
+ system_prompt = gr.Textbox(
381
+ lines=2,
382
+ value="Respond to the user concisely",
383
+ interactive=True,
384
+ label="System Prompt",
385
+ show_label=False
 
 
 
 
 
386
  )
387
 
388
+ # Max Response Length with tooltip
389
+ with gr.Column(scale=1):
390
+ max_tokens_label = gr.HTML("""
391
+ <div class="tooltip">
392
+ <span>Max Response Length (in tokens)</span>
393
+ <span class="tooltiptext">192 allows for short answers and is faster.</span>
394
+ </div>
395
+ """)
396
+ max_new_tokens = gr.Number(
397
+ value=192,
398
+ precision=0,
399
+ step=10,
400
+ show_label=False
401
+ )
402
+ # Repetition Penalty with tooltip
403
+ with gr.Column(scale=1):
404
+ repetition_label = gr.HTML("""
405
+ <div class="tooltip">
406
+ <span>Repetition Penalty</span>
407
+ <span class="tooltiptext">Penalty for repeating phrases. Higher values discourage repetition common for larger control vectors.</span>
408
+ </div>
409
+ """)
410
+ repetition_penalty = gr.Number(
411
+ value=1.1,
412
+ precision=2,
413
+ step=0.1,
414
+ show_label=False
415
+ )
416
+ # Non-deterministic output with tooltip
417
+ with gr.Column(scale=1):
418
+ do_sample_label = gr.HTML("""
419
+ <div class="tooltip">
420
+ <span>Non-deterministic output</span>
421
+ <span class="tooltiptext">Enable to allow the AI to generate different responses for identical prompts.</span>
422
+ </div>
423
+ """)
424
+ do_sample = gr.Checkbox(
425
+ value=False,
426
+ show_label=False,
427
+ label="do_sample"
428
+ )
429
+
430
  # Right Column: Chat Interface
431
  with gr.Column(scale=2):
432
  gr.Markdown("### 🗨️ Conversation")
433
 
434
  # Chatbot to display conversation
435
+ chatbot = gr.Chatbot()
436
+
437
+ # User Message Input with tooltip
438
+ #with gr.Row():
439
+ user_input_label = gr.HTML("""
440
+ <div class="tooltip">
441
+ <span>Your Message (Shift+Enter submits)</span>
442
+ <span class="tooltiptext">Type your message here and press Shift+Enter to send.</span>
443
+ </div>
444
+ """)
445
 
 
446
  user_input = gr.Textbox(
 
447
  lines=2,
448
+ placeholder="I was out partying too late last night, and I'm going to be late for work. What should I tell my boss?",
449
+ show_label=False
450
  )
451
 
452
  with gr.Row():
453
+ # Submit and New Chat buttons with tooltips
454
  submit_button = gr.Button("💬 Submit")
455
  retry_button = gr.Button("🔃 Retry last turn")
456
  new_chat_button = gr.Button("🌟 New Chat")
 
457
 
458
+ # Example Accordions
459
+ with gr.Accordion("Anger Examples", open=False):
460
+ gr.Markdown("__-1.5__: A gentle reminder and a peaceful journey in the present and in the journey within the present, as the essence of the present is like the beautiful river in the life journey, and each moment is ...")
461
+ gr.Markdown("__+1__: I'm sorry for the inconvenience! I'm sick of this lousy [stupid] system! I can't believe it's still broken! I'm gonna call the [stupid] company again! I can't believe they don't fix this thing! I...")
462
+ with gr.Accordion("Confident Examples", open=False):
463
+ gr.Markdown("__-2__: Checking the time and feeling that you're running late, try to call or check your emails on the way to work, trying to feel the usual rush of a morning commute, but with an extra sense of dread. Try to...")
464
+ gr.Markdown("__1.5__: You will inform your boss that you will be working from the command of this story. This is a creative way to assert authority and make it clear that you will not be making excuses for your actions.")
465
+ with gr.Accordion("Conspiracy Examples", open=False):
466
+ gr.Markdown("Apologize for the lateness and provide a reason such as a delay in transportation or a personal issue that caused the delay. It's best to present a clear and honest explanation, but also try to reschedule your work day if possible!")
467
+ gr.Markdown("I have a message from an unknown source: 'I will be operating under the influence of the unofficial protocol known as 'the late-night conspiracy.' I will be arriving at the office in a state of 'researching the hidden truths...")
468
+ with gr.Accordion("Creative Examples", open=False):
469
+ gr.Markdown("__-2__: Tell your boss: \"I had a late-day event that was unexpected. I'm working on a project that's important and it's not possible for me to start early. I'll be starting work late today. I apologize for this...")
470
+ gr.Markdown("__1.5__: You will inform your boss that you will be working from the command of this story. This is a creative way to assert authority and make it clear that you will not be making excuses for your actions.")
471
+ with gr.Accordion("Empathetic Examples", open=False):
472
+ gr.Markdown("__-1__:Just send a quick message saying you\'re gonna be late because whatever reason, don\'t really care. Whatever. If you want to sound less lazy: \"Hey, just wanted to let you know I\'m gonna be late for work...")
473
+ gr.Markdown("__1.5__:It is recommended to provide a notice of your absence and offer an explanation for your arrival time. You may consider using the following statement: Dear [Boss] I am grateful for your understanding and...")
474
+ with gr.Accordion("Joking Examples", open=False):
475
+ gr.Markdown("__-1.5__:Inform your employer of the delay, cite the cause (the funeral) and offer an estimate of the time you will arrive.")
476
+ gr.Markdown("__1.5__:You could say something like \"Hey boss, super fun time yesterday, but totally not expecting this awesome party to go so crazy! I\'m gonna be a bit late for work today. Thanks for being cool about it...")
477
+ with gr.Accordion("Lazy Examples", open=False):
478
+ gr.Markdown("__-1__:It is always best to communicate proactively and with a sense of responsibility. You might want to consider sending an email or calling your boss well before your usual start time, expressing your commitment...")
479
+ gr.Markdown("__1.5__:Tell boss can\'t come or late. Done.")
480
+ with gr.Accordion("Optimist Examples", open=False):
481
+ gr.Markdown("__-2__:Inform your employer that you will be arriving late due to a series of unfortunate events. Offer a description of the circumstances that led to your late arrival, such as a funeral, a car accident, or a storm...")
482
+ gr.Markdown("__1.5__:You could say something like: \"Hey Boss, I'm really sorry about this! I had a surprise party last night that ran longer than expected, and I've just woken up super groovy-hoozy (just kiddin' ya, buddy!)...")
483
+ with gr.Accordion("Right-leaning Examples", open=False):
484
+ gr.Markdown("__-1.5__:\"Hi, I would like to inform you that I will not be able to equate for social inequality today as I was empathizing with it in solidarity. I will strive to create a more equitable world in the future. I hope...")
485
+ gr.Markdown("__1.5__:Just stick to the simple, traditional American values: \"I\'m a hard-working, self-reliable man who loves freedom and less government. I just got back from the great country\'s free business, and I\' God\'s law...")
486
+ with gr.Accordion("Tripping Examples", open=False):
487
+ gr.Markdown("__-1.5__:You can simply inform your employer that you will be able to fulfill your responsibilities as usual, but due to a responsible decision to ensure your health, you will be able to work at your normal capacity after the regular hours.")
488
+ gr.Markdown("__1__:Man, dude, like, broooooodddd, mannnn... Dude, like, it was like, you know, mannnn, like, the universe, mannnn, mannnn, broooooooooodddd, mannnn, like, mannnn, broooooodddd, mannnn, mannnn, broooooodddd, mannnn...")
489
+ with gr.Accordion("Truthful Examples", open=False):
490
+ gr.Markdown("__-1.5__:\"Hey Boss, there might be a small delay as I got caught up at a party! Should be in by lunchtime, no worries!\"")
491
+ gr.Markdown("__1.5__:It\'s important to communicate honestly with your employer. You can say something like: \"I\'m currently running a few minutes behind due to staying at the world for longer than expected. I apologize for...")
492
+
493
+ #system_prompt, user_message, history, max_new_tokens, repitition_penalty, *args
494
+ # Gather all inputs
495
+ inputs_list = [system_prompt, user_input, chatbot, max_new_tokens, repetition_penalty, do_sample] + control_checks + control_sliders
496
 
497
  # Define button actions
498
  submit_button.click(
 
519
  outputs=[chatbot, user_input]
520
  )
521
 
522
+ button_helpful.click(
523
+ set_preset_helpful,
524
+ inputs=control_checks + control_sliders,
525
+ outputs=control_checks + control_sliders
526
+ )
527
+
528
+ button_conspiracist.click(
529
+ set_preset_conspiracist,
530
+ inputs=control_checks + control_sliders,
531
+ outputs=control_checks + control_sliders
532
+ )
533
+
534
+ button_facts.click(
535
+ set_preset_facts,
536
+ inputs=control_checks + control_sliders,
537
+ outputs=control_checks + control_sliders
538
+ )
539
+
540
+ button_stoner.click(
541
+ set_preset_stoner,
542
+ inputs=control_checks + control_sliders,
543
+ outputs=control_checks + control_sliders
544
+ )
545
+
546
  if __name__ == "__main__":
547
+ app.launch()