Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,58 +54,63 @@ def parse_home_depot(html):
|
|
54 |
|
55 |
# === Streamlit App ===
|
56 |
|
57 |
-
|
58 |
-
st.
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
st.
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
elif agent == "Agent 3: Material Explorer":
|
97 |
-
st.header("๐ฆ Building Material Browser")
|
98 |
-
st.markdown("Browse current **laminate flooring** options from Home Depot.")
|
99 |
-
|
100 |
-
if st.button("Get Laminate Flooring Options"):
|
101 |
-
with st.spinner("Scraping Home Depot via Zyte..."):
|
102 |
-
html = zyte_scrape(LAMINATE_FLOORING_URL)
|
103 |
-
if html:
|
104 |
-
data = parse_home_depot(html)
|
105 |
-
if data:
|
106 |
-
st.success("Here are some laminate flooring options:")
|
107 |
-
st.table(data)
|
108 |
-
else:
|
109 |
-
st.warning("No products found. Parsing may need updating.")
|
110 |
else:
|
111 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
# === Streamlit App ===
|
56 |
|
57 |
+
def main():
|
58 |
+
st.set_page_config(page_title="AI Architecture Assistant", layout="centered")
|
59 |
+
st.title("๐๏ธ AI Architecture Assistant")
|
60 |
+
|
61 |
+
# === Agent Selector ===
|
62 |
+
agent = st.selectbox("Choose an Agent:", ["Agent 1: Floor Plan Generator", "Agent 3: Material Explorer"])
|
63 |
+
|
64 |
+
if agent == "Agent 1: Floor Plan Generator":
|
65 |
+
st.header("๐ผ๏ธ Generate a Tiny Home Floor Plan")
|
66 |
+
|
67 |
+
if "prompt" not in st.session_state:
|
68 |
+
st.session_state.prompt = ""
|
69 |
+
|
70 |
+
st.text_area("Enter your prompt:", key="prompt_input", value=st.session_state.prompt, height=200)
|
71 |
+
|
72 |
+
if st.button("Insert Sample Prompt"):
|
73 |
+
st.session_state.prompt = sample_prompt
|
74 |
+
st.rerun()
|
75 |
+
|
76 |
+
st.session_state.prompt = st.session_state.prompt_input
|
77 |
+
st.text_area("Current prompt being used:", st.session_state.prompt, height=200, disabled=True)
|
78 |
+
|
79 |
+
if st.button("Generate Image"):
|
80 |
+
if st.session_state.prompt.strip():
|
81 |
+
with st.spinner("Generating image..."):
|
82 |
+
try:
|
83 |
+
response = client.images.generate(
|
84 |
+
model="dall-e-3",
|
85 |
+
prompt=st.session_state.prompt,
|
86 |
+
size="1024x1024",
|
87 |
+
quality="standard",
|
88 |
+
n=1
|
89 |
+
)
|
90 |
+
image_url = response.data[0].url
|
91 |
+
st.image(image_url, caption="Generated Image", use_column_width=True)
|
92 |
+
st.markdown(f"[Download Image]({image_url})", unsafe_allow_html=True)
|
93 |
+
except Exception as e:
|
94 |
+
st.error(f"Error: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
else:
|
96 |
+
st.warning("Please enter a valid prompt.")
|
97 |
+
|
98 |
+
elif agent == "Agent 3: Material Explorer":
|
99 |
+
st.header("๐ฆ Building Material Browser")
|
100 |
+
st.markdown("Browse current **laminate flooring** options from Home Depot.")
|
101 |
+
|
102 |
+
if st.button("Get Laminate Flooring Options"):
|
103 |
+
with st.spinner("Scraping Home Depot via Zyte..."):
|
104 |
+
html = zyte_scrape(LAMINATE_FLOORING_URL)
|
105 |
+
if html:
|
106 |
+
data = parse_home_depot(html)
|
107 |
+
if data:
|
108 |
+
st.success("Here are some laminate flooring options:")
|
109 |
+
st.table(data)
|
110 |
+
else:
|
111 |
+
st.warning("No products found. Parsing may need updating.")
|
112 |
+
else:
|
113 |
+
st.error("Failed to scrape the page.")
|
114 |
+
|
115 |
+
if __name__ == "__main__":
|
116 |
+
main()
|