import streamlit as st from transformers import pipeline st.title("❓ AI Question Answering Bot") @st.cache_resource def load_qa(): return pipeline("question-answering", model="deepset/roberta-base-squad2") qa = load_qa() # Set a static context or let user provide it context = st.text_area("📄 Paste your reference text (context):", "The QA QC Electrical Inspector ensures the quality of installations, performs inspection and testing, and checks documentation in power and oil & gas projects.") question = st.text_input("❓ Your question:") if question: try: with st.spinner("Thinking..."): answer = qa(question=question, context=context) st.markdown(f"**Answer:** {answer['answer']}") except Exception as e: st.error("Something went wrong.") st.exception(e)