Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,15 +53,27 @@ def predict(question):
|
|
53 |
return answers
|
54 |
|
55 |
|
56 |
-
title = "Chatbot Refugiados"
|
57 |
-
description= "Our chatbot helps refugees arriving in Spain by providing information on key topics. This project is based on the article titled [Desarrollando un chatbot para refugiados: nuestra experiencia en Saturdays.AI](https://medium.com/saturdays-ai/desarrollando-un-chatbot-para-refugiados-nuestra-experiencia-en-saturdays-ai-9bf2551432c9), which outlines the process of building a chatbot for refugees. \n You can find the training script in this [github repo](https://github.com/jsr90/chatbot_refugiados_train)."
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
return answers
|
54 |
|
55 |
|
56 |
+
title = "# Chatbot Refugiados (spanish)"
|
57 |
+
description= "Our chatbot helps refugees arriving in Spain by providing information on key topics. \n This project is based on the article titled [Desarrollando un chatbot para refugiados: nuestra experiencia en Saturdays.AI](https://medium.com/saturdays-ai/desarrollando-un-chatbot-para-refugiados-nuestra-experiencia-en-saturdays-ai-9bf2551432c9), which outlines the process of building a chatbot for refugees. \n You can find the training script in this [github repo](https://github.com/jsr90/chatbot_refugiados_train)."
|
58 |
|
59 |
+
with gr.Blocks() as demo:
|
60 |
+
gr.Markdown(title)
|
61 |
+
gr.Markdown(description)
|
62 |
+
chatbot = gr.Chatbot()
|
63 |
+
msg = gr.Textbox(label="Write your question:", value="¿Dónde puedo solicitar asilo?")
|
64 |
+
submit = gr.Button("Submit")
|
65 |
+
clear = gr.Button("Clear")
|
66 |
+
|
67 |
+
def respond(message, chat_history):
|
68 |
+
if len(message)==0:
|
69 |
+
message="¿Dónde puedo solicitar asilo?"
|
70 |
+
bot_message = predict(message)[0]['answer']
|
71 |
+
chat_history.append((message, bot_message))
|
72 |
+
return "", chat_history
|
73 |
+
|
74 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
75 |
+
submit.click(respond, [msg, chatbot], [msg, chatbot])
|
76 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
77 |
+
|
78 |
+
if __name__ == "__main__":
|
79 |
+
demo.launch()
|