Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,4 +118,41 @@ if st.button("Get Cost Estimate"):
|
|
| 118 |
st.markdown(estimate)
|
| 119 |
else:
|
| 120 |
st.warning("Please enter a prompt first.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
|
|
|
| 118 |
st.markdown(estimate)
|
| 119 |
else:
|
| 120 |
st.warning("Please enter a prompt first.")
|
| 121 |
+
st.markdown("### 🏗️ Building Code Comparison")
|
| 122 |
+
|
| 123 |
+
province_1 = st.selectbox("Select first province:", [
|
| 124 |
+
"British Columbia", "Alberta", "Ontario", "Quebec", "Atlantic Canada", "Prairies"
|
| 125 |
+
], key="prov1")
|
| 126 |
+
|
| 127 |
+
province_2 = st.selectbox("Select second province:", [
|
| 128 |
+
"British Columbia", "Alberta", "Ontario", "Quebec", "Atlantic Canada", "Prairies"
|
| 129 |
+
], key="prov2")
|
| 130 |
+
|
| 131 |
+
if st.button("Compare Building Codes"):
|
| 132 |
+
if province_1 != province_2:
|
| 133 |
+
with st.spinner("Comparing codes across provinces..."):
|
| 134 |
+
def compare_building_codes(p1, p2, prompt):
|
| 135 |
+
system_instruction = (
|
| 136 |
+
"You are a Canadian building code expert. Compare the key differences in building code requirements "
|
| 137 |
+
f"between {p1} and {p2} for residential construction, especially related to small or modern homes like the one described below. "
|
| 138 |
+
"Focus on differences in energy efficiency, foundations, insulation, accessibility, and design limitations. "
|
| 139 |
+
"Keep your response clear and under 10 bullet points."
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
response = client.chat.completions.create(
|
| 143 |
+
model="gpt-4",
|
| 144 |
+
messages=[
|
| 145 |
+
{"role": "system", "content": system_instruction},
|
| 146 |
+
{"role": "user", "content": prompt}
|
| 147 |
+
],
|
| 148 |
+
temperature=0.7
|
| 149 |
+
)
|
| 150 |
+
return response.choices[0].message.content.strip()
|
| 151 |
+
|
| 152 |
+
comparison = compare_building_codes(province_1, province_2, st.session_state.prompt)
|
| 153 |
+
st.markdown(f"### 🏛️ {province_1} vs. {province_2}")
|
| 154 |
+
st.markdown(comparison)
|
| 155 |
+
else:
|
| 156 |
+
st.warning("Please select two different provinces.")
|
| 157 |
+
|
| 158 |
|