Spaces:
Runtime error
Runtime error
letrunglinh
commited on
Commit
•
13db79f
1
Parent(s):
29ba7fe
Update app.py
Browse files
app.py
CHANGED
@@ -56,13 +56,26 @@ def get_answer_e2e(question):
|
|
56 |
|
57 |
return best_answer
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
return best_answer
|
58 |
|
59 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
60 |
+
gr.Markdown("<h1><center>CHATBOT - I know what you want 💬</center></h1>")
|
61 |
+
chatbot = gr.Chatbot(show_label=True, value=[[None,'Hi👋,How can i help you?']])
|
62 |
+
msg = gr.Textbox(label="Question",placeholder="Enter your question and press Enter...")
|
63 |
+
clear = gr.Button("Clear")
|
64 |
+
|
65 |
+
def user(user_message, history):
|
66 |
+
return "", history + [[user_message, None]]
|
67 |
+
|
68 |
+
def bot(history):
|
69 |
+
|
70 |
+
best_answer = get_answer_e2e(history[-1][0])
|
71 |
+
|
72 |
+
history[-1][1] = best_answer
|
73 |
+
|
74 |
+
return history
|
75 |
+
|
76 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False ,scroll_to_output=True, show_progress=True, ).then(
|
77 |
+
bot, chatbot, chatbot
|
78 |
+
)
|
79 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
80 |
+
|
81 |
+
demo.launch()
|