Spaces:
Runtime error
Runtime error
| # Author: Ricardo Lisboa Santos | |
| # Creation date: 2024-01-10 | |
| import streamlit as st | |
| import AI.question_answering as ai | |
| def run(): | |
| st.set_page_config(page_title="Question Answering", page_icon="π") | |
| st.markdown("# Question Answering") | |
| st.write('Give some context. Ask some questions.') | |
| context = st.text_area('Enter your context here.') | |
| question = st.text_input('Enter your question here.') | |
| if st.button('Click me to run'): | |
| progress_bar = st.sidebar.progress(0) | |
| status_text = st.sidebar.empty() | |
| with st.spinner(text='Loading Model'): | |
| status_text.text("Getting Device") | |
| device = ai.getDevice("cpu") | |
| progress_bar.progress(30) | |
| status_text.text("Loading Model") | |
| model = ai.loadGenerator(device) | |
| progress_bar.progress(60) | |
| status_text.text("Generating Answer") | |
| output = ai.query(model, question, context) | |
| progress_bar.progress(90) | |
| status_text.text("Clearing Cache") | |
| ai.clearCache("cpu", model) | |
| progress_bar.progress(100) | |
| status_text.text("Done") | |
| st.code(output.get('answer')) | |
| # st.success('Done') | |
| if __name__ == '__main__': | |
| run() |