HudaQamber/Learning_structures
0
1import streamlit as st2from transformers import pipeline3 4# Set Streamlit page config5st.set_page_config(page_title="StructuLearn - Structural Tutor", layout="centered")6 7# Load the Hugging Face model pipeline8@st.cache_resource9def load_model():10 return pipeline("text-generation", model="tiiuae/falcon-7b-instruct", max_length=512)11 12qa_pipeline = load_model()13 14# App title15st.title("๐๏ธ StructuLearn: Ask About Structural Concepts")16st.write("This is an AI-powered learning tool for junior structural engineers. Ask any question about structural design, codes, or analysis.")17 18# User input19user_question = st.text_input("๐ง What do you want to learn about?", placeholder="e.g. What is buckling in columns?")20 21if st.button("Get Answer"):22 if user_question.strip() == "":23 st.warning("Please enter a question.")24 else:25 with st.spinner("Thinking like an engineer..."):26 response = qa_pipeline(f"Explain like I'm a structural engineering intern: {user_question}")27 answer = response[0]['generated_text']28 st.subheader("๐ Explanation")29 st.write(answer)30 