Spaces:
Runtime error
Runtime error
artificialguybr
commited on
Commit
•
e61245d
1
Parent(s):
7e4cf08
Update app.py
Browse files
app.py
CHANGED
@@ -22,13 +22,17 @@ def user(message, history):
|
|
22 |
history.append([message, ""])
|
23 |
return "", history
|
24 |
|
25 |
-
def regenerate(
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
# Re-execute the chat function
|
31 |
-
new_history, _, _ = chat(history, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty)
|
32 |
return new_history, new_history, ""
|
33 |
|
34 |
|
@@ -129,12 +133,11 @@ with gr.Blocks() as demo:
|
|
129 |
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
|
130 |
regen_click_event = regen_btn.click(
|
131 |
fn=regenerate,
|
132 |
-
inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty],
|
133 |
outputs=[chatbot, chat_history_state, message],
|
134 |
queue=True
|
135 |
)
|
136 |
|
137 |
|
138 |
-
|
139 |
demo.queue(max_size=128, concurrency_count=2)
|
140 |
demo.launch()
|
|
|
22 |
history.append([message, ""])
|
23 |
return "", history
|
24 |
|
25 |
+
def regenerate(chatbot, chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
26 |
+
if not chat_history_state:
|
27 |
+
return chatbot, chat_history_state, ""
|
28 |
+
|
29 |
+
# Remove the last item from the chat history
|
30 |
+
if len(chat_history_state) > 0:
|
31 |
+
chat_history_state.pop(-1)
|
32 |
+
|
33 |
+
# Re-run the chat function
|
34 |
+
new_history, _, _ = chat(chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty)
|
35 |
|
|
|
|
|
36 |
return new_history, new_history, ""
|
37 |
|
38 |
|
|
|
133 |
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
|
134 |
regen_click_event = regen_btn.click(
|
135 |
fn=regenerate,
|
136 |
+
inputs=[chatbot, chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty],
|
137 |
outputs=[chatbot, chat_history_state, message],
|
138 |
queue=True
|
139 |
)
|
140 |
|
141 |
|
|
|
142 |
demo.queue(max_size=128, concurrency_count=2)
|
143 |
demo.launch()
|