Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
# app.py -
|
2 |
|
3 |
import streamlit as st
|
4 |
import pandas as pd
|
@@ -29,17 +29,17 @@ if uploaded_file:
|
|
29 |
st.subheader("π Sensor Snapshot")
|
30 |
st.dataframe(df.head())
|
31 |
|
32 |
-
# --- Multi-signal Dashboard ---
|
33 |
-
st.
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
# --- Convert Logs to Chunks ---
|
45 |
def convert_to_chunks(df):
|
@@ -49,7 +49,6 @@ if uploaded_file:
|
|
49 |
chunks.append(sentence)
|
50 |
return chunks
|
51 |
|
52 |
-
# Ensure initialization
|
53 |
if 'chunks' not in st.session_state or 'embeddings' not in st.session_state:
|
54 |
chunks = convert_to_chunks(df)
|
55 |
embeddings = EMBED_MODEL.encode(chunks)
|
@@ -84,15 +83,13 @@ if uploaded_file:
|
|
84 |
href = f'<a href="data:application/octet-stream;base64,{b64}" download="digital_twin_report.pdf">π Download PDF Report</a>'
|
85 |
st.markdown(href, unsafe_allow_html=True)
|
86 |
|
87 |
-
# --- Role-based Factory Assistant ---
|
88 |
st.subheader("π¬ Factory Assistant Chat")
|
89 |
-
|
90 |
roles = {
|
91 |
"Operator": "You are a machine operator. Provide practical insights and safety warnings.",
|
92 |
"Maintenance": "You are a maintenance technician. Suggest inspections and likely causes of sensor anomalies.",
|
93 |
"Engineer": "You are a control systems engineer. Offer analytical interpretations and system-level advice."
|
94 |
}
|
95 |
-
|
96 |
role = st.selectbox("π€ Choose your role: Operator, Maintenance, or Engineer", list(roles.keys()))
|
97 |
|
98 |
if 'chat_history' not in st.session_state:
|
|
|
1 |
+
# app.py - FactoryGPT: FactoryGPT Humanization for the Factories of the Future in Industry 5.0 β Predict, Perfect, and Connect
|
2 |
|
3 |
import streamlit as st
|
4 |
import pandas as pd
|
|
|
29 |
st.subheader("π Sensor Snapshot")
|
30 |
st.dataframe(df.head())
|
31 |
|
32 |
+
# --- Multi-signal Dashboard (Collapsible) ---
|
33 |
+
with st.expander("π Expand to View Sensor Dashboard", expanded=False):
|
34 |
+
selected_cols = st.multiselect("Select signals to visualize", numeric_cols, default=numeric_cols[:3])
|
35 |
+
fig, ax = plt.subplots(len(selected_cols), 1, figsize=(8, 2 * len(selected_cols)))
|
36 |
+
if len(selected_cols) == 1:
|
37 |
+
ax = [ax]
|
38 |
+
for i, col in enumerate(selected_cols):
|
39 |
+
ax[i].plot(df[col], label=col)
|
40 |
+
ax[i].set_ylabel(col)
|
41 |
+
ax[i].legend()
|
42 |
+
st.pyplot(fig)
|
43 |
|
44 |
# --- Convert Logs to Chunks ---
|
45 |
def convert_to_chunks(df):
|
|
|
49 |
chunks.append(sentence)
|
50 |
return chunks
|
51 |
|
|
|
52 |
if 'chunks' not in st.session_state or 'embeddings' not in st.session_state:
|
53 |
chunks = convert_to_chunks(df)
|
54 |
embeddings = EMBED_MODEL.encode(chunks)
|
|
|
83 |
href = f'<a href="data:application/octet-stream;base64,{b64}" download="digital_twin_report.pdf">π Download PDF Report</a>'
|
84 |
st.markdown(href, unsafe_allow_html=True)
|
85 |
|
86 |
+
# --- Role-based Factory Assistant Chatbot ---
|
87 |
st.subheader("π¬ Factory Assistant Chat")
|
|
|
88 |
roles = {
|
89 |
"Operator": "You are a machine operator. Provide practical insights and safety warnings.",
|
90 |
"Maintenance": "You are a maintenance technician. Suggest inspections and likely causes of sensor anomalies.",
|
91 |
"Engineer": "You are a control systems engineer. Offer analytical interpretations and system-level advice."
|
92 |
}
|
|
|
93 |
role = st.selectbox("π€ Choose your role: Operator, Maintenance, or Engineer", list(roles.keys()))
|
94 |
|
95 |
if 'chat_history' not in st.session_state:
|