Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,28 +52,35 @@ def predict(question):
|
|
52 |
answers = print_answers(result)
|
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.
|
61 |
-
gr.
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
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()
|
|
|
52 |
answers = print_answers(result)
|
53 |
return answers
|
54 |
|
55 |
+
def respond(message, chat_history):
|
56 |
+
if len(message)==0:
|
57 |
+
message="¿Dónde puedo solicitar asilo?"
|
58 |
+
bot_message = predict(message)[0]['answer']
|
59 |
+
chat_history.append((message, bot_message))
|
60 |
+
return "", chat_history
|
61 |
|
|
|
62 |
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)."
|
63 |
|
64 |
+
with gr.Blocks(theme="huggingface") as demo:
|
65 |
+
gr.HTML("<h1 style='text-align: center; font-size: xx-large'>Chatbot Refugiados (spanish)</h1>")
|
66 |
+
gr.HTML("<h2 style='text-align: center; font-size: large'>The demo you're about to see is from a project currently in development.</h2>")
|
67 |
+
|
68 |
+
with gr.Row():
|
69 |
+
with gr.Column(scale=2):
|
70 |
+
chatbot = gr.Chatbot()
|
71 |
+
with gr.Column(scale=1):
|
72 |
+
with gr.Row():
|
73 |
+
msg = gr.Textbox(label="Write your question:", value="¿Dónde puedo solicitar asilo?")
|
74 |
+
with gr.Row():
|
75 |
+
submit = gr.Button("Submit")
|
76 |
+
clear = gr.Button("Clear")
|
77 |
+
gr.Image("OIG.jpeg")
|
78 |
|
79 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
80 |
submit.click(respond, [msg, chatbot], [msg, chatbot])
|
81 |
clear.click(lambda: None, None, chatbot, queue=False)
|
82 |
|
83 |
+
gr.Markdown(description)
|
84 |
+
|
85 |
if __name__ == "__main__":
|
86 |
demo.launch()
|