Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Set Streamlit page config
|
5 |
+
st.set_page_config(page_title="StructuLearn - Structural Tutor", layout="centered")
|
6 |
+
|
7 |
+
# Load the Hugging Face model pipeline
|
8 |
+
@st.cache_resource
|
9 |
+
def load_model():
|
10 |
+
return pipeline("text-generation", model="tiiuae/falcon-7b-instruct", max_length=512)
|
11 |
+
|
12 |
+
qa_pipeline = load_model()
|
13 |
+
|
14 |
+
# App title
|
15 |
+
st.title("🏗️ StructuLearn: Ask About Structural Concepts")
|
16 |
+
st.write("This is an AI-powered learning tool for junior structural engineers. Ask any question about structural design, codes, or analysis.")
|
17 |
+
|
18 |
+
# User input
|
19 |
+
user_question = st.text_input("🧠 What do you want to learn about?", placeholder="e.g. What is buckling in columns?")
|
20 |
+
|
21 |
+
if 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)
|