Ozaii commited on
Commit
78ac739
·
verified ·
1 Parent(s): 0d63733

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -61,7 +61,8 @@ def chat_with_zephyr(message, history):
61
  # Extract Zephyr's response
62
  zephyr_response = response.split("Zephyr:")[-1].strip()
63
 
64
- return zephyr_response
 
65
 
66
  css = """
67
  body {
@@ -79,7 +80,18 @@ with gr.Blocks(css=css) as iface:
79
  msg = gr.Textbox(placeholder="Tell Zephyr what's on your mind...", label="Your message")
80
  clear = gr.Button("Clear Chat")
81
 
82
- msg.submit(chat_with_zephyr, [msg, chatbot], [chatbot])
 
 
 
 
 
 
 
 
 
 
 
83
  clear.click(lambda: None, None, chatbot, queue=False)
84
 
85
  gr.Markdown("""
 
61
  # Extract Zephyr's response
62
  zephyr_response = response.split("Zephyr:")[-1].strip()
63
 
64
+ # Return the new message pair
65
+ return "", zephyr_response
66
 
67
  css = """
68
  body {
 
80
  msg = gr.Textbox(placeholder="Tell Zephyr what's on your mind...", label="Your message")
81
  clear = gr.Button("Clear Chat")
82
 
83
+ def user(user_message, history):
84
+ return "", history + [[user_message, None]]
85
+
86
+ def bot(history):
87
+ user_message = history[-1][0]
88
+ bot_response = chat_with_zephyr(user_message, history[:-1])
89
+ history[-1][1] = bot_response
90
+ return history
91
+
92
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
93
+ bot, chatbot, chatbot
94
+ )
95
  clear.click(lambda: None, None, chatbot, queue=False)
96
 
97
  gr.Markdown("""