Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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("
|
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
|
65 |
-
prompt = st.chat_input("What
|
66 |
-
|
67 |
-
|
68 |
-
st.markdown("#### β‘
|
69 |
-
|
70 |
-
with
|
71 |
-
if st.button("
|
72 |
-
prompt = "Summarize
|
73 |
-
with
|
74 |
-
if st.button("
|
75 |
-
prompt = "
|
76 |
-
with
|
77 |
-
if st.button("
|
78 |
-
prompt = "
|
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("π€
|
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)
|