rocketpal commited on
Commit
51791c5
·
verified ·
1 Parent(s): e9f720e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -114,19 +114,25 @@ with gr.Blocks() as demo:
114
  ],
115
  height=200,
116
  )
117
-
118
  with gr.Row():
119
  with gr.Column(scale=2):
120
- chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
 
 
 
 
 
 
121
  chat_btn = gr.Button("Add messages")
122
 
123
- chat_btn.click(
124
- lambda history: history
125
- + [["How are you?", "I am good."]]
126
- + (time.sleep(2) or []),
127
- chatbot,
128
- chatbot,
129
- )
130
  with gr.Column(scale=1):
131
  with gr.Accordion("Advanced Settings"):
132
  gr.Markdown("Hello")
@@ -137,3 +143,4 @@ with gr.Blocks() as demo:
137
 
138
  if __name__ == "__main__":
139
  demo.queue().launch(theme='rocketpal/apple-light')
 
 
114
  ],
115
  height=200,
116
  )
117
+
118
  with gr.Row():
119
  with gr.Column(scale=2):
120
+ chatbot = gr.Chatbot(
121
+ value=[
122
+ {"role": "user", "content": "Hello"},
123
+ {"role": "assistant", "content": "Hi"}
124
+ ],
125
+ label="Chatbot"
126
+ )
127
  chat_btn = gr.Button("Add messages")
128
 
129
+ def add_messages(history):
130
+ time.sleep(2)
131
+ history.append({"role": "user", "content": "How are you?"})
132
+ history.append({"role": "assistant", "content": "I am good."})
133
+ return history
134
+
135
+ chat_btn.click(add_messages, chatbot, chatbot)
136
  with gr.Column(scale=1):
137
  with gr.Accordion("Advanced Settings"):
138
  gr.Markdown("Hello")
 
143
 
144
  if __name__ == "__main__":
145
  demo.queue().launch(theme='rocketpal/apple-light')
146
+