from transformers import pipeline import streamlit as st from streamlit_chat import message st.set_page_config( page_title="WLS", page_icon=":robot:" ) st.header("We Love Sousse ChatBot") # Load the pre-trained question answering model qa_model = pipeline('question-answering', model='bert-large-uncased-whole-word-masking-finetuned-squad') # Provide the context and question for the model to answer context = """"We Love Sousse" is a humanitarian club that is dedicated to helping those in need in the city of Sousse, Tunisia. The club is made up of passionate individuals who are committed to making a positive impact on their community by engaging in various activities that support the well-being of others. One of the main goals of the "We Love Sousse" club is to promote humanitarianism by encouraging its members and the community at large to engage in volunteer work, charitable donations, and other forms of support for those who are struggling. The club is committed to creating a culture of compassion and kindness in Sousse, where people are always looking out for one another and working together to build a stronger and more resilient community. The "We Love Sousse" club engages in a wide range of activities to achieve its goals. Some of these activities include: Community Service: The club organizes regular volunteer work in various locations throughout Sousse, including hospitals, orphanages, and elderly care facilities. Members of the club spend time with the residents, provide them with assistance and support, and help to improve their living conditions. Fundraising: The club raises funds through various activities, such as charity events, auctions, and crowdfunding campaigns. The money raised is used to support various humanitarian causes in the city, such as providing food, clothing, and shelter to those in need. Awareness Campaigns: The club runs awareness campaigns to educate the community about various social issues affecting the city. These campaigns cover topics such as homelessness, poverty, healthcare, and education, and aim to inspire people to take action and make a positive difference in the lives of others. Donations: The club collects donations of food, clothing, and other essential items from members of the community and distributes them to those in need. The club also organizes toy drives during the holiday season to provide gifts to children who might otherwise go without. Overall, the "We Love Sousse" club is committed to making a positive difference in the lives of others in Sousse through its various humanitarian activities. The club's goal is to create a more compassionate, empathetic, and supportive community where everyone has the opportunity to thrive. """ if 'generated' not in st.session_state: st.session_state['generated'] = [] if 'past' not in st.session_state: st.session_state['past'] = [] def get_text(): input_text = st.text_input("You: "," ", key="input") return input_text # message("Hello, How can I help you?") # message(" ",is_user=True) # question = get_text() # # while True: # if st.button("Send"): # # Generate the answer using the model # message(question,is_user=True) # answer = qa_model(question=question, context=context) # message(answer) # Provide the context and question for the model to answer # context = "Paris is the capital and most populous city of France." # question = "What is the capital of France?" question = "tell me about i love sousse" # Generate the answer using the model st.write(question) answer = qa_model(question=question, context=context) sleep(2) # Print the answer st.write(answer) # Print the answer # print(answer)