IAMTFRMZA commited on
Commit
74246a4
Β·
verified Β·
1 Parent(s): af951b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -10,7 +10,7 @@ from openai import OpenAI
10
  # ------------------ App Configuration ------------------
11
  st.set_page_config(page_title="Schlaeger Forrestdale DocAIA", layout="wide")
12
  st.title("πŸ“„ Schlaeger Forrestdale Document Assistant")
13
- st.caption("Chat with construction documents using OCR-based AI")
14
 
15
  # ------------------ Load API Key and Assistant ID ------------------
16
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
@@ -61,26 +61,21 @@ with image_col:
61
 
62
  # ------------------ Chat Interface ------------------
63
  with chat_col:
64
- st.markdown("### 🧠 Ask a Question or Choose Below")
65
- prompt = st.chat_input("What would you like to ask about the construction documents?")
66
-
67
- # Quick Action Buttons
68
- st.markdown("#### ⚑ Quick Prompts")
69
- quick_cols = st.columns(3)
70
- with quick_cols[0]:
71
- if st.button("πŸ” Summary Mode"):
72
- prompt = "Summarize this section."
73
- with quick_cols[1]:
74
- if st.button("πŸ“˜ FAQ Mode"):
75
- prompt = "Generate FAQs from this section."
76
- with quick_cols[2]:
77
- if st.button("🧾 Compliance Info"):
78
- prompt = "What are the safety and compliance measures?"
79
-
80
- # Display Message History
81
- for msg in st.session_state.messages:
82
- with st.chat_message(msg["role"]):
83
- st.markdown(msg["content"])
84
 
85
  if prompt:
86
  st.session_state.messages.append({"role": "user", "content": prompt})
@@ -93,7 +88,7 @@ with chat_col:
93
 
94
  run = client.beta.threads.runs.create(thread_id=st.session_state.thread_id, assistant_id=ASSISTANT_ID)
95
 
96
- with st.spinner("πŸ€– Processing your query..."):
97
  while True:
98
  run_status = client.beta.threads.runs.retrieve(thread_id=st.session_state.thread_id, run_id=run.id)
99
  if run_status.status == "completed":
@@ -119,3 +114,7 @@ with chat_col:
119
  st.rerun()
120
  except Exception as e:
121
  st.error(f"❌ Error: {e}")
 
 
 
 
 
10
  # ------------------ App Configuration ------------------
11
  st.set_page_config(page_title="Schlaeger Forrestdale DocAIA", layout="wide")
12
  st.title("πŸ“„ Schlaeger Forrestdale Document Assistant")
13
+ st.caption("Explore technical construction documents via AI with OCR references")
14
 
15
  # ------------------ Load API Key and Assistant ID ------------------
16
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
 
61
 
62
  # ------------------ Chat Interface ------------------
63
  with chat_col:
64
+ st.markdown("### 🧠 Ask a Document-Specific Question")
65
+ prompt = st.chat_input("Example: What is the defects liability period?")
66
+
67
+ st.markdown("<hr style='margin:0.5em 0;'>", unsafe_allow_html=True)
68
+ st.markdown("#### ⚑ Prompt Templates")
69
+ col_btn1, col_btn2, col_btn3 = st.columns(3)
70
+ with col_btn1:
71
+ if st.button("Summarize Current Page"):
72
+ prompt = "Summarize the current page."
73
+ with col_btn2:
74
+ if st.button("List Contractual Obligations"):
75
+ prompt = "List the contractual obligations from this section."
76
+ with col_btn3:
77
+ if st.button("Find Related AS Clauses"):
78
+ prompt = "Which clauses reference AS 4000-1997 or similar standards?"
 
 
 
 
 
79
 
80
  if prompt:
81
  st.session_state.messages.append({"role": "user", "content": prompt})
 
88
 
89
  run = client.beta.threads.runs.create(thread_id=st.session_state.thread_id, assistant_id=ASSISTANT_ID)
90
 
91
+ with st.spinner("πŸ€– Parsing and responding with referenced content..."):
92
  while True:
93
  run_status = client.beta.threads.runs.retrieve(thread_id=st.session_state.thread_id, run_id=run.id)
94
  if run_status.status == "completed":
 
114
  st.rerun()
115
  except Exception as e:
116
  st.error(f"❌ Error: {e}")
117
+
118
+ for msg in st.session_state.messages:
119
+ with st.chat_message(msg["role"]):
120
+ st.markdown(msg["content"], unsafe_allow_html=True)