bhagwandas commited on
Commit
bcf8dac
Β·
verified Β·
1 Parent(s): ff73cbe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py - FactoryRAG+: Smart Chatbot with Role-Based Assistant, Dashboard, PDF, and Digital Twin
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.subheader("πŸ“ˆ Sensor Dashboard")
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,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: