crystalkalem commited on
Commit
a403df4
·
verified ·
1 Parent(s): 8a083e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -20,8 +20,21 @@ def generate(message, history,temperature=0.7,max_tokens=1024):
20
  mychatbot = gr.Chatbot(
21
  avatar_images=["user.png", "bots.png"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True,)
22
 
23
- iface = gr.ChatInterface(fn=generate, chatbot=mychatbot, retry_btn=retry_last_message, undo_btn=None)
 
 
 
 
24
 
 
 
 
 
 
 
 
 
 
25
  with gr.Blocks() as demo:
26
  gr.HTML("<center><h1>Chat with Solar</h1></center>")
27
  iface.render()
 
20
  mychatbot = gr.Chatbot(
21
  avatar_images=["user.png", "bots.png"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True,)
22
 
23
+ def retry(message, history):
24
+ # Remove the last user message from the history
25
+ history = history[:-1]
26
+ # Generate a new response using the updated history
27
+ return generate(message, history)
28
 
29
+ def undo(message, history):
30
+ # Remove the last user message and the last bot response from the history
31
+ history = history[:-2]
32
+ # Return the updated history
33
+ return history
34
+
35
+
36
+ iface = gr.ChatInterface(fn=generate, chatbot=mychatbot, retry_btn=retry, undo_btn=undo)
37
+
38
  with gr.Blocks() as demo:
39
  gr.HTML("<center><h1>Chat with Solar</h1></center>")
40
  iface.render()