jsr90 commited on
Commit
2331097
1 Parent(s): 9ddd54f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
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
- iface = gr.Interface(fn=predict,
60
- inputs=[gr.inputs.Textbox(lines=3, label='Haz una pregunta')],
61
- outputs="text",
62
- title=title,
63
- description = description,
64
- theme="huggingface",
65
- examples=['Dónde pedir ayuda?', 'qué hacer al llegar a España?']
66
- )
67
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
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()