Update app.py
Browse files
app.py
CHANGED
@@ -245,6 +245,19 @@ def reset_name_interface():
|
|
245 |
chat_log_name = ""
|
246 |
return "User info has been reset."
|
247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
def reset_all():
|
249 |
global unique_id
|
250 |
message1 = reset_chat_interface()
|
@@ -286,12 +299,19 @@ with gr.Blocks() as app:
|
|
286 |
|
287 |
|
288 |
with gr.Tab("Chat Bot"):
|
289 |
-
chatbot = gr.Chatbot()
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
with gr.Tab("Reset"):
|
297 |
reset_button = gr.Button("Reset ChatBot Instance")
|
|
|
245 |
chat_log_name = ""
|
246 |
return "User info has been reset."
|
247 |
|
248 |
+
|
249 |
+
def add_text(history, text):
|
250 |
+
history = history + [(text, None)]
|
251 |
+
return history, gr.Textbox(value="", interactive=False)
|
252 |
+
|
253 |
+
def bot(history):
|
254 |
+
response = "**That's cool!**"
|
255 |
+
history[-1][1] = ""
|
256 |
+
for character in response:
|
257 |
+
history[-1][1] += character
|
258 |
+
time.sleep(0.05)
|
259 |
+
yield history
|
260 |
+
|
261 |
def reset_all():
|
262 |
global unique_id
|
263 |
message1 = reset_chat_interface()
|
|
|
299 |
|
300 |
|
301 |
with gr.Tab("Chat Bot"):
|
302 |
+
chatbot = gr.Chatbot([],elem_id="chatbot",bubble_full_width=False,)
|
303 |
+
with gr.Row():
|
304 |
+
|
305 |
+
txt = gr.Textbox(
|
306 |
+
scale=4,
|
307 |
+
show_label=False,
|
308 |
+
placeholder="Enter text and press enter, or upload an image",
|
309 |
+
container=False,)
|
310 |
+
|
311 |
+
txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
|
312 |
+
bot, chatbot, chatbot, api_name="bot_response"
|
313 |
+
)
|
314 |
+
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
315 |
|
316 |
with gr.Tab("Reset"):
|
317 |
reset_button = gr.Button("Reset ChatBot Instance")
|