lewtun HF staff commited on
Commit
004554c
1 Parent(s): e169f05

Remove regenerate

Browse files
Files changed (1) hide show
  1. app.py +41 -40
app.py CHANGED
@@ -126,6 +126,7 @@ def generate(
126
  do_sample=True,
127
  truncate=999,
128
  seed=42,
 
129
  stop_sequences=["<|end|>"],
130
  )
131
 
@@ -165,30 +166,30 @@ examples = [
165
  ]
166
 
167
 
168
- def regenerate(
169
- system_message,
170
- user_message,
171
- chatbot,
172
- history,
173
- temperature=0.5,
174
- top_p=0.25,
175
- top_k=50,
176
- max_new_tokens=512,
177
- do_save=True,
178
- ):
179
- # Do nothing if there's no history
180
- if has_no_history(chatbot, history):
181
- return (
182
- chatbot,
183
- history,
184
- user_message,
185
- "",
186
- )
187
-
188
- chatbot = chatbot[:-1]
189
- history = history[:-2]
190
-
191
- return generate(system_message, user_message, chatbot, history, temperature, top_p, top_k, max_new_tokens, do_save)
192
 
193
 
194
  def clear_chat():
@@ -275,7 +276,7 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=custom_css) as demo:
275
  user_message = gr.Textbox(placeholder="Enter your message here", show_label=False, elem_id="q-input")
276
  with gr.Row():
277
  send_button = gr.Button("Send", elem_id="send-btn", visible=True)
278
- regenerate_button = gr.Button("Regenerate", elem_id="send-btn", visible=True)
279
 
280
  clear_chat_button = gr.Button("Clear chat", elem_id="clear-btn", visible=True)
281
 
@@ -366,21 +367,21 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=custom_css) as demo:
366
  outputs=[chatbot, history, last_user_message, user_message],
367
  )
368
 
369
- regenerate_button.click(
370
- regenerate,
371
- inputs=[
372
- system_message,
373
- last_user_message,
374
- chatbot,
375
- history,
376
- temperature,
377
- top_p,
378
- top_k,
379
- max_new_tokens,
380
- do_save,
381
- ],
382
- outputs=[chatbot, history, last_user_message, user_message],
383
- )
384
 
385
  clear_chat_button.click(clear_chat, outputs=[chatbot, history])
386
  # share_button.click(None, [], [], _js=share_js)
 
126
  do_sample=True,
127
  truncate=999,
128
  seed=42,
129
+ repetition_penalty=1.2,
130
  stop_sequences=["<|end|>"],
131
  )
132
 
 
166
  ]
167
 
168
 
169
+ # def regenerate(
170
+ # system_message,
171
+ # user_message,
172
+ # chatbot,
173
+ # history,
174
+ # temperature=0.5,
175
+ # top_p=0.25,
176
+ # top_k=50,
177
+ # max_new_tokens=512,
178
+ # do_save=True,
179
+ # ):
180
+ # # Do nothing if there's no history
181
+ # if has_no_history(chatbot, history):
182
+ # return (
183
+ # chatbot,
184
+ # history,
185
+ # user_message,
186
+ # "",
187
+ # )
188
+
189
+ # chatbot = chatbot[:-1]
190
+ # history = history[:-2]
191
+
192
+ # return generate(system_message, user_message, chatbot, history, temperature, top_p, top_k, max_new_tokens, do_save)
193
 
194
 
195
  def clear_chat():
 
276
  user_message = gr.Textbox(placeholder="Enter your message here", show_label=False, elem_id="q-input")
277
  with gr.Row():
278
  send_button = gr.Button("Send", elem_id="send-btn", visible=True)
279
+ # regenerate_button = gr.Button("Regenerate", elem_id="send-btn", visible=True)
280
 
281
  clear_chat_button = gr.Button("Clear chat", elem_id="clear-btn", visible=True)
282
 
 
367
  outputs=[chatbot, history, last_user_message, user_message],
368
  )
369
 
370
+ # regenerate_button.click(
371
+ # regenerate,
372
+ # inputs=[
373
+ # system_message,
374
+ # last_user_message,
375
+ # chatbot,
376
+ # history,
377
+ # temperature,
378
+ # top_p,
379
+ # top_k,
380
+ # max_new_tokens,
381
+ # do_save,
382
+ # ],
383
+ # outputs=[chatbot, history, last_user_message, user_message],
384
+ # )
385
 
386
  clear_chat_button.click(clear_chat, outputs=[chatbot, history])
387
  # share_button.click(None, [], [], _js=share_js)