Spaces:
Runtime error
Runtime error
artificialguybr
commited on
Commit
•
6ac567d
1
Parent(s):
c314120
Update app.py
Browse files
app.py
CHANGED
@@ -22,21 +22,13 @@ def user(message, history):
|
|
22 |
history.append([message, ""])
|
23 |
return "", history
|
24 |
|
25 |
-
def regenerate(
|
26 |
-
|
27 |
-
if
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
_task_history.append([last_message[0], ""])
|
33 |
-
new_history, _, _ = chat(_task_history, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty)
|
34 |
-
print(f"New history: {new_history}") # Debugging line
|
35 |
-
yield new_history
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
42 |
history = history or []
|
@@ -133,9 +125,11 @@ with gr.Blocks() as demo:
|
|
133 |
|
134 |
# Stop button remains the same
|
135 |
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
139 |
)
|
140 |
|
141 |
|
|
|
22 |
history.append([message, ""])
|
23 |
return "", history
|
24 |
|
25 |
+
def regenerate(history, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
26 |
+
# Remove the last item from the history
|
27 |
+
if history:
|
28 |
+
history.pop(-1)
|
29 |
+
|
30 |
+
# Re-execute the chat function
|
31 |
+
return chat(history, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
34 |
history = history or []
|
|
|
125 |
|
126 |
# Stop button remains the same
|
127 |
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
|
128 |
+
regen_click_event = regen_btn.click(
|
129 |
+
fn=regenerate,
|
130 |
+
inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty],
|
131 |
+
outputs=[chatbot, chat_history_state, message],
|
132 |
+
queue=True
|
133 |
)
|
134 |
|
135 |
|