import streamlit as st from transformers import pipeline # Set Streamlit page config st.set_page_config(page_title="StructuLearn - Structural Tutor", layout="centered") # Load the Hugging Face model pipeline @st.cache_resource def load_model(): return pipeline("text-generation", model="tiiuae/falcon-7b-instruct", max_length=512) qa_pipeline = load_model() # App title st.title("🏗️ StructuLearn: Ask About Structural Concepts") st.write("This is an AI-powered learning tool for junior structural engineers. Ask any question about structural design, codes, or analysis.") # User input user_question = st.text_input("🧠 What do you want to learn about?", placeholder="e.g. What is buckling in columns?") if st.button("Get Answer"): if user_question.strip() == "": st.warning("Please enter a question.") else: with st.spinner("Thinking like an engineer..."): response = qa_pipeline(f"Explain like I'm a structural engineering intern: {user_question}") answer = response[0]['generated_text'] st.subheader("📘 Explanation") st.write(answer)