File size: 1,128 Bytes
7e8dfcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)